|
The most straightforward way to do it is to override the behavior of the OnClosing method on the Form. Basically, this method passes an argument to the active control to see if it validates, and the Cancel flag on the argument is set accordingly. By overriding the value set on that flag, you can always allow the form to close:
protected override void OnClosing(CancelEventArgs e)
{
// Let the default behavior to happen.
base.OnClosing(e);
// Do not allow cancellation of the close operation.
e.Cancel = false;
}
|