Selecting a Node in a TreeView

G

Guest

First of all, I want to thank JohnFol and Dan Artuso in my last question
about TreeView!!

I have a form, with a TreeView object to show the structure of my data. By
clicking in one node, I select the data and open it to be edited.

Example:

Position 1
Position 2
Position 3
Position 4

One of these fields is the ReportsTo field which, when it is changed, I
automatically change my structure (Combo_AfterUpdate event), it is working
fine. My problem is, if I change the Position 3 to Report to Position 4, (I
am deleting the node and adding it again in the new position), to became:

Position 1
Position 2
Position 4
Position 3

The treeview object keeps the position1 selected (the old parent) and not
the new position3 node.

My questions are:
1) How can select a specific node in a TreeView object ?
2) Where I can find an on-line help for the MS TreeView object? My help
doesn't have it and I cannot download anything to my computer (Company's
policy)

Thanks for any help

Mauricio Silva
 
R

Ron Weiner

To select a node program magically all you need to do is to first select it
then ensure it is visible. So if I wanted to select node 3 whose Key was
Position3 I'd :

tvwFiles.Nodes("Position3").Selected = True
tvwFiles.Nodes("Position3").EnsureVisible

If the node was a parent and I wanted to expand it (to show the children)
I'd:

tvwFiles.Nodes("Position3").Expanded = True
tvwFiles.Nodes("Position3").Selected = True
tvwFiles.Nodes("Position3").EnsureVisible

Ron W
 

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