Hi I need to know if there is a way to move from the parent node in a treeview to a child node. If anyone has a code example, that would help immensely.
If you need to programatically identify a node to which you want to move to, which could be anywhere in the tree, you will need a recursive function to 'find' it. See the following thread:
I do have one more question. This worked great to find the first occurance of a node. The problem I am having now is, I would like to find the next occurance of string contained in the node.
For example, I have 5 nodes that contain the string "HL". The whole node might like something like this: "HL*1*21" and another might look like "HL*3*19". I have just found the 1st one, now I want to find the next one. With the current process, I keep finding the first one and it never moves to the next. Do you know how I might go about doing that?
In my own programs I usually store a unique reference in the tag property of each node (e.g. a description and a unique ID, usually pulled from a database identity column, such as File_1034). This then allows me to use the FindNode function to search for the unique tag value.
If you are looking for the text and it always starts with 'HL', you could use the Split function to return the values:
If TreeNode.Text.StartsWith("HL" Then
Dim s() As String
s = TreeNode.Text.Split(Convert.ToChar("*")
End If
That is good, but sometimes the text is in the middle or elseware. One thing I have decided to do is store the item i found in a hashtable. that way, I can simply check to see if that node has been found previously and then just move on to the next. Then i clear the hashtable when the search criteria is changed or the application is closed.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.