This is a migrated thread and some comments may be shown as answers.

Formatting numeric input

1 Answer 978 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Nejc Žerjal
Top achievements
Rank 1
Nejc Žerjal asked on 16 Oct 2013, 08:35 AM

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?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 20 Oct 2013, 09:17 AM
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.

Regards,
Dimitar
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
Tags
MaskedEditBox
Asked by
Nejc Žerjal
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or