Mask

2 posts, 1 answers
  1. Philipp Egger
    Philipp Egger avatar
    5 posts
    Member since:
    Oct 2009

    Posted 27 Jun 2011 Link to this post

    Dear Experts,

    I would like to use the Mask property in RadMaskedNumericInput like "###'###'##0.00":

    <telerik:RadMaskedNumericInput Name="radMaskedNumericInput1" Mask="###'###'##0.00" />

    This does not work.

    I could set the mask "c9.2" and put the culture "de-CH":

    <telerik:RadMaskedNumericInput Name="radMaskedNumericInput1" Mask="c9.2" Culture="de-CH" />

    The reason why I want to define the mask as "###'###'##0.00" is because of ease of use for the end users. I want to enable my end users to freely define a char for the thousand separator (') and the decimal separator (.).

    I understood from the examples that I can change this by changing the culture. However, I think that end users do not know which separator is behind each culture.

    Therefore, my goal is to have different masks like i.e.:

    ###,###,##0.00
    ###'###'##0.00
    ### ### ##0,00
    ...

    Or if no decimals apply for specific currencies:

    ###,###,##0
    ###'###'##0
    ### ### ##0
    ...

    I tried with RadMaskedTextBox, but unfotunately it does not behave the same way as RadMaskedNumericInput when entering the value. I want to have the cursor set before the comma, when the field gets the focus. And if the user types in (. or ,) it shoud "jump" to the decimal places after the comma.

    Any ideas on how to set the mask property in RadMaskedNumericInput like "###,###,##0.00"?

    Best Regards,

    Philipp
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 30 Jun 2011 Link to this post

    Hi Philipp Egger,

    You can use the Mask "#9.2" and define your own Culture like so:
    public MainPage()
           {
               InitializeComponent();
               CultureInfo culture = new CultureInfo("MyCulture");
               culture.NumberFormat.CurrencyNegativePattern = 11;
               culture.NumberFormat.CurrencyPositivePattern = 2;
               culture.NumberFormat.CurrencyDecimalSeparator = ".";
               culture.NumberFormat.CurrencyGroupSeparator = ",";
               culture.NumberFormat.CurrencyGroupSizes = new int[]{3,3,3};
               //etc....
               this.maskInput.Culture = culture;
           }
    You need to create a new Culture every time you need to change it because the Culture property of the RadMaskedInputControls does not implement INotifyPropertyChanged interface.
    You can also use the KeyDown event handler in order to specify a non-default behavior when using the "." and "," keys.
    Please let us know if you need further assistance on this.

    Best wishes,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top