[VB 2008] Select a TreeView Node

V

vino

Hello

I have created a TreeView and i wish to select a node into it
and then expand the selected node.

Is someone has an idea ?

Thanks
 
M

Mattias Sjögren

I have created a TreeView and i wish to select a node into it
and then expand the selected node.

Is someone has an idea ?

Assuming you mean a WinForms TreeView control:

yourTreeView.SelectedNode = ...
yourTreeView.SelectedNode.Expand()


Mattias
 
V

vino

Hi Mattias and thank you for your answer.

But the SelectedNode doesn't select the Node like a user click on it (with a
blue bgcolor)
Is there a solution to do it automatically without setting its BackColor
property to Blue ?
 
K

Kadaitcha Man

vino, ye decaying cozening slave, thou bawd, thou broker, thou all
changing word, ye pealed:
Hi Mattias and thank you for your answer.

But the SelectedNode doesn't select the Node like a user click on it (with
a
blue bgcolor)
Is there a solution to do it automatically without setting its BackColor
property to Blue ?


If you have code in the AfterSelect event handler that you want to execute
when you select a node via code then move all the code out of the
AfterSelect handler into another routine. Call the routine from the
AfterSelect handler and call it when you set the SelectedNode in code.
 
H

Herfried K. Wagner [MVP]

vino said:
But the SelectedNode doesn't select the Node like a user click on it (with
a
blue bgcolor)
Is there a solution to do it automatically without setting its BackColor
property to Blue ?

\\\
Me.TreeView1.SelectedNode = ...
Me.TreeView1.Focus()
///

Take a look at the 'HideSelection' property too.
 

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