Link to home
Start Free TrialLog in
Avatar of fmichail
fmichailFlag for Canada

asked on

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
Avatar of Slow_mo
Slow_mo

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)
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()
ASKER CERTIFIED SOLUTION
Avatar of Slow_mo
Slow_mo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fmichail

ASKER

Thank you slow mo