开发者

treeview checked nodes

开发者 https://www.devze.com 2022-12-08 22:57 出处:网络
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.

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

精彩评论

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