更新时间:2023-02-21 11:20:20
您显然没有正确验证它.我倾向于自己控制,因为带遮罩的文本框仅会告诉您何时输入了错误的内存.在按键或按键事件中,检查Char.IsControl和Char.IsAlpha,如果它们均失败,则拒绝按键.
You''re obviously not validating it properly. I tend to make my own control, because the masked text box just tells you when you entered something wrong, from memory. In the key press or key down event check Char.IsControl and Char.IsAlpha and if they both fail, reject the keypress.
使用Validating
^ ]或KeyDown
事件,然后编写一个简单的正则表达式以仅接受字母.
检查此答案 [ ^ ] out.
Use theValidating
event[^] orKeyDown
event and then write a simple regular expression to accept only alphabets.
Check this answer[^] out.