Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Winform form closed event

Tags:

c#

.net

winforms

I have 2 forms, Main and Child. When a button is clicked on the Main form, the Child form is loaded. Can I catch from the Main form, when the Child form is closed by subscribing to the closed event of the child form?

like image 638
Saif Khan Avatar asked Jul 24 '09 19:07

Saif Khan


1 Answers

Yes you can, it's pretty straightforward:

private void LoadChildForm_Click(object sender, EventArgs e)
{
    ChildForm form = new ChildForm();
    form.FormClosed += new FormClosedEventHandler(ChildFormClosed);
    form.Show();
}

void ChildFormClosed(object sender, FormClosedEventArgs e)
{
    // do something useful
}
like image 156
Fredrik Mörk Avatar answered Oct 10 '22 14:10

Fredrik Mörk