October 9, 2009

Close Parent Form from Child Form

How to Close Parent Form from Child Form in Windows Forms

C#
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();
}

No comments:

Post a Comment