|
-
Nov 12th, 2007, 11:16 AM
#1
Thread Starter
PowerPoster
Continue searching previous node?
in a treeview, when I have searched all the current node's child nodes and when it finds an item it needs to find in the childnodes, how can i continue searching going back up one level and just carrying on?
-
Nov 12th, 2007, 05:59 PM
#2
Re: Continue searching previous node?
If you're searching using recursion then you don't have to do anything because you will continue with the next node inherently, e.g.
CSharp Code:
private void FindNodes(TreeNodeCollection nodes, string text)
{
foreach (TreeNode node in nodes)
{
if (node.Text == text)
{
MessageBox.Show(node.FullPath, "Match Found");
this.FindNodes(node.Nodes, text);
}
}
}
Just call that method and pass the Nodes property of your TreeView to the first argument and it will recursively search the entire tree, popping up a message each time it encounters a node whose Text matches the specified value.
Last edited by jmcilhinney; Nov 12th, 2007 at 06:05 PM.
-
Mar 19th, 2008, 04:12 AM
#3
Fanatic Member
Re: Continue searching previous node?
dear jmcilhinney,
call FindNodes(Treeview1.nodes,"Server")
is this correct ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|