-4

I know this is very stupid question, but i cant find any anwser to my problem.

I have form1 and button I wanna open form2 when I click at that button but cant find the right code if anyone know the solution and if anyone knows the solution and is willing to share it, thank you

WolfMate
  • 11
  • 2
  • 1
    Possible duplicate of [Open Form2 from Form1, close Form1 from Form2](http://stackoverflow.com/questions/2958912/open-form2-from-form1-close-form1-from-form2) – NineBerry Oct 09 '16 at 13:11
  • [Windows Forms Tutorial](http://www.bing.com/search?q=winforms%20tutorial&qs=n&form=QBRE&pq=winforms%20tutorial&sc=8-17&sp=-1&sk=&cvid=DF37F768E5D349F48E192B8F9E5905B4) – Steve Oct 09 '16 at 13:11
  • Winform? Or webForm? – Vivek Nuna Oct 09 '16 at 13:12

3 Answers3

1

that should be in your OnClick event:

form2 newForm2 = new form2();
newForm2.ShowDialog();
0

Try this on button click event

using (Form2 frm = new Form2())
{
   frm.Show();
}

You can use ShowDialog() function if want modal form.

Nenad J.
  • 331
  • 2
  • 8
0

In the click event handler of your button, you need to create an instance of your form2 class and call Show():

form2 myFrom2 = new form2();
form2.Show();

The question is not stupid, but you really should try to find the answer yourself first:

https://www.google.at/?gws_rd=ssl#safe=off&q=wpf+show+window

Bernhard Koenig
  • 1,342
  • 13
  • 23