How to hide MDI children instead of closing them?

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi,

I have an MDI application. The MDI children are instantiated when the
form loads and the user has the ability to show them or to hide them.
I trap the Closing event on the children and set e.Hide = true and
then call Hide() to hide the form.

The problem is when the application needs to exit. When the user
clicks the X on the MDI parent the Closing event is fired on all the
children *BEFORE* it's fired for the parent. The children cancel the
close so the application doesn't exit.

What's the right way to make this work?

Thanks,
John
 
Hi John,

Putting 'Application.Exit()' in the Closing event of the MDI form should do
the trick.

HTH,
Gary
 
Thanks for your reply.

The Closing event in the parent form never gets called if any of the
children forms sets e.Cancel = true.

Am I missing something?

Thanks,
John
 
The problem is when the application needs to exit. When the user
clicks the X on the MDI parent the Closing event is fired on all the
children *BEFORE* it's fired for the parent. The children cancel the
close so the application doesn't exit.


MSDN library - Closing event:
"To force all MDI parent and child forms to close, set the
System.Windows.Forms.ClosingEventArgs.Cancel property to false in
the MDI parent form."
 
Have you resolved this problem using the suggestions from the community
members, John?
Please feel free to reply this thread to let me know, if you still have
problem on it.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Back
Top