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?
Form2 frm = new Form2();
frm.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frm_FormClosed);
. . .
private void frm_FormClosed(object sender, EventArgs e)
{
//Runs after closing child :)
}
Subscribe to the Closed Event
Form2 frm = new Form2();
frm.FormClosed += new FormClosedEventHandler(Form_Closed);
void Form_Closed(object sender, FormClosedEventArgs e)
{
Form2 frm = (Form2)sender;
MessageBox.Show(frm.Name);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With