为输入框添加keyPress事件,然后添加代码: if ((e.KeyChar < || e.KeyChar > ) && e.KeyChar != && e.KeyChar != && e.KeyChar != ) e.Handled = true;