或在keyPress(object sender,KeypressEventArgs)中写
switch ((short)e.KeyChar)
{
case 13:case 48:case 49:case 50:case 51:case 52:
case 53:case 54:case 55:case 56:case 57:case 08:
//digits 0-9,backspace and Enter
e.Handled = false;
break;
default:
e.handled =true;
break;
}
可以在输入的时候就检查
switch ((short)e.KeyChar)
{
case 13:case 48:case 49:case 50:case 51:case 52:
case 53:case 54:case 55:case 56:case 57:case 08:
//digits 0-9,backspace and Enter
e.Handled = false;
break;
default:
e.handled =true;
break;
}
可以在输入的时候就检查