Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

checking all child nodes

5 views
Skip to first unread message

Vicky

unread,
Jun 30, 2001, 6:33:05 AM6/30/01
to
hi everybody

is there anyway by whihc i can check all the child nodes of a parent node in
a treeview when i click that parent node.When the chekbox property is true
for the treeview

please give me any code if available for this
vicky


Chris Petchey

unread,
Jun 30, 2001, 3:13:20 PM6/30/01
to
Vicky:

What you need is a recursive function to check the children of your node and
then check the children of the children etc

Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)
'If a node is checked (or unchecked) then do the same to its children
recursively
CheckChildren Node.Child, Node.Checked
End Sub


Private Function CheckChildren(Child As Node, Check As Boolean)
Do Until Child Is Nothing
'Check the child
Child.Checked = Check
'If this child has any children, check them too!
If Child.Children > 0 Then
CheckChildren Child.Child, Check
End If
'move on to this childs next sibling
Set Child = Child.Next
Loop

End Function

Private Sub Form_Load()
Dim i, b, c, tvw

For i = 1 To 5
Set tvw = TreeView1.Nodes.Add(, tvwChild, "A" & i, "A" & i)
For b = 1 To 5
Set tvw = TreeView1.Nodes.Add("A" & i, tvwChild, "B" & i & b, "B" &
b)
For c = 1 To 5
Set tvw = TreeView1.Nodes.Add("B" & i & b, tvwChild, "C" & i & b & c,
"C" & c)
Next c
Next b
Next i

End Sub


"Vicky" <vicks...@yahoo.com> wrote in message
news:#YHNqAVABHA.500@tkmsftngp07...

0 new messages