how to show existing form

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.
 
S

Stelrad Doulton

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();
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
C

Chris Dunaway

No, his original code was just creating an instance of a Form not an
instance of a Form2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top