473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to search a TreeNode?

Looking for an efficient way to get a TreeNode out of my rootTreeNode -- for
example I know the FullPath -- is there a quick way to locate the node
matching my FullPath?

Rob.
Dec 16 '05 #1
1 1110
public TreeNode GetNodeByPath(TreeNode rootNode, string strFullPath)
{
if(rootNode==null)
return null;
TreeNode hotNode = rootNode;
string[] nodes = strFullPath.Split('\\');
for(int i=1; i<nodes.Length; i++)
{
TreeNode node0 = null;
foreach(TreeNode node in hotNode.Nodes)
{
if(node.Text == nodes[i])
{
node0 = node;
break;
}
}
if(node0 == null)
break;
hotNode = node0;
}
return hotNode;
}

Rob R. Ainscough wrote:
Looking for an efficient way to get a TreeNode out of my rootTreeNode -- for
example I know the FullPath -- is there a quick way to locate the node
matching my FullPath?

Rob.


Jan 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Henry Jordon | last post by:
I have everything pretty much done but I need to fix something in my coding. I want to be able to enter strings such as "love", "hate", "the", etc. but am unable to figure how to do this. I have...
4
by: G Uljee | last post by:
How can I find and select an specific item in an treeview control? I want to create a search feature on my treeview. Thanks in advance, Gaby
0
by: Dianna | last post by:
Hi, I am doing a recursive search of my treeview. All I am doing is iterating through the nodes and checking if my tag = my id. It seems to works, finds the ID, selects it and exits. However,...
4
by: Alan T | last post by:
I want to search the whole tree of a root node if one node has a tag value is matched. I have added tree nodes into a tree view with tag value is assigned to each node. If I want to find out...
4
by: BenCoo | last post by:
Hello, In a Binary Search Tree I get the error : Object must be of type String if I run the form only with the "Dim bstLidnummer As New BinarySearchTree" it works fine. Thanks for any...
36
Ganon11
by: Ganon11 | last post by:
OK, first of all, thanks to everyone who helped me out with my Isomorphism problem - it finally works. Now, the other part of my homework I'm having trouble with is this: I don't want to post...
1
by: jmDesktop | last post by:
I am trying to add nodes with keys to my treeview. I can add general nodes without problem with: //create new node TreeNode newNode = new TreeNode(myIdNumber); //create children TreeNode...
1
by: AAaron123 | last post by:
If you see this posted twice - sorry. My news reader showed my first post as "No Longer Available" I have the following in a .css file. The treeNodes behave as if they were "a" elements. ...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.