Solved

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

Posted on 2007-11-26
7
843 Views
Last Modified: 2013-12-16
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
Comment
Question by:VirtueTech
  • 4
  • 3
7 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20354222
in a mdi application you can have many child forms, not just one, so, how do you know which to call?
0
 

Author Comment

by:VirtueTech
ID: 20354331
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
 

Author Comment

by:VirtueTech
ID: 20354338
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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20354382
MdiChildren is a collection. You have to pick one.
0
 

Author Comment

by:VirtueTech
ID: 20354394
how?
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20354447
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
 

Author Closing Comment

by:VirtueTech
ID: 31411140
Thank you Jaime! You're full of information and have been extremely helpful!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question