I am using a TreeView with checkboxes. When the user checks a checkbox at any level - I want all the child nodes of the selected node to be checked in code.
Note that this will only check/uncheck the boxes of children on the first child level of the box you checked/unchecked. If you want to drill down all levels, then it's different.
Here. Use this if you need all "children of the children" to check and uncheck. This uses a function so it can recursively call itself and drill down through all levels..
Private Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)
NodeCHK Node
End Sub
Public Function NodeCHK(ByVal Node As MSComctlLib.Node)
Dim CNode As MSComctlLib.Node
For Each CNode In TreeView1.Nodes
If CNode.Parent Is Node Then
CNode.Checked = CNode.Parent.Checked
If CNode.Children > 0 Then NodeCHK CNode
End If
Next CNode
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.