跳过验证与关闭[X]框的windowsform

本文关键字:框的 windowsform 验证 | 更新日期: 2023-09-27 18:13:16

是否可以跳过验证与关闭[X]框的windowsform?像这样的按钮,当点击

时跳过验证
private void button1_Click(object sender, EventArgs e)
{
   AutoValidate = AutoValidate.Disable;
   Close();
}

跳过验证与关闭[X]框的windowsform

https://stackoverflow.com/a/16544523/2322994

protected override void WndProc(ref Message m) {
    // Intercept WM_SYSCOMMAND, SC_CLOSE
    if (m.Msg == 0x112 && (m.WParam.ToInt32() & 0xfff0) == 0xf060) this.AutoValidate =   AutoValidate.Disable;
    base.WndProc(ref m);
}