树状节点检查 [英] treeview checked nodes
本文介绍了树状节点检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用了TreeView控件在我的C#Windows应用程序。在那我有几个父节点有子节点。我已经为所有设置ShowCheckboxes属性。因此,如果父节点或子节点的ckeck复选框被选中
我怎样才能得到否定的。托运nodes.In foreach循环,我应该用什么代码?
请帮帮我。
I have used the treeview control in my C# windows application. In that i have a few parent nodes and there child nodes. i have set the ShowCheckboxes properties as ALL. So if the ckeck box of a parent node or child node is checked how can i get the no. of checked nodes.In the foreach loop what code should i use? Please help me.
推荐答案
使用递归。下面是一些伪代码:
Use recursion. Here's some psuedo code:
int GetCount(Node n)
{
int ret = 0;
foreach (Node child in n.Nodes)
{
ret += GetCount(child);
}
return ret + (n.IsChecked() ? 1 : 0);
}
这篇关于树状节点检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文