给个最简单的方法: private void textBox3_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { //阻止从键盘输入键 e.Handled = true; if(e.KeyChar>='0' && e.KeyChar <='9') { e.Handled = false; } }