Results 1 to 4 of 4

Thread: [2.0] Accessing other form's control object

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Location
    Taiwan
    Posts
    37

    [2.0] Accessing other form's control object

    i've 2 child forms in one parent mdi form.
    Is it possible one child form access the other child form's control ? (such as label, etc)..

    what is the safe way to do this ? will it give cross thread error ?

    (actually i just want a form which is specialized to display some data, and another form to give command to the first form.)
    Last edited by ini_hendry; Aug 20th, 2006 at 05:03 AM.

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

    Re: [2.0] Accessing other form's control object

    There are no threads involved. Just like in any other situation it comes down to one object accessing members of another object. To do so the first object must have a reference to the second, just like always. The parent form is the link. It will presumably be creating both child forms so it will have to pass the first form a reference to the second. It's just like if you had two friends who didn't know each other who needed to talk. You'd give one of them the other one's phone number so that they could contact them. This is the same thing.
    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

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2006
    Location
    Taiwan
    Posts
    37

    Re: [2.0] Accessing other form's control object

    thx jm for the reply
    but i really don't know how to do what u say.
    can give me an example concrete code ?
    or maybe a link so that i can master this ?

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

    Re: [2.0] Accessing other form's control object

    Check out the "Forms in VB.NET" tutorial in my signature. The principles are exactly the same as for C# and you can use one of the code converter links in my signature if you need to convert the code samples. Remember that everything in .NET is an object and forms are no different. You've already done before exactly what you need to do here. It's just that you don't recognise it because, like so many other people, you can't see that forms are just like other objects.
    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