Results 1 to 5 of 5

Thread: [RESOLVED] [2005] - TreeView Node and Windows Form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    111

    Resolved [RESOLVED] [2005] - TreeView Node and Windows Form

    Hi All,

    I currently have a TreeView with a bunch of nodes. After clicking on a selected node, I would like to display a windows form. I can assign the form to the "NodeMouseClickEvent", but that will load the same form for every node.

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

    Re: [2005] - TreeView Node and Windows Form

    The NodeMouseClick event handler gives you a reference to the node that was clicked, so you can then display the appropriate form for that node.
    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
    Lively Member
    Join Date
    Jan 2006
    Posts
    111

    Question Re: [2005] - TreeView Node and Windows Form

    Possible to get any article links or examples? I tried Google and MSDN but their solutions are not really answering my question.

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

    Re: [2005] - TreeView Node and Windows Form

    As with all event handlers, the data for the NodeMouseClick event is provide via the 'e' parameter. The type of the 'e' parameter changes depending on the event being handled. In this case it's a TreeNodeMouseClickEventArgs object. That class has a Node property that returns a reference to the node that was clicked. You simply check which node that is and open the appropriate form, e.g.
    vb.net Code:
    1. Dim node As TreeNode = e.Node
    2.  
    3. If node Is Me.node1 Then
    4.     'Open form 1.
    5. ElseIf node Is Me.node2 Then
    6.     'Open form 2.
    7. End If
    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    111

    Talking Re: [2005] - TreeView Node and Windows Form

    Thanks for the solution Worked like a charm

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