本文介绍了在文本框中不允许键入数字只允许字符uisng csharp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 文本框中的不允许在Windows applciation中键入数字仅允许使用csharp的字符。 名称文本框。 在上面的文本框中,我不允许键入数字只允许字符。 表示如何验证。 假设当用户在文本框中键入数字时,想要显示消息Numbers not Allowed。 将记录保存到记录中,显示弹出消息。 我怎么能用csharp。请帮帮我。 谢谢和问候, Narasiman P. 解决方案 Hi private void textBox1_KeyPress( object sender,KeyPressEventArgs e) { if ( !char.IsLetter(e.KeyChar)) { e.Handled = false ; } } 问候 Jegan 它非常简单只需添加事件,您可以直接选择设计器或代码只需在构造函数中编写以下内容 textBox1.KeyPress + = new KeyPressEventHandler(textBox1_KeyPress); private void textBox1_KeyPress( object sender,KeyPressEventArgs e) { if ( char .IsDigit( e.KeyChar)|| char .IsControl(e.KeyChar)) { e.Handled = 真; } 其他 { e.Handled = false ; } } hi professional 低于两个链接一用于数字限制和第二个用于角色......... http://stackoverflow.com/questions/463299/how-do-i-make-a -textbox-only-accepted-numbers [ ^ ] http://stackoverflow.com/questions/12607087/only-allow-specific-characters-in-textbox [ ^ ] 乐于助人。 in textbox wont allow to type Numbers Only allow Characters using csharp in windows applciation. Name textbox.In the above textbox i wont allow to type Numbers Only allow Characters.for that how to validate.suppose when user type the Numbers in the textbox, want to show the message "Numbers not Allowed".before saving the record in to record, show the popup message.for that how can i do using csharp. please help me.Thanks & regards,Narasiman P. 解决方案 Hiprivate void textBox1_KeyPress(object sender, KeyPressEventArgs e){ if (!char.IsLetter(e.KeyChar)) { e.Handled = false; }}RegardsJeganIts really simple just add event which you can directly select for designer or in code just write following in constructortextBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);private void textBox1_KeyPress(object sender, KeyPressEventArgs e){ if (char.IsDigit(e.KeyChar) || char.IsControl(e.KeyChar)) { e.Handled = true; } else { e.Handled = false; }}hi professionalbelow two link one for Numeric restriction and 2nd one for character.........http://stackoverflow.com/questions/463299/how-do-i-make-a-textbox-that-only-accepts-numbers[^]http://stackoverflow.com/questions/12607087/only-allow-specific-characters-in-textbox[^]Happy to Help. 这篇关于在文本框中不允许键入数字只允许字符uisng csharp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 00:56
查看更多