<br /><br /> '<br /> 'This procedure checks the root node of any child under it<br /> '<br /> Private Sub CheckRootNode(ByVal GetNode As TreeNode)<br /><br /> Do While Not GetNode.Parent Is Nothing<br /><br /> Root = GetNode.Parent<br /> CheckRootNode(Root)<br /> Loop<br /><br /> TreeView1.Nodes(Root.Index).Checked = True<br /> End Sub<br /><br /> '<br /> 'This procedure checks all the child nodes of the parent<br /> '<br /> Private Sub CheckChildNodes(ByVal GetParentNode As TreeNode, ByVal CheckState As Boolean)<br /><br /> For Each xnode As TreeNode In GetParentNode.Nodes<br /> xnode.Checked = CheckState<br /> Next<br /><br /> End Sub<br />
<br /><br />Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck<br /><br /> Call CheckChildNodes(e.Node, e.Node.Checked)<br /> Call CheckRootNode(e.Node)<br />End Sub<br />
var