Treeview control- expanding

wojtasik6

Registered User.
Local time
Today, 05:19
Joined
Apr 18, 2014
Messages
23
Hi!
I'd like to expand me tree view automatically when a node matches a string variable from a table. In other words, when a node in a tree matches the given name (variable), the tree will expand all the way down to that name. I guess I need to use "For each node" and when the node and variable match, the tree structure will show up. Any help?

EDIT:
I have come up with something like this:
Code:
 For Each nd In Me.tree.Nodes
If nd = level1 Then
nd.Child.EnsureVisible
Exit For
End If
Next nd
Me.tree.SetFocus

But this only shows the first level of my tree ( btw. I have a 3 level tree). I get lost inside the FOR when I want to make use of another two variables - level2 and level 3
 
Last edited:
If I remember correctly a node or child has Children (which is also a collection). So if you use the Children property of each node you will get to the node you want.

Otherwise, use Recursion to traverse the tree.
 

Users who are viewing this thread

Back
Top Bottom