DevExpress 控件 EditMask Numeric数字类型掩码

来源:互联网 发布:mysql 防止重复update 编辑:程序博客网 时间:2024/04/28 19:28

关于Numeric的EditMask说明:

  1. 可以用分号“;”分成两部分,前面是正数,后面是负数。(通过用户输入-来切换)
  2. 正数和负数小数点前、后的有效位数一定要相同,否则会报异常,所谓有效就是0、#、%等这样的。(位数不含负号-)
  3. 如果“;”字符和Mask负值省略,编辑器将使用默认的负值的NumberFormat对象决定的模式。所以”#######0.00;-#######0.00”和”#######0.00”将是同样的效果,这时建议直接用后者,不但简洁还可以避免正负两部分时小数点前面位数不一致造成异常。
  4. 如果不小心把EditMask设置成了有两个分号,那么也没有问题,只是第二个分号不做为分隔使用,而是做为负数的一部分,效果就是你一旦切换成负数时第二个分号连同后面的内容都会显示在输入框中,但一定要注意,第二个分号“;”后面不能写0、#、%等有效的掩码字符,否则仍会报异常。

官方说明摘要:

The ‘;’ character is used to separate the masks for positive and negative values.
The mask can contain two parts delimited by the ‘;’ character. The first part defines the mask for entering positive values, the second part specifies a mask for entering negative values. An end-user can toggle the value’s sign by pressing the ‘-’ key. In this case, depending upon the value’s sign, the value entered is automatically reformatted using the corresponding mask.
If the “;” character and mask for negative values are omitted, the editor will use the default pattern for negative values determined by the NumberFormat object.(如果“;”字符和Mask负值省略,编辑器将使用默认的负值的NumberFormat对象决定的模式。)
If the “;” character is followed by an empty string, the editor will not allow end-users to enter negative values.

示例代码

这里写图片描述

这里写图片描述