Treeview, repost of several previously unanswered questions

G

Guest

Must not be a lot of people using treeview, cause getting an answer is
extremely difficult.

1. I would like to be able to "select" a node directly by referencing its
key value, not its index, something like:

tvx.nodes("a12345").selected = true

Instead, I have to pass a value to a subroutine that loops through all of
the nodes and tests to determine whether the Key = the value passed, and if
it is, select it.

2. Once I have done this, I would like the "selected" node to be visible in
the treeview window. How do I manipulate the window so that the selected
item is visible in the window (and not hidden above or below the window).

3. Lastly, I want to be able to click on a command button and expand the
selected node and all of its progeny (children, grand-children, ...). I know
I can go back to my recordset, query it for the selected node, then search
for the node with the key value and expand it, then continue through the
recordset, but there has to be an easier way.

Thanks for any help
 
G

Graham Mandeno

Hi Dale

Try this for 1:
tvx.SelectedItem = tvx.Nodes("a12345")

For 2:
tvx.SelectedItem.EnsureVisible

And for 3:

ExpandNode tvx.SelectedItem

Public Function ExpandNode(nParent As Node)
Dim nChild As Node
With nParent
.Expanded = True
If .Children > 0 Then
Set nChild = .Child
Do
ExpandNode nChild
Set nChild = nChild.Next
Loop Until nChild Is Nothing
End If
End With
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top