Solved

MDI Access

Posted on 2003-12-08
6
262 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
A short film showing how OnPage and Connectwise integration works.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

937 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

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now