I got the following code from the samples and was wondering how to make it work clear up to the root node?
' This method only has relevance for non root-level nodes
If Not parentNode Is Nothing Then
' Get the nodes collection to which the specified descendantNode belongs
' Iterate the nodes collection and get a count of
' the number of checked nodes
Dim i As Integer
Dim node As UltraTreeNode = nodesCollection(i)
Next i
' If all the child nodes are checked, set the parent's CheckState
' to 'Checked'; if none are checked then set the parent's CheckState
' to 'Unchecked'; if some but not all are checked, make it 'Indeterminate'.
If checkedNodesCount = nodesCollection.Count Then
parentNode.CheckedState = CheckState.Checked
ElseIf checkedNodesCount <> 0 Then
parentNode.CheckedState = CheckState.Indeterminate
Else
parentNode.CheckedState = CheckState.Unchecked
End If
End Sub
Modify that method to support calling itself recursively, so that it is called on the immediate children of 'descendantNode', which in turn will call it on their children, an so on.
Easy enough. Thanks.
Using this code it only takes the user up one branch of the tree. How do I check all branches of a node to see if the parent node should be checked or indeterminate.
The first and second lines of code in the method are expecting descendantNode to have a parent node, which will not be the case when descendantNode is a root level node. In that case, get the TreeNodesCollection from the control's Nodes property instead of the node's Nodes property.