0

Is it possible to skip validation with Close[X]box of windowsform? Something like this with a button that skip validation when hit

private void button1_Click(object sender, EventArgs e)
{
   AutoValidate = AutoValidate.Disable;
   Close();
}
Karlx Swanovski
  • 2,869
  • 9
  • 34
  • 67

1 Answers1

0

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);
}
Community
  • 1
  • 1
Karlx Swanovski
  • 2,869
  • 9
  • 34
  • 67