arajoe
asked on
Looping through nodes in a tree
I have a VB6 program with a tree in a form. I already have the tree all populated. What I want to do know is build in the logic that if all of the children of a parent are checked then the parent itself will be checked, or true. If someone could please point me in the right direction with a sample of code, that would be great. Thanks, arajoe.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Private Sub Check_Parents(ByRef Node As MSComctlLib.Node, ByVal Node_Checked_Value As Boolean)
Dim Child As MSComctlLib.Node
Dim All_Checked As Boolean
If Node.Children > 0 Then
Set Child = Node.Child
Do While Not Child Is Nothing
Child.Checked = Node_Checked_Value
UnAssign_SUP Child
Check_Parents Child, Child.Checked
Set Child = Child.Next
Loop
End If
If Not Node.Parent Is Nothing Then
All_Checked = True
Set Child = Node.Parent.Child
Do While Not Child Is Nothing
If Not Child.Checked Then
All_Checked = False
Exit Do
End If
Set Child = Child.Next
Loop
Node.Parent.Checked = All_Checked
End If
End Sub