文本框上的所有检查 [英] all checks on textbox
本文介绍了文本框上的所有检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我有一个包含15种以上表格和许多文本框的应用程序
我想创建一个函数,其中所有检查都针对文本框
我有两种文本框
一个用于int
其他字符(50)
hi to all!
i have an application which consist more then fifteen forms and many textboxes
i want to create a function where all checks are ther for the textbox
i have two kinds of textbox
one for int
other for char (50)
推荐答案
使用正则表达式验证文本框.
您会发现许多使用正则表达式验证文本框的示例 ^ ]
Use Regular Expressions for validating textboxes.
You will find many examples of validating textboxes using Regular Expressions here[^]
//以下代码将仅接受带空格的数字
//following code will accept only numeric with Spaces
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar)&& !(e.KeyChar == ' ') ;
}
//以下代码将只接受带有空格的字符
//following code will accept only char''s with sapces
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !char.IsLetter(e.KeyChar) && !char.IsControl(e.KeyChar)&& !(e.KeyChar == ' ') ;
}
这篇关于文本框上的所有检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文