How to select a node in the tree control programatically in vb.net

I have a populated tree control, and I want programatically to set focus (with highlight) to a specific node, that could be in the visible area or not (including moving to the top or bottom. How to do that programatically in vb.net
Thanks in advance
fmichailAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Slow_moCommented:
Me.TreeView1.SelectedNode = Me.TreeView1.Nodes(1)

This will select the second root node

To select the first child node of a second root node use this:

Me.TreeView1.SelectedNode = Me.TreeView1.Nodes(1).Nodes(0)
0
icrCommented:
Bear in mind that the treeview may not be focussed (depending on when you are selecting the node). If you want to subsiquently focus it you can use Me.TreeView1.Focus()
0
Slow_moCommented:
Additionaly you can set a HideSelection property to false to be able to see selected node even if TreeView is not focused.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fmichailAuthor Commented:
Thank you slow mo
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.