Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 865
  • Last Modified:

From an MDI application - Call MDI Child form method from the Parent form?

Hello,

"jaime_olivares" helped me on this question to call an MDI Parent Form method from a child form:
http://www.experts-exchange.com/Microsoft/Development/.NET/Visual_CSharp/Q_22983140.html

Now I need to call a Child Forms method from its Parent. Anyone?


Here is my solution from "jaime_olivares" in the other question:
   ((MainForm2 )this.MDIParent).AddCamerastoButton();

NOTES:
- ChildMDItestForm = my Child form
- MainForm2 = my Parent Form
- AddCamerastoButton() method is on my MainForm2 = MDI Parent method
0
VirtueTech
Asked:
VirtueTech
  • 4
  • 3
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
in a mdi application you can have many child forms, not just one, so, how do you know which to call?
0
 
VirtueTechAuthor Commented:
I tried this but I get an error:
((ChildMDItestForm)this.MdiChildren).upgradeLayoutbyXML(1);

ERROR:
Cannot convert type 'System.Windows.Forms.Form[]' to 'SW24RC_DevEx.ChildMDItestForm'

0
 
VirtueTechAuthor Commented:
Similar to your comment jaime...the error states that I need to know which child form, thus the array.

I'm using the MDI Manager from DevExpress, and where I need to call the Child form method is always on the selected/active child form.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Jaime OlivaresSoftware ArchitectCommented:
MdiChildren is a collection. You have to pick one.
0
 
VirtueTechAuthor Commented:
how?
0
 
Jaime OlivaresSoftware ArchitectCommented:
ok, forget the MdiChildren collection. Use the  ActiveMdiChild property instead, but first you have to check if it is not null:

from your main form:

if (this.ActiveMdiChild != null)
{
         ((ChildMDItestForm)this.ActiveMdiChild).upgradeLayoutbyXML(1);
}

0
 
VirtueTechAuthor Commented:
Thank you Jaime! You're full of information and have been extremely helpful!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now