'from Planet Source Code
Public Sub TreeCheckBoxes(TR As TreeView, CurrentNode As Node)
Dim lbDirty As Boolean, liCounter As Integer
Dim lParentNode As Node, lChildNode As Node
lbDirty = False
liNodeIndex = CurrentNode.Index
If CurrentNode.Checked = True Then
If Not TR.Nodes.Item(CurrentNode.Index).Child Is Nothing Then
Set lParentNode = TR.Nodes.Item(CurrentNode.Index).Child.FirstSibling
Do While Not lParentNode Is Nothing
lParentNode.Checked = CurrentNode.Checked
If Not lParentNode.Child Is Nothing Then
Set lChildNode = lParentNode.Child
Do While Not lChildNode Is Nothing
lChildNode.Checked = CurrentNode.Checked
If Not lChildNode.Next Is Nothing Then
Set lChildNode = lChildNode.Next
Else
Set lChildNode = lChildNode.Child
End If
Loop
End If
Set lParentNode = lParentNode.Next
Loop
End If
ElseIf CurrentNode.Checked = False Then 'node is unchecked
If Not TR.Nodes.Item(CurrentNode.Index).Child Is Nothing Then
Set lParentNode = TR.Nodes.Item(CurrentNode.Index).Child.FirstSibling
Do While Not lParentNode Is Nothing
lParentNode.Checked = CurrentNode.Checked
If Not lParentNode.Child Is Nothing Then
Set lChildNode = lParentNode.Child
Do While Not lChildNode Is Nothing
lChildNode.Checked = CurrentNode.Checked
If Not lChildNode.Next Is Nothing Then
Set lChildNode = lChildNode.Next
Else
Set lChildNode = lChildNode.Child
End If
Loop
End If
Set lParentNode = lParentNode.Next
Loop
End If
Set lParentNode = Nothing
Set lChildNode = Nothing
If Not CurrentNode.Parent Is Nothing Then
Set lParentNode = CurrentNode.Parent.Child
Do While Not lParentNode Is Nothing
Set lChildNode = lParentNode.FirstSibling
Do While Not lChildNode Is Nothing
If lChildNode.Checked = True Then
lbDirty = True
Exit Do
End If
Set lChildNode = lChildNode.Next
Loop
If Not lParentNode.Parent Is Nothing Then
Set lParentNode = lParentNode.Parent
Else
Set lParentNode = lParentNode.Parent
End If
Loop
End If
End If
Set CurrentNode = Nothing
Set lParentNode = Nothing
Set lChildNode = Nothing
End Sub