textbox的验证
代码如下:
textBox1.KeyDown += (a, b) => { if (b.KeyCode == Keys.Enter) { textBox2.Focus(); } }; textBox1.Leave += delegate { int result; if (!int.TryParse(textBox1.Text.Trim(), out result)) { MessageBox.Show("fsfd"); textBox1.Focus(); } };
代码如下:
textBox1.KeyDown += (a, b) => { if (b.KeyCode == Keys.Enter) { textBox2.Focus(); } }; textBox1.Leave += delegate { int result; if (!int.TryParse(textBox1.Text.Trim(), out result)) { MessageBox.Show("fsfd"); textBox1.Focus(); } };