Created
December 18, 2014 20:05
-
-
Save joebuschmann/6a10c5813be82e46cc5a to your computer and use it in GitHub Desktop.
Prevent a dialog from closing by setting Form.DialogResult to None
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void btnOK_Click(object sender, EventArgs e) | |
| { | |
| if (Validate()) | |
| { | |
| // There's no need to explicitly hide the form | |
| // because the button's DialogResult property | |
| // has a value of DialogResult.OK | |
| // Details elided... | |
| } | |
| else | |
| { | |
| // Set the value of the form's DialogResult property | |
| // to DialogResult.None to prevent the form from closing. | |
| this.DialogResult = DialogResult.None; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment