treeview checked nodes
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? Plea开发者_运维知识库se 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);
}
精彩评论