Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

Problem with a Dialog Window

Apr 4 2003 4:38 PM
Hi, I have a form that opens another form as modal window using ShowDialog(). I then check the DialogResult to figure out what to do next. If the DialogResult is OK, I then perform a check on a value entered in the form that is exposed as a property. If that check fails, I want to inform the user and open the dialog window again with their data so far and allow them to change the necessary entry. I have been able to do what I have described to this point. However, if the user enters some data, fails my test and I open the dialog form again, when they hit OK to clos that form, it just disappears. How can I handle that DialogResult the same way I do at the first without having to rewrite the code again? frmCostingElementInstance.ShowDialog(); //i want to come back here after and look at the result a second time if (frmCostingElementInstance.DialogResult == DialogResult.OK) { if (this.currentJob.IsDuplicate(frmCostingElementInstance.CostingElementData.Description)) { MessageBox.Show("You can't enter a second costing element with the same description"); frmCostingElementInstance.DialogResult = DialogResult.None; frmCostingElementInstance.ShowDialog(); //what to do from here } else { MessageBox.Show("Dialog result of OK"); ... } }

Answers (1)