C#.NET常见问题(FAQ)-如何让文本框textbox内容限制为数字

//限制文本框的输入

private void txtQuestionScore_KeyPress(object sender, KeyPressEventArgs e)

{

if (e.KeyChar != '\b')//这是允许输入退格键

{

if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字

{

e.Handled = true;

}

}

}

 

 

更多教学视频和资料下载,欢迎关注以下信息:

我的优酷空间:

http://i.youku.com/acetaohai123

 

我的在线论坛:

http://csrobot.gz01.bdysite.com/

 

问题交流:

QQ:910358960

邮箱:acetaohai123@163.com

 

 

posted @ 2017-10-03 11:48  gary_tao  阅读(1124)  评论(0编辑  收藏  举报
AmazingCounters.com 我要啦免费统计