Reputation: 5478
I have a TextEdit and need to limit its input to the following type of formats:
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?
Upvotes: 0
Views: 17741
Reputation: 18290
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;
}
Upvotes: 0
Reputation: 11326
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}
.
Upvotes: 0