Solved

MDI Access

Posted on 2003-12-08
6
267 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
[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
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert VB web project to C# 3 66
c# ftp code 3 56
asp.net repeater 2 36
SQL State HYT00. Timeout expired proplem 8 43
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

734 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