Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
How to Call MDI Form Event in Child Form
Posted
Comments
BillWoodruff 6-Jan-14 5:30am    
I agree with OriginalGriff's advice in his answer here, but I am curious to ask you why you would want an MDIChildForm to invoke an event in the MDIParentForm.

Is what you want to trigger a Click on an MDIParentForm's ToolStripMenuItem ?

1 solution

You can't: events can only be invoked from the class that created them. And Child forms should not know about the MDI parent unless they really, really have to - which they rarely do. Accessing Parents is a bad idea from an OOPs POV.

Instead, create an event in the Child form to which the Parent subscribes. In teh handler, teh Parent can take whatever action it deems appropriate.
See here: Transferring information between two forms, Part 2: Child to Parent[^]
 
Share this answer
 
Comments
BillWoodruff 6-Jan-14 6:14am    
It's possible, given another question the OP asked an hour ago, that he is talking about a triggering a Click Event in an MDIParent Form's MenuStrip from a MDIChildForm. That is possible due to the strange fact that the MDIParentForm automatically exposes, in all child Forms, a MDIForm.MainMenuStrip reference.

If that's the case, and the OP takes the trouble to clarify what they are asking about, I'll demonstrate that, even though I don't like it :)
OriginalGriff 6-Jan-14 6:27am    
Could be!
BTW: Your email is not ignored - I've just got back from the dentist, and I've got to take Herself shopping, so I'll reply when I get back.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900