Formatting numeric input

2 posts, 0 answers
  1. Nejc Žerjal
    Nejc Žerjal avatar
    9 posts
    Member since:
    Nov 2009

    Posted 16 Oct 2013 Link to this post

    I have a problem with formatting numbers with Telerik controls (version Q3 2012).

    Requirements are
     - formatting similar to ###,###,##0.00## (limiting number of decimals and also number of digits on the left of decimal point) must be supported.
     - formatting mask must be invisible so with mask ###,###,##0.00## text should be only 0.00 and not ___,___,__0.00__.

    I have tried to implement this scenario with MaskedEditBox and Textbox but 
     - in MaskedEditBox i could not hide the mask
     - TextBox does not have any formatting options

    Is such scenario supported with Telerik controls?
  2. Dimitar
    Dimitar avatar
    1321 posts

    Posted 20 Oct 2013 Link to this post

    Hello Nejc,

    Thank you for writing.

    To achieve the desired behaviour you can use RadMaskedEditBox with MaskType set to Numeric and Mask set to "n2", also in this case you have to handle the KeyPress event in order to achieve the max length requirement:
    void radMaskedEditBox1_KeyPress(object sender, KeyPressEventArgs e)
        if (char.IsDigit(e.KeyChar) && radMaskedEditBox1.Text.Length >= 15 && radMaskedEditBox1.SelectionLength == 0
            && radMaskedEditBox1.Text.IndexOf('.') >= radMaskedEditBox1.SelectionStart)
            e.Handled = true;

    Alternatively you can use RadSpinEditor. With it you can easily set maximum value and decimal places:
    radSpinEditor1.DecimalPlaces = 2;
    radSpinEditor1.Maximum = 9999;

    I hope this helps. Should you have any other questions do not hesitate to ask.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft R3 2016 release webinar banner
Back to Top