110,499
社区成员
发帖
与我相关
我的任务
分享
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8)
{
e.Handled = true;
}
}
判断输入的是否为数字 至于长度你可以直接设置MaxLength 的。