Showing Windows Forms

G

Guest

Hello,

I got my main form called Form1. Now I added Form2. On Form1 there is a
button that would make Form2 appear. What code should I add to the button so
that Form2 will appear when the button is pressed?

Mateusz Rajca
 
V

Vitaly Zayko

Form2 f2 = new Form2();
try
{
f2.ShowDialog();
}
finally
{
f2.Dispose();
}

If you don't want to show Form2 as a modal form use Show() instead.
 
G

Guest

Thank You

Vitaly Zayko said:
Form2 f2 = new Form2();
try
{
f2.ShowDialog();
}
finally
{
f2.Dispose();
}

If you don't want to show Form2 as a modal form use Show() instead.
 

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