'DevExpress XtraEditors TextEdit mask
I have a TextEdit and need to limit its input to the following type of formats:
- 00.000
- 0.000
- 00.00
- 0.00
- ...
There can be up to 3 decimal places. Integer part is not required.
The closest thing I've found is MaskType = Numeric with ###.### mask. However, this doesn't accept all zeros, which is a requirement.
Any suggestions?
ADD: I'm thinking of 0{0,3}\.0{0,3} with MaskType = RegEx. Is it a suitable choice?
Solution 1:[1]
Looks like you've answered your own question. Your RegEx looks fine.
If you meant to allow non-zero values too, such as 12.345 or 001.010, then the mask should be
[0-9]{0,3}\.[0-9]{0,3}.
Solution 2:[2]
Check XtraEditor's Mask Type: Numeric. you are setting wrong edit mask. on the place of ###.### use 000.000. Check the custom mask section on the specified link.
In case of #, the input string is converted to the editor's value, digits left empty are not stored in the result, but in case 0; the digits left empty are interpreted as zeros.
private void Form1_Load(object sender, EventArgs e)
{
textEdit1.Properties.Mask.MaskType = MaskType.Numeric;
textEdit1.Properties.Mask.EditMask = "000.000";
textEdit1.Properties.Mask.UseMaskAsDisplayFormat = true;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | shamp00 |
| Solution 2 | Niranjan Singh |
