Solved

MDI Access

Posted on 2003-12-08
6
261 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

19 Experts available now in Live!

Get 1:1 Help Now