Handled
1. 设置textBox只可输入数字,并识别退格键
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))//如果不是退格键和数字
{ e.Handled = true; }
}
2.设置textBox不识别空格键:
private void textBox25_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == ' ') e.Handled = true;
}
textBox输入两个数字后,自动跳转到下一个textBox表格并选中其所有内容
private void NUM_TextChanged(object sender, EventArgs e)
{
if (((TextBox)sender).SelectionLength > 0) return;
if (((TextBox)sender).Text.Length >= 2)
{
SelectNextControl((Control)sender, true, true, true, true);
((TextBox)ActiveControl).SelectAll();
}
}