private void textBox1_KeyPress(object sender,KeyPressEventArgs e)
{
//数字0~9所对应的keychar为48~57
e.Handled = true;
//输入0-9
if ((e.KeyChar >= 47 && e.KeyChar <= 58))
{
e.Handled = false;
}
}
限制textBox的输入,只能输入数字
C# Winform textBox 只允许输入数字,布布扣,bubuko.com
时间: 2024-10-25 15:27:50