|
-
Jan 3rd, 2007, 06:35 PM
#1
Thread Starter
Hyperactive Member
parent and child window
hello!
this is the prob, the parent window and the child window is opened.
in parent window there is a textbox, in child window there is a checkbox,
when i check the checkbox the textbox in parent window must enable or vise versa it will diable. how can do that?
in vb6 you can simply code form1.textbox.enabled=true, but not in C#.
tnx
-
Jan 3rd, 2007, 08:54 PM
#2
Re: parent and child window
The parent window is an object and the TextBox is a member. If you want to access a member of an object then you first need a reference to that object. That means that the child window needs a reference to the parent window. For that to happen the parent window must pass a reference to itself, i.e. 'this', to the child when it creates it. This can be done by setting a property or an argument of a method, which includes the constructor.
Now that the child has a reference to the parent it can access its public members. I would recommend against exposing the TextBox publicly. It is preferable to declare public properties or methods in the parent that will access only the members of the TextBox that are necessary to expose, in this case the Enabled property.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|