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
AlanPosted Nov 6, 2008, 11:04 AM
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;
}
GUHAN SPosted Jan 21, 2011, 7:07 AM
vignesh durairajPosted Aug 1, 2009, 6:01 AM
Charith LiyanagamagePosted Nov 6, 2008, 1:41 PM