哈哈,我正好有这段代码
Private Sub setchildrennodes(node As node)
If node Is Nothing Then Exit Sub
If issystemcontrol = True Then Exit Sub
Dim child As node
Set child = node.child
If child Is Nothing Then Exit Sub
Dim nodecounter As Integer
If node.Children = 0 Then Exit Sub
For nodecounter = 1 To node.Children
issystemcontrol = True
child.Checked = node.Checked
issystemcontrol = False
Set child = child.Next
Call setchildrennodes(child)
Next
End SubPrivate Sub setparentnodes(node As node)
If node Is Nothing Then Exit Sub
Dim parentnode As node
Dim nownode As node
Dim flag As Boolean
Dim counter As Integer
flag = True
Set parentnode = node.Parent
If parentnode Is Nothing Then Exit Sub
Set nownode = node.FirstSibling
For counter = 1 To parentnode.Children
flag = flag And nownode.Checked
Set nownode = nownode.Next
Next
issystemcontrol = True
parentnode.Checked = flag
issystemcontrol = False
Call setparentnodes(parentnode)
End Sub在发生点击事件的时候调用就可以了,给分吧
Private Sub setchildrennodes(node As node)
If node Is Nothing Then Exit Sub
If issystemcontrol = True Then Exit Sub
Dim child As node
Set child = node.child
If child Is Nothing Then Exit Sub
Dim nodecounter As Integer
If node.Children = 0 Then Exit Sub
For nodecounter = 1 To node.Children
issystemcontrol = True
child.Checked = node.Checked
issystemcontrol = False
Set child = child.Next
Call setchildrennodes(child)
Next
End SubPrivate Sub setparentnodes(node As node)
If node Is Nothing Then Exit Sub
Dim parentnode As node
Dim nownode As node
Dim flag As Boolean
Dim counter As Integer
flag = True
Set parentnode = node.Parent
If parentnode Is Nothing Then Exit Sub
Set nownode = node.FirstSibling
For counter = 1 To parentnode.Children
flag = flag And nownode.Checked
Set nownode = nownode.Next
Next
issystemcontrol = True
parentnode.Checked = flag
issystemcontrol = False
Call setparentnodes(parentnode)
End Sub在发生点击事件的时候调用就可以了,给分吧
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货