Treeview 选中和取消选中 [英] Treeview Check and Uncheck
本文介绍了Treeview 选中和取消选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Private Function Check(ByVal mytreeNode As TreeNodeCollection) As Boolean
For Each node As TreeNode In mytreeNode
If node.ChildNodes.Count > 0 Then
If node.Checked = True Then
For Each chknode As TreeNode In node.ChildNodes
chknode.Checked = True
Next
End If
Check(node.ChildNodes)
Next
End Function
使用这个函数我可以在检查父节点时检查子节点.我想做相反的事情.一旦我取消选中父子节点也会取消选中.可以使用相同的功能.?
Using this function i can check child node when checking parent.I want to do opposite.Once i uncheck parent child also gets uncheck.It is possible using this same function.?
推荐答案
你的意思是把它改成使用传入的参数.类似
Do you mean to change it to using a param passed in. Something like
Private Function Check(ByVal mytreeNode As TreeNodeCollection, checked as Boolean) As Boolean
For Each node As TreeNode In mytreeNode
If node.ChildNodes.Count > 0 Then
If node.Checked = checked Then
For Each chknode As TreeNode In node.ChildNodes
chknode.Checked = checked
Next
End If
Check(node.ChildNodes, checked)
Next
End Function
这篇关于Treeview 选中和取消选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文