How to Close Parent Window from Child Window in C#.Net

Close The Parent Window from A Child Window


You can use the following code to close parent window when you navigate to the child window. Its very simple code using C#.Net.

CODE



private void btnOpenForm_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.FormClosed += new FormClosedEventHandler(frm2_FormClosed);
frm2.Show();
this.Hide();
}
private void frm2_FormClosed(object sender, FormClosedEventArgs e)
{
this.Close();
}


Regards,
Manoranjan Sahoo
Visit My Blog: http://msahoo.wordpress.com


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: