Blog Stats
  • Posts - 14
  • Articles - 0
  • Comments - 6
  • Trackbacks - 0

 

Old school trick that I forgot

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.

Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 
 

 

 

Copyright © DavidMadden