开发者

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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜