Winform How to iterate in tree view nodes

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
i have treeview which has many nodes and nested nodes. how could i iterate in all the nodes in foreach loop ?

i was following this way

foreach (var node in Collect(tvCsmTuner.Nodes))

{

}

IEnumerable<TreeNode> Collect(TreeNodeCollection nodes)
{
foreach (TreeNode node in nodes)
{
yield return node;

foreach (var child in Collect(node.Nodes))
yield return child;
}
}



i do not want to use this Collect() function rather i want to use normal foreach to iterate in all the nodes ?

thanks

Continue reading...
 
Back
Top