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.
+1
A:
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);
}
popester
2009-10-22 06:45:59