Hello all. I am using the ShowDialog on a form (FormDialogBox). The
form exposes a custom property (UserName). I call the ShowDialog
method on the form, enter some data into the user name text box.
Press the OK button. Then from the calling class (the parent), check
for DialogResult.OK. If OK, then I display a MessageBox with the
UserName property. After calling Dispose on the frmDialog, I make
another call to MessageBox.Show passing in the same UserName property.
This displays back the same name, even after I called Dispose()? I
read that Close will not close because this was called via ShowDialog?
That's why I tried Dispose(). However, I have learned the a method
like Close() generally just calls Dispose? Well, in either case, I am
getting back the same result, the value of the UserName property i
sbeing returned twice. Can anyone explain this to me or point me to a
reference on this behavior?
FormDialogBox frmDialog = new FormDialogBox();
if (frmDialog.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("Thanks " + frmDialog.UserName);
frmDialog.Dispose();
MessageBox.Show("Thanks " + frmDialog.UserName);
}
TIA