Click to See Complete Forum and Search --> : Continue searching previous node?
Techno
Nov 12th, 2007, 10:16 AM
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?
jmcilhinney
Nov 12th, 2007, 04:59 PM
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.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.
karthikeyan
Mar 19th, 2008, 04:12 AM
dear jmcilhinney,
call FindNodes(Treeview1.nodes,"Server")
is this correct ?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.