I have a button btnOK on my form, with a DialogResult property of OK. The form's AcceptButton property is set to btnOK. So if I click the button, the form closes automatically.
Now, inside the btnOK_Click() method, I want to ability to cancel out of the close action, e.g. if there was an error I want to show a message box and not close the form.
How do I do it?