Hello all,
I have an MdiParent with an MdiChild form. In the MdiChild form, I open a form for which the MdiChild is the Owner. My code is as follows:
// MdiChild opening form private void OpenForm() { Form3 frm = new Form3(); frm.Owner = this; frm.Show(); } // MdiParent's FormClosing private void Form1_FormClosing(object sender, FormClosingEventArgs e) { Properties.Settings.Default.Size = this.Size; Properties.Settings.Default.Save(); } // MdiChild's FormClosing private void Form2_FormClosing(object sender, FormClosingEventArgs e) { //this condition is rare so we can say that nothing else happens in this function if (condition) {//...} } // MdiChild OwnedForms's FormClosing private void Form3_FormClosing(object sender, FormClosingEventArgs e) { if (this.dataSet.HasChanges()) { DialogResult result = MessageBox.Show("Save changes?", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { UpdateData(); } else if (result == DialogResult.No) { // just let form close } else { e.Cancel = true; } } }
When I close the MdiParent, Form3 does not have its FormClosing event triggered. When I close the MdiChild it works fine. Any idea of why this is?
Thanks.