Close Parent Form & open child form
Hi friends...!
My question is....
I have 2 forms.I want to close first/main/Parent form when I open 2nd form using btn_click event.
I went through several forums.But couldnt get a idea.
I used this form1's btn_click event.
Form2 f2=new Form2();
f2.Show();
this.Close();
but this will close whole application.
I wanna close first/Parent form and open child form after the btn_click.
::::I'm using VS 2008 and C#::::
Thanks.....
Charith
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

AlanRank #669 · 3.6K reputationPosted Nov 6, 2008, 6:04 AM EST
Just hide Form1 rather than close it which, as you say, will close the whole application.
If you like, you can also make Form1 visible again automatically when Form2 closes with code such as this:
// in button1_Click
Form2 f2 = new Form2();
f2.FormClosed += new FormClosedEventHandler(MakeVisibleAgain);
f2.Show();
this.Visible = false; // hide Form1
// add this handler to Form1
private void MakeVisibleAgain(object sender, FormClosedEventArgs e)
{
this.Visible = true;
}
Charith Liyanagamage112 reputationPosted Nov 6, 2008, 8:41 AM EST
vignesh durairaj2 reputationPosted Aug 1, 2009, 2:01 AM EDT
GUHAN S2 reputationPosted Jan 21, 2011, 2:07 AM EST