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();
        }
    };
原文地址:https://www.cnblogs.com/yao2yao4/p/3256360.html