Results 1 to 3 of 3

Thread: clicking on child in treeview control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    Hi there,

    I have a treeview control with parent and child nodes. When you click the 'Main Menu' (Parent node), 3 child nodes appear as I have in the code below.

    I want to have it so that, when one of the child nodes is clicked, a respective textbox will appear on my form (I have all textboxes set to visible=false). Could someone tell me how to do this, please?


    Private Sub Form_Load()
    Dim ndsnode As Node
    ' Here your making the first Main Nodes
    Set ndsnode = treeview.Nodes.Add(, , "MAIN1", "Main Menu")
    ' Here you make child nodes under Main1 Node
    Set ndsnode = treeview.Nodes.Add("MAIN1", tvwChild, "CHILD1" & A, "Part 1")
    Set ndsnode = treeview.Nodes.Add("MAIN1", tvwChild, "CHILD2" & A, "Part 2")
    Set ndsnode = treeview.Nodes.Add("MAIN1", tvwChild, "CHILD3" & A, "Part 3")
    End Sub

  2. #2
    Lively Member
    Join Date
    Jun 1999
    Location
    East Anglia, England
    Posts
    73
    Here you go this should hopefully help you,

    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Dim ndsnode As Node
        ' Here your making the first Main Nodes
        Set ndsnode = TreeView.Nodes.Add(, , "MAIN1", "Main Menu")
        ' Here you make child nodes under Main1 Node
        Set ndsnode = TreeView.Nodes.Add("MAIN1", tvwChild, "CHILD1", "Part 1")
        Set ndsnode = TreeView.Nodes.Add("MAIN1", tvwChild, "CHILD2", "Part 2")
        Set ndsnode = TreeView.Nodes.Add("MAIN1", tvwChild, "CHILD3", "Part 3")
    End Sub
    
    
    Private Sub TreeView_NodeClick(ByVal Node As ComctlLib.Node)
        Select Case Node
            Case "Part 1"
                MsgBox "Node - Part 1 was clicked"
            Case "Part 2"
                MsgBox "Node - Part 2 was clicked"
            Case "Part 3"
                MsgBox "Node - Part 3 was clicked"
        End Select
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281
    Thanks Desire,

    Just what I was looking for!

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