简体   繁体   中英

Mask in C#: get a number that can be up to 10 digits in length that will accept leading 0's

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM