Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7439875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:46:07+00:00 2026-05-29T10:46:07+00:00

I have several TextBoxes, which display angular values. I format these using different custom

  • 0

I have several TextBoxes, which display angular values. I format these using different custom implementations of IFormatProvider, for example: The value 1.5707963267949 can be displayed as 1.5707963267949, 0.5π or 90°. The TextBoxes are one-way-databound and I perform the formatting by handling the Format event of the Binding:

void bindingToMyTextBox_Format(object sender, ConvertEventArgs e)
{
    // angleValueFormat is one of a few a custom implementations of 
    // IFormatProvider performing the actual formatting work.
    e.Value = String.Format(this.angleValueFormat, "{0:0.###}", (double)e.Value);
}

I want to allow the user to input values in the same format as they are displayed in. So I need to parse TextBox.Text to obtain the original value 1.5707963267949. Is there any "IParserProvider" interface providing parsing services, like IFormatProvider in the opposite direction? Or would you suggest a different approach?

From what I understand, i can’t use my IFormatProviders in the Convert.ToDouble Method (String, IFormatProvider) because, to determine in which format the number to parse is, it uses only the NumberFormatInfo-Object returned by the IFormatProvider.GetFormat(), which I obviously can’t use to specify the necessary info.

Thank you!

richn

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:46:07+00:00Added an answer on May 29, 2026 at 10:46 am

    No, that’s not possible. I think mostly because in general it’s not possible to automatically deduce a parser from a formatter (which is, iirc, internally implemented by a method ICustomFormatter.Format).

    I would suggest to define your own interface

    public interface IAngleParser {
        double ParseAngle(string);
    }
    

    and implement it in your classes for the angleValueFormat mamber. You’ll probably have to use some regexes or so to do that.

    Then you can use

    void bindingToMyTextBox_Parse(object sender, ConvertEventArgs e) {
        e.Value = ((IAngleParser)this.angleValueFormat).ParseAngle(e.Value);
    }
    

    and bind this to your binding’s Parse event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two sections(primary and secondary) in a form with several textboxes which display
I have an company asp.net website with textboxes which may contain several hundred words.
I have several TextBoxes which need to allow only numeric inputs. The problem is
I have several dropdownlists and textboxes inside an <asp:UpdatePanel> , which should let me
I have several projects in which I have for exemple, textboxes that I would
I have several textboxes in a form, and have a button which inserts all
In my project i have several TextBoxes which i have to fill dynmically. I
I have several textboxes where users can enter information into them. This can include
I have a login page that has several textboxes on the page, one of
I have these ViewModels: RecordViewModel, ComponentViewModel where RecordViewModel essentially is a container for several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.