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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top