Results 1 to 2 of 2

Thread: parent and child window

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width