Windows Develop Bookmark and Share   
 index > Windows Forms General > How can I run a method from child form?
 

How can I run a method from child form?

Hy there,

I would like to know how can I run a MDI's method from the child form. Actualy, I wanna run a method from the already openned MDI instance...

Does anyone help me?

Tks,

Luis Antonio

Lant  Tuesday, April 24, 2007 9:54 PM
You can do that in many ways, and it depends on the scenario in your application.
- declare event in child form. when opening child form subscribe to that child form event and in the event handler run that method. In child form, raise the event when you need to execute the method
- set the MdiParent property of the child form to the Mdi Form. In the child form when you need to run the method, cast the MdiParent to Mdi form type and run the mehtod. In this case this method must be public.
- you can also pass the mdi form instance as a parameter to the child form constructor, store that reference of mdi form in some field of Mdi form type, and leter when you need it, just execute the public method.
boban.s  Tuesday, April 24, 2007 10:07 PM
You can do that in many ways, and it depends on the scenario in your application.
- declare event in child form. when opening child form subscribe to that child form event and in the event handler run that method. In child form, raise the event when you need to execute the method
- set the MdiParent property of the child form to the Mdi Form. In the child form when you need to run the method, cast the MdiParent to Mdi form type and run the mehtod. In this case this method must be public.
- you can also pass the mdi form instance as a parameter to the child form constructor, store that reference of mdi form in some field of Mdi form type, and leter when you need it, just execute the public method.
boban.s  Tuesday, April 24, 2007 10:07 PM

You can use google to search for other answers

Custom Search

More Threads

• ListBox OwnerDrawn with UseCustomTabOffsets
• Keep two forms both visible!
• PrinterSettings is serializable... FAKE, Don't believe it.
• Scrollbar issue (.NET 2.0, C#)
• How to persist the settings of a ToolStrip using ToolStripManager using a class that inherits from ToolStrip
• Help with textboxes
• TextBox $$$ validation
• ComboBox Raise ShowItemsList Event
• How to Block the Keyboard Shortcut Alt + Space in UserControl?
• A question about listview (C#)