设置AfterCheckNode事件:
If e.node.Nodes.count > 0 Then
Dim cnt As Integer
For Each nd As WinForm.TreeNode In e.node.Nodes
If nd.Checked Then
cnt = cnt + 1
End If
Next
If cnt = 0 Then
e.node.Checked = False
End If
End If
Dim pd As WinForm.TreeNode = e.Node.ParentNode
If pd IsNot Nothing Then
Dim cnt As Integer
For Each nd As WinForm.TreeNode In pd.Nodes
If nd.Checked Then
cnt = cnt +1
End If
Next
If cnt = 0 Then
pd.Checked = False
End If
End If