清除所有asp:TreeView
复选框以便全部取消选中的最佳方法是什么?我已经尝试迭代treenodes并取消选中,但这对于子节点复选框不起作用。
答案 0 :(得分:1)
你自己的答案很接近,但不会越过树。尝试这样的递归方法。
Private Sub unCheckNodesIncludingDescendants(Node as TreeNode)
Node.checked=false
For Each tn As TreeNode In Node.ChildNodes
tn.Checked = False
unCheckNodesIncludingDescendants(tn)
Next tn
End Sub
您的初次通话将如下所示:
private sub UncheckWholeTree(TreeControl as TreeView)
For each rootNode as TreeNode in TreeControl.nodes
unCheckNodesIncludingDescendants(rootNode)
Next rootNode
end sub