Dim pd As WinForm.TreeNode = e.node.ParentNode Do While pd IsNot Nothing Dim cnt As Integer For Each cd As WinForm.TreeNode In pd.Nodes If cd.Checked Then cnt = cnt +1 End If Next If cnt > 0 Then pd.Checked = True Else pd.Checked = False End If pd = pd.ParentNode Loop For Each nd As WinForm.TreeNode In e.Node.AllNodes nd.Checked = e.Node.Checked Next