Link to home
Start Free TrialLog in
Avatar of MVas
MVas

asked on

Treeview select/selected property

Hi Experts,

I am using vb.net 2005 framework2, there is a treeview in my program, what I would like to do is
click on a button and then a specific node is selected, click on a different button and a different node is selected.
I did some searching on ee but found questions relating to the selected property of the treeview which
i cannot find, i did find a select property but it doesnt allow to select nodes,

any help
would be appreciated.
thank you.
Avatar of maidinhtai
maidinhtai

TreeView1.SelectedNode = x 'with x is the node that you want to select
Avatar of MVas

ASKER

hi maidinhtai

I tried the code you posted as follows:

treeview1.SelectedNode = 0 'It threw the following error
Value of type 'Integer' cannot be converted to 'System.Windows.Forms.TreeNode'.

I then tried

Dim mynode As New System.Windows.Forms.TreeNode

mynode.Index = 0
treeview1.SelectedNode = mynode

this won't build because property "Index" is read-only

can you help me finding what "x" needs to be in your example.
ASKER CERTIFIED SOLUTION
Avatar of maidinhtai
maidinhtai

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 MVas

ASKER

I tried your examlpe above and it works like a charm,
thank you maidinhtai