Solved

MDI Access

Posted on 2003-12-08
6
266 Views
Last Modified: 2010-04-16
I have an MDI application

Within my parent I have the following for storing application wide data:

public string test;

I want to be able to read and write this from within a child form but this isn't visible to the child form when I try:

this.MdiParent.test = "xxx";

Any ideas how to get this to work?

Thanks

Dave
0
Comment
Question by:daveamour
  • 3
  • 3
6 Comments
 
LVL 20

Accepted Solution

by:
TheAvenger earned 25 total points
ID: 9899982
You should cast the parent to your form type. Let's say the

public string test;

is in a class called MainForm. Then this will work:

((MainForm)this.MdiParent).test = "xxx";
0
 
LVL 19

Author Comment

by:daveamour
ID: 9902766
Ok that works great, would I be opening a can of worms if I asked why you had to cast?

Thanks

Dave
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9902804
Because the MdiParent is of type Form and you included your variable in the type MainForm. C# is stricktly prohibiting the usage of not clearly declared members/methods so you have to tell it what exactly the type is
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Author Comment

by:daveamour
ID: 9902813
Ok I see, would have made more sense for .net to figure out what type the parent is for itself.

Thanks

Dave
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9902823
Not possible during design time because you can change it whenever you want....
0
 
LVL 19

Author Comment

by:daveamour
ID: 9902831
Good point
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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