Dialog return values
Posted on 2004-11-11
I created a modal dialog with OK and Cancel buttons. Inside the dialog, I call the Close() function to close the dialog. But when I inspect the return value (see code below), it comes back as Cancel, even though I clicked on the OK button.
Password pwDlg = new Password();
System.Windows.Forms.DialogResult reply = pwDlg.ShowDialog(this);
if ( reply == System.Windows.Forms.DialogResult.OK )
// do something
By this I mean that the value of the reply variable is "Cancel".
Am I missing something? Should I be associating a button object with the some property so this built-in functionality works?
Thanks for the help.