.net Masked Text Box

旧时模样 提交于 2019-12-11 05:46:55

问题


What is the mask for "percentage", in a WinForms application (VB.net)?


回答1:


Per the documentation here: http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask.aspx

\ Escape. Escapes a mask character, turning it into a literal. "\\" is the escape sequence for a backslash.

So the mask for a % sign is \%

Before posting, I made up a quick and dirty winforms app, tried it and it works.

Edit - added although this next item in the documentation makes it look like just a straight % sign should work without the backslash, so I tried it and it works as well.

All other characters Literals. All non-mask elements will appear as themselves within MaskedTextBox. Literals always occupy a static position in the mask at run time, and cannot be moved or deleted by the user.




回答2:


textEdit1.Properties.Mask.MaskType = Numeric;
textEdit1.Properties.Mask.EditMask = "00.00%%";
textEdit1.Properties.Mask.UseMaskAsDisplayFormat = true;

http://community.devexpress.com/forums/t/59535.aspx



来源:https://stackoverflow.com/questions/3165840/net-masked-text-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!