DevExpress XtraEditors TextEdit mask

17.5k views Asked by At

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?

2

There are 2 answers

0
Niranjan Singh On

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;
        }
0
shamp00 On

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}.