如何让文本框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;
}
}
}

 

posted @ 2018-05-07 22:42  ParanoiaApe  阅读(177)  评论(0)    收藏  举报