private void txt_KeyPress(object sender, KeyPressEventArgs e)
{
byte keyValue = (byte)e.KeyChar;//获取键盘按键的对应ASCII码
if ((keyValue < 48 || keyValue > 57) && keyValue != 8 && keyValue != 127)//数字之外的码不作处理,除去退格键及删除键
{
e.Handled = true;
}
}