c#winform下textbox限定只能输入数字
private void txtPort_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != '\b')//允许输入退格键 { if ((e.KeyChar < '0') || (e.KeyChar > '9'))//允许输入0-9数字 { e.Handled = true; } } }
private void txtPort_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != '\b')//允许输入退格键 { if ((e.KeyChar < '0') || (e.KeyChar > '9'))//允许输入0-9数字 { e.Handled = true; } } }