Diga Diga - 3 months ago 11
C# Question

Know When Child Form Closed

I've a Form1 with a button. When you click the button, this code block executes:

Form2 frm = new Form2();
frm.Name = "Form" + musteriNumarasi.ToString();
frm.Text = "Kullanıcı - " + musteriNumarasi.ToString();

Lets say I've clicked three times. There are four forms now: Main, Child1, Child2, Child3. When user closes one of the child forms, main form needs to know which one is closed. How can I do that?


Subscribe to the Closed Event

Form2 frm = new Form2();    
frm.FormClosed += new EventHandler(Form_Closed);

void Form_Closed(object sender, EventArgs e)
    Form2 frm = (Form2)sender;