Solved

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

Posted on 2007-11-26
7
848 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…

738 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