|
|
       
The purpose of this tutorial is to show you how to use Numeric mask with RadMaskedTextBox. The numeric mask is used when you need to display:
- Percent values.
- Decimal values.
- Currency (culture-aware).
- Fixed point values.
Setting Numeric Mask
In order to use numeric mask in RadMaskedTextBox, you need to set the RadMaskedTextBox's MaskType property to Numeric.
CopyXAML <telerik:RadMaskedTextBox MaskType="Numeric" /> Masking Elements
This subsection describes the mask characters that can be used when the MaskType property is set to Numeric. Note that the format characters are case sensitive.
1. Standard Numeric Format Codes- c, C - currency pattern.
- g, G, f, F - fixed point pattern.
- n, N - decimal pattern.
- p, P - percent pattern.
- d, D - standard pattern.
CopyXAML <StackPanel>
<TextBlock Text="Currency Pattern" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="c"
MaskType="Numeric"
Value="111.234" />
<TextBlock Text="Fixed Point Pattern" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="g"
MaskType="Numeric"
Value="111.234" />
<TextBlock Text="Decimal Pattern" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="n"
MaskType="Numeric"
Value="111.234" />
<TextBlock Text="Percent Pattern" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="p"
MaskType="Numeric"
Value="111.234" />
<TextBlock Text="Standard Pattern" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="d"
MaskType="Numeric"
Value="111.234" />
</StackPanel>2. Custom Numeric CodesWhen standard numeric codes are too restrictive, you can create your own custom formats using the format patterns listed below: - d5 - produce a 5 digits number. The user will not be able to insert more that 5 digits number.
- c5 - produce a currency with 5 digits after the decimal point.
- p5 - produce percent with 5 digits after the decimal point.
- n5 - produce a number with 5 digits after the decimal point.
CopyXAML <StackPanel>
<TextBlock Text="Five digits number" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="d5"
MaskType="Numeric" />
<TextBlock Text="Currency, five digits after decimal point" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="c5"
MaskType="Numeric" />
<TextBlock Text="Percent, five digits after decimal point" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="p5"
MaskType="Numeric" />
<TextBlock Text="Number, five digits after decimal point" />
<telerik:RadMaskedTextBox Margin="0,5,0,10"
Mask="n5"
MaskType="Numeric" />
</StackPanel> See Also
|