MDI Children Closing Event Not Firing

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
 
S

Steven Smith

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
 
B

Barry Gast

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
 
A

Armin Zingler

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.
 
B

Barry Gast

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top