Consulting

Results 1 to 1 of 1

Thread: Checkboxes in a Treeview

  1. #1
    VBAX Regular
    Joined
    Aug 2006
    Posts
    9
    Location

    Checkboxes in a Treeview

    Hello,
    do you have any code which supports better functionality of treeview checkboxes? Actually I mean if I check checkbox in a parent node, I expect all child nodes to check automatically. I expect the same of unchecking the checkbox. I started with following, but I can imagine a better solution not going through all nodes, but only for TreeView1.Nodes.Item(i).Children - unfortunately I cannot make it work.

    [vba]Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)
    Dim i As Integer
    If (Node.Checked = True) Then
    For i = 2 To TreeView1.Nodes.Count
    If (TreeView1.Nodes.Item(i).Parent.Checked = True) Then TreeView1.Nodes.Item(i).Checked = True
    Next i
    Else
    For i = 2 To TreeView1.Nodes.Count
    If (TreeView1.Nodes.Item(i).Parent = Node) Then
    TreeView1.Nodes.Item(i).Checked = False
    Call TreeView1_NodeCheck(TreeView1.Nodes.Item(i))
    End If
    Next i
    End If
    End Sub[/vba]

    Edit 9/5/20006 Code updated..

    Any Ideas?
    Last edited by Sowanso; 09-05-2006 at 01:10 AM.

Posting Permissions

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