Solved

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

Posted on 2007-11-26
7
841 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Store results in vb.net 3 22
C# winforms programmitically move panels 6 29
Expression Evaluater 3 27
Problem with SelectList in .NET MVC application 1 18
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 article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

822 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