meena moon

meena moon

  • NA
  • 39
  • 8.9k

search in treeview

Dec 3 2015 10:49 AM
Hi how can search on node in treeview by his text without Recursive
 
private void FindByText()
{
TreeNodeCollection nodes = treeView1.Nodes;
foreach (TreeNode n in nodes)
{
FindRecursive(n);
}
}
private void FindRecursive(TreeNode treeNode)
{
foreach (TreeNode tn in treeNode.Nodes)
{
// if the text properties match, color the item
if (tn.Text == this.txtNodeTextSearch.Text)
tn.BackColor = Color.Yellow;
FindRecursive(tn);
}
}
 

Answers (1)