Treeview Search

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I'm trying to do a text search on a TreeView control. So far I've been able
to find the matching items and add them to another treeView but I want to be
able to add its whole path to the other treeView and not just the matching
node.
Any ideas on how to do this?
 
You will need to implement a simple recursive routine:

TreeViewWalk(treeView.Nodes);




private void TreeViewWalk(TreeNodeCollection nodes)
{
foreach (TreeNode node in nodes)
{
// do what you want to do with 'node' here.

if (node.ChildNodes.Count > 0)
{
TreeViewWalk(node.ChildNodes, list);
}
}
}
 
Back
Top