Link to home
Start Free TrialLog in
Avatar of VirtueTech
VirtueTech

asked on

From an MDI application call MDI Parent method from MDI Child - And Visa-Versa??

I have an MDI Application:

How do I call a MDI Parent method from my MDI Child form?

And visa-versa - how do I call a MDI Child method from my MDI Parent?
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

your mdi child has an MDIParent property.
But you have to cast it properly before using:

((your_mdiform_classname)this.MDIParent).somemethod();
Avatar of VirtueTech
VirtueTech

ASKER

I get an Error when making this call:
   ((MainForm2 )this.MDIParent).AddCamerastoButton();

ERROR:
'SW24RC_DevEx.ChildMDItestForm' does not contain a definition for 'MDIParent'      


NOTES:
- Strange this is "Intellisense" allows me to choose the MainForm2.AddCamerastoButton method.
- ChildMDItestForm = my Child form
- MainForm2 = my Parent Form
- AddCamerastoButton() method is on my MainForm2 = MDI Parent method

ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.  
How Can I do this from the Child MDI form?

Meaning how can I call a Parent method from the child?
Something like I stated earlier:

((your_mdiparentform_classname)this.MdiParent).somemethod();
Yeah...I was tryng something like that, trying to use Intellisense to figure it out, but I had no luck.
jaime - please reffer to the following NEW question on the subject of calling a Child method from the Parent Form:
https://www.experts-exchange.com/questions/22983879/From-an-MDI-application-Call-MDI-Child-form-method-from-the-Parent-form.html