Geeks With Blogs

David Madden Mastering the craft one mountain at a time.
If you have to support some older Winforms you might like to remember this.  When opening a MessageBox to display that the user entered incorrect information, if you are doing so from a dialog, catch the DialogResult of the MessageBox and then set 

this.DialogResult = DialogResult.None;

 to prevent the dialog from closing if you want the user to try again.  Otherwise, it will close the dialog box and return to the section of code that called it.

Note:  You do not have to catch the DialogResult from the MessageBox.  You can still set this after the return from the call to the MessageBox.  Just make sure to do either but exiting the body of the dialog itself.
Posted on Wednesday, November 28, 2012 8:42 AM | Back to top

Comments on this post: Old school trick that I forgot

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © DavidMadden | Powered by: