473,480 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MDI child access to it's parents' controls

This sounds so easy to me and feel like an idiot that I can't figure it out,
but....how can I have a MDI child access it's parents control(s)??

Seems like it should be as easy as making the controls on the parent public,
so i created a new project real quick w/2 forms. One is the MDIParent
container and then one child form.

On the MDIParent i put a textbox (textbox1) and set it to public.
From the child code I just try to do a this.MDIParent.textbox1, but there is
no "textbox1" listed under this.MDIParent

What am I doing wrong? Somebody hit me over the head and knock me to my
senses!!
Nov 16 '05 #1
1 1764
Hi Lucas,

You can't see the textbox because MDIParent is stored as a Form object,
which has no textbox.

You need to cast it to your parent class to access its methods.

((MyParent)this.MDIParent).textbox1.Text = "Hello World!";

That said, you should instead use public properties instead of directly
accessing the textbox.

public string TextBoxText
{
set
{
//if(ValidText(value))
textbox1.Text = value;
}
get
{
//if(contentCanBePassed == true)
return textbox1.Text;
//else
// return "";
}
}

This way the parent can keep control of its own textbox.
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2645
by: Suzanne Vogel | last post by:
Hi, I've been trying to write a function to test whether one class is derived from another class. I am given only id's of the two classes. Therefore, direct use of template methods is not an...
13
7350
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
4
9759
by: james | last post by:
I have a custom UserControl, which can have many sub class levels derived from it. I want to be able to discover all the components at Load time, but the only components I can see from the base...
1
1515
by: szabelin | last post by:
Hi there were a few postings earlier, including mine regarding this. It looks as if when a dynamic child control causes a postback, its handler never gets called, and the control is null. This...
0
1417
by: ILCSP | last post by:
Hello, I have a VB.Net project where I have created a dynamic menu. This menu has 2 parents (File and Edit) and I need to place 3 child submenus under Edit at runtime. The problem is that I am...
2
6040
by: Fred Heida | last post by:
Hi, Question on Vista Run As Administrator. If i have exe which creates a child process, using the Process class, and this exe is Run As Asministror, is there a way to have the child process...
8
5957
by: Rick | last post by:
VS 2005 I' m setting up a parent/child datagridviews in a form. I am doing a lot of this by hand coding in order to get the feel of things. I want a change in the parent table to trigger a...
1
1724
by: Seth Petry-Johnson | last post by:
Is there a way to compile a user control into a redistributable assembly , but still have access to its child controls using the .Controls property? Here's what I mean: I have a user control...
0
2627
muaddubby
by: muaddubby | last post by:
Hi I've got a situation with a dataset that contains two tables with a many-to-one relationship, and am trying to extract the data in xml format. When I execute the GetXml() method, and exception...
0
7044
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7045
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7087
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4483
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2985
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.