how to show existing form

  • Thread starter Thread starter Eugene Turin
  • Start date Start date
E

Eugene Turin

Hi people.

I have a question - how to show existnig form?

I create two forms: Form1 and Form2 in designer. I place a button on
Form1 and I want to call a Form2 (better in modal mode!).

It's simple to show NEW form:
Form Form2 = new Form();
Form2.Show();

but i want to call a form I designed before.
 
Isn't that the same?

Make form2 a member variable of your main form. In the main form's
construction instantiate form2. In the click handler call
form2.ShowDialog();
 
Eugene,

If you want to show a form that you have hidden before, then in the
instance of Form1 that you have, you should store the instance of Form2 that
was previously shown. Then, all you have to do is reference that parameter
and call the Show method.

Hope this helps.
 
No, his original code was just creating an instance of a Form not an
instance of a Form2
 
Back
Top