以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  遍历父级 点了子级 所有的父线都取消勾选  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=160812)

--  作者:aoc103
--  发布时间:2021/2/22 23:09:00
--  遍历父级 点了子级 所有的父线都取消勾选
图片点击可在新窗口打开查看
现在 点了子级 父级能取消 但是 父级的父级却没有取消勾选 我希望 点了最子级  这个最子级的每个父级都取消勾选。不知道要如何实现
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd1 As WinForm.TreeNode = trv1.SelectedNode
Dim dr As DataRow

If e.node.ParentNode IsNot Nothing Then \'取消父节点的选中标记,因为选中子节点,就不要选中父节点了
    e.node.ParentNode.Checked = False
End If

For Each cnd As WinForm.TreeNode In e.Node.allNodes \'取消子节点的选中标记,因为选中父节点,就不要选中子节点了
    cnd.Checked = False

--  作者:有点蓝
--  发布时间:2021/2/23 8:31:00
--  
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd1 As WinForm.TreeNode = trv1.SelectedNode
Dim dr As DataRow
dim node as WinForm.TreeNode = e.node.ParentNode

do while node isnot nothing
    node.Checked = False
node = node.ParentNode
loop

For Each cnd As WinForm.TreeNode In e.Node.allNodes \'取消子节点的选中标记,因为选中父节点,就不要选中子节点了
    cnd.Checked = False