473,598 Members | 3,409 Online
Bytes | Software Development & Data Engineering Community
+ 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 1777
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).tex tbox1.Text = "Hello World!";

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

public string TextBoxText
{
set
{
//if(ValidText(va lue))
textbox1.Text = value;
}
get
{
//if(contentCanBe Passed == 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
2663
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 option. Let's call the id of a class "cid" (for "class id"). The function signature should look like this: ******************************************
13
7393
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 created forms for both those tables, and inserted the child table form into the master table form as a subform. It works just as it is supposed to, in that I can create a new master record, and then add detail records.
4
9771
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 class are the private components internal to the base class itself. What I want are ALL components for the entire class no matter how many levels of sub-classing this particular control contains. I do not want to have to force the child classes to...
1
1527
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 seems wierd. What about bubbing events to parents in DataGrid - if events are never even triggered? Can somebody explain this please. Thank you
0
1436
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 using dynamic menus where I get the values from a SQL 2000 table. I have a variable called "mnu" as the name of the child menu. I have another variable with the name of the parent menu "sct". I loop through a data table to get the child and...
2
6056
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 also Run As Asministror with out confirmation for this (as this is already doen my the main process) ? Cheers,
8
5963
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 change in the child. Where is the best place (if I cannot set it up to be automatic through relationships) to catch the change in the parent to refetch the child rows?
1
1730
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 that contains some child controls, mostly custom text boxes and such. If I load this control declaratively or using LoadControl(), I can access those child controls using the .Controls property.
0
2648
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 is thrown telling me that "A child row has multiple parents", and the xml is obviously not generated. The output I'm expecting is something like this: <parent> <parentRecnum>1</parentRecnum> <childRecnum>1</childRecnum> <child>
0
7991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7902
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8398
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8265
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2412
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1250
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.