Is it possible to search treeview nodes using text and expand node that matches search?

Hi

I have built a document management system that is interfaced into Access using treeview. It works fine but when I add files to the system I want to refresh the treeview and expand the node to which the files were added to display the added files.

Is it possible to search treeview nodes using text and expand node that matches search?
PhilIT ConsultantAsked:
Who is Participating?
 
John TsioumprisSoftware & Systems EngineerCommented:
You could use something like this
 For Each nodNode In tv.Nodes
                If nodNode.Text= YOURCriteria Then
                    nodNode.Expanded = True
                End If
            Next nodNode

Open in new window

0
 
Martin LissOlder than dirtCommented:
You probably should add Exit For after line 3 to save a very small bit of processing time.
0
 
Dale FyeCommented:
It is certainly possible, but I prefer to search the table that the tree is based upon to get the PK associated with whatever I'm searching for.

Then use the PK to construct the key that is used for that node and then select the node based upon the key.

HTH
Dale
0
 
PhilIT ConsultantAuthor Commented:
Great, this worked a treat.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.