MDI Children Closing Event Not Firing

  • Thread starter Thread starter Barry Gast
  • Start date Start date
B

Barry Gast

Hi. I have an MDI Parent form with multiple child windows. When I close
the parent form, the Closing events of the children forms are not executing.
Do I have to close all the child forms in the parent's closing event in
order to get the closing events of the children forms to execute?

Thanks.

-Barry
 
Possibly not exactly what you are looking for but I would
use this to close all active children:

\\\
Dim frmChild As Form
For Each frmChild In Me.MdiChildren()
Me.ActiveMdiChild.Close()
Next frmChild
///


Regards Steve
 
That works for the events, but now I can't seem to get the
CancelEventArgs.Cancel property to "bubble-up" back to the parent MDI form
to prevent it's closing.

Any ideas?

-Barry
 
Barry Gast said:
Hi. I have an MDI Parent form with multiple child windows. When I
close the parent form, the Closing events of the children forms are
not executing. Do I have to close all the child forms in the parent's
closing event in order to get the closing events of the children
forms to execute?

No, the Closing events should fire in the child windows. How do you close
the MDI parent? If you call application.exit or even execute "End", the app
is killed the hard way => no closing events fired.
 
The closing events of the child forms now fire, and the cancel property of
the CancelEventArgs parameter "bubbles-up" back to the MDI form.

My close function originally had the Application.Exit command in it, which
by-passed all the closing events of all the forms. Now I just issue a
Me.Close command for the MDI Parent form, and my Sub Main() handles the rest
of the application closing functions.

Thanks!

-Barry
 
Back
Top