In my Visual C# program I have 2 forms call Form1
& Form2
.
Form1
has a button call btnfrm1
and Form2
has a button call btnfrm2
.
What I need my program to do is :-
When I press the btnfrm1
it need to open Form2
and hide the Form1
& when I press the btnfrm2
it needs to show the Form1
again and close the Form2
.
What I have coded for the btnfrm1
's click event is this
Form2 frm2= new Form2();
frm2.Show();
this.Hide();
But I don't know what to write in Form2's btnfrm2
click event to make Form2 disappear and Form1 reappear.
Can someone help me? any help I appreciate
Try following code
Form1 frm1 = (Form1)Application.OpenForms["Form1"];
frm1.Show();
this.Close();