如何来判断让一个文本框的值必须为数字的??? 正则表达式ms-help://MS.MSDNQTR.2003FEB.2052/cpgenref/html/cpconregularexpressionvalidatorcontrol.htm 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string regx = @"^\d+$";string temp = "9832a1232";Regex reg = new Regex(regx );if( !reg.IsMatch(temp) ){ Console.write("error");}顺便说一下,楼主没有可用分的话,我可以给你:) 正则表达式最简单,表达式为使用RegularExpressionValidator控件在VailidationExpression属性中输入\d在controltovalidate属性中输入你要控件的文本框 作textBox的KeyPress事件 -》只能输入数字和退格符(BackSpace)private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(!Char.IsDigit(e.KeyChar) && e.KeyChar != Keys.Back) { e.Handled=true; } } 有关c# webbroswer 的问题? 严重问题:后台程序第三方dll的消息提示框 C# WinForm 中 TreeView CheckBoxes属性问题 form里有个panel,panle里有个button,请问怎么得到这个button在form里的坐标。 想实现个线条厚度,画出有厚度的线 .net的症结么?已停止工作,要求关闭程序 帮忙估各价格 谢谢!! C# 如何让父窗口截获消息? 怎么获得重定向地址? C#里面怎么取一个string的第n到n个字符?我只能找到remove,没有别的方法吗? 存储过程总是不正确,请看看。。。。 C#的udp应用问题?
string temp = "9832a1232";
Regex reg = new Regex(regx );
if( !reg.IsMatch(temp) )
{
Console.write("error");
}顺便说一下,楼主没有可用分的话,我可以给你:)
表达式为
使用RegularExpressionValidator控件
在VailidationExpression属性中输入\d
在controltovalidate属性中输入你要控件的文本框
{
if(!Char.IsDigit(e.KeyChar) && e.KeyChar != Keys.Back)
{
e.Handled=true;
}
}