Windows Develop Bookmark and Share   
 index > Windows Forms General > Destruction of MDI ChildForms
 

Destruction of MDI ChildForms

A simple question : If you close the MDI parentform, are the childforms closed and disposed of automatically?

My issue is as follows:
I have an application with a MDI parent from, which has several child forms open. Now, if I press a button on Child A it raises an event X to all the other ChildForms, those in turn raise event Y that child A is listening to. (Essentially the construct is to query and report back certain status information from selected children). This works all very fine, however

if I close the parent form (the application stays alive), and then reopen it I now get event Y back twice, if I close and reopen again three times...etc.

I have been through all my class instantiations and cannot see anything wrong with it, so my suspicion now is that when I close the parent the children stay alive but invisible - this may be also supported by that reloading the parent takes longer with each attempt.

Am I on the right track, and has anyone a cure?

(I have already tried closing the children explicitely in the parent close button, but that does not do it either)

Any help or hints greatly appreciated.
TheEnglishPatient  Wednesday, September 30, 2009 11:21 AM
Hi,

I am not sure I have understood your situation clearly. Based on my understanding, you want to avoid event handled method being registered multi-time. So I think you can do unregister before you register it. In C#, you can use “-=” to unregister the method while in VB, using RemoveHandler. It doesn’t matter whether you have already registered, unregister always works.

If I misunderstood you, please feel free to tell me.

Sincerely,
Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!
Kira Qian  Tuesday, October 06, 2009 9:35 AM

You can use google to search for other answers

Custom Search

More Threads

• Moving the input character position in a textbox
• Drag and Drop with Tree component
• incorporating license key approach for a WinForms app? what approach?
• Configuring the help provider control
• Copying Events.
• Extremely slow painting on TabControl, GroupBox and Label with transparent back color
• Notify Icon double-click
• Saving a Path to Configuration
• TreeView fails to display icons, why?
• How to convert string to int