Programatically Select a TreeView Node

M

Michael_Burgess

Hi there,

I've looked around the different groups and still can't figure this
out without resorting to scrappy code............

I want to programtically select and highlight a TreeView node, such
that it looks the same as if a user has clicked it.

I'm aware about the SelectedNode property, but this just seems to
expand the TreeView to show the node in question, but not highlight
it.

I'm aware that I could change the back and fore colour, but this seems
like trying to workaround something that I'd assume to be simple?

Is there an easy way for me to do what I'm after and still have the
TreeView in a normal state, such that if I then go and click a
different node after, that one is highlighted like usual and the
previously programmatically selected node is no longer highlighted /
selected?

Thanks in advance,
Mike.
 
J

jibesh

Try setting focus back to your tree control using

control.SetFocus() method . Hope this will high light your selected item

- Jibesh.V.P
 
T

Tom Dacon

Setting the control's HideSelection property to False will cause the
selected node (after you've set the SelectedNode property of the Treeview)
to show selected even when the control doesn't have the focus. It will have
the characteristic grey background to show that it's selected but not
focused.

HTH,
Tom Dacon
Dacon Software Consulting
 

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