How to return the result of dialog window work in the moment of its closing?
Everyone knows the MessageBox.Show() method, that returns DialogResult value after dialog closed. How can I implement such a metho开发者_StackOverflow中文版d in my dialog class?
class MyDialog : Form {
public static MyDialogResult Show() {};
}
The problem, as you can guess, is that the method returns a value only after user clicks some button in the dialog.
You can also set the DialogResult property on a button. If that button is clicked then the specified value will be returned by the ShowDialog() method.
In your handler which closes your dialog, put this before closing:
DialogResult = DialogResult.OK;
Or whatever you want the result to be.
Very useful answers. Thanks! But I've solved my problem yet, using mutex. It provides ability to return results of different types. So, my showDialog() method returns a string ).
精彩评论