How to inform one form that another has ended...

I have 2 forms:
form1, form2.

form1 creates a new instance of form2 in the standard way, I want form1 to perform a method when form2 closes, but how do I inform form1 that this has occured and to go ahead and start the method?

LVL 9
WinterMuteUKAsked:
Who is Participating?
 
astankovicCommented:
This will do it:

   Form dlg = new Form();

   if (dlg.ShowDialog() == DialogResult.OK )
   {
        //call your method here
   }

0
 
WinterMuteUKAuthor Commented:
How do I return a 'DialogResult.OK' value?

Currently I have it set up:

01.  if (dlg.ShowDialog() == DialogResult.OK )
02.  {
03.      MessageBox.Show("Got Here (1)");
04.  }
05.  MessageBox.Show("Got Here (2)");

And if I place a break point on line 03 the code shows the form, and when I close the form (using this.Close();) it just skips to line 05.

Thanks again.

Me.
0
 
WinterMuteUKAuthor Commented:
Right,

Found it, if I set the DialogResult property of the buttons on the form!

Thanks for the help

Me.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.