如何让文本框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; } } }
//限制文本框的输入
private void txtQuestionScore_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != '\b')//这是允许输入退格键 { if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字 { e.Handled = true; } } }