C# 中的掩码:获取长度最多为 10 位且接受前导 0 的数字
我想这将是一个 DevExpress 掩码,但这就是我所拥有的:
var dlEdit = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
dlEdit.Mask.MaskType = MaskType.RegEx;
dlEdit.Mask.EditMask = "\\d{1,10}";
我正在尝试获取一个长度最多为 10 位的数字,该数字将接受前导 0,因为现在它将显示前导 0(例如 0032421243),直到单击该字段,在这种情况下它将删除它们。我尝试了数字掩码类型,但同样的事情只是它根本不允许我输入 0 开始。我认为这将是我的答案,但这种自定义类型不是。有人可以为我指明我需要的正确方向吗?也许是不同类型的面具之类的?
I guess this would be a DevExpress mask, but here is what I have:
var dlEdit = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
dlEdit.Mask.MaskType = MaskType.RegEx;
dlEdit.Mask.EditMask = "\\d{1,10}";
I'm trying to get a number that can be up to 10 digits in length that WILL accept leading 0's, as it is now it will show the leading 0's (ex. 0032421243) until the field is clicked off in which case it removes them. I tried a numeric masktype but same thing only it wouldn't let me enter the 0's to start with at all. I thought this would be my answer but this custom type isn't. Can someone point me in the right direction for what I need? Maybe a different type of mask or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的面膜很适合我。
您是否绑定到数字字段?
如果是这样,你不能这样做;数字字段不能存储前导零。
切换到
字符串
字段。Your mask works fine for me.
Are you binding to a numeric field?
If so, you can't do this; numeric fields cannot store leading zeroes.
Switch to a
string
field.