Solved

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

Posted on 2007-11-26
7
853 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

623 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