但是会引发每个子节点的BeforeCheck,
只好在treeview 的MouseDown对全局标志isChecked=true,
在BeforeCheck 子节点处理完成后 isChecked=false
在BeforeCheck 子节点处理前 判断 isChecked If isChecked = False Then Return
还有其他好办法吗???
5 个解决方案
#1
treeview很少用,不是很熟悉!
#2
能不能母节点没有选中,设子节点无效呀?
#3
\\
#4
选中子节点时,连同父节点一起选中
Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
Dim tn As TreeNode = e.Node
If tn.Checked = True Then
tn = e.Node.Parent
While Not tn Is Nothing
tn.Checked = True
tn = tn.Parent
End While
End If
End Sub
也可以反过来试吧
Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
Dim tn As TreeNode = e.Node
If tn.Checked = True Then
tn = e.Node.Parent
While Not tn Is Nothing
tn.Checked = True
tn = tn.Parent
End While
End If
End Sub
也可以反过来试吧
#5
使用递归算法一定可以,俺就是这样做的。
#1
treeview很少用,不是很熟悉!
#2
能不能母节点没有选中,设子节点无效呀?
#3
\\
#4
选中子节点时,连同父节点一起选中
Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
Dim tn As TreeNode = e.Node
If tn.Checked = True Then
tn = e.Node.Parent
While Not tn Is Nothing
tn.Checked = True
tn = tn.Parent
End While
End If
End Sub
也可以反过来试吧
Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
Dim tn As TreeNode = e.Node
If tn.Checked = True Then
tn = e.Node.Parent
While Not tn Is Nothing
tn.Checked = True
tn = tn.Parent
End While
End If
End Sub
也可以反过来试吧
#5
使用递归算法一定可以,俺就是这样做的。