469,275 Members | 1,802 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Programatically Select a TreeView Node

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.

Feb 10 '07 #1
3 21556
Try setting focus back to your tree control using

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

- Jibesh.V.P

"Michael_Burgess" <mi**@marsh-hall-studios.co.ukwrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
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.

Feb 10 '07 #2
Yes thanks - was just about to reply saying giving the control focus
seemed to work. Thanks.

http://groups.google.co.uk/group/Dot...a9443d6cfab78f

Feb 10 '07 #3
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

"Michael_Burgess" <mi**@marsh-hall-studios.co.ukwrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
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.

Feb 10 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by someone | last post: by
4 posts views Thread by G Uljee | last post: by
2 posts views Thread by Stephen | last post: by
13 posts views Thread by André Nogueira | last post: by
4 posts views Thread by KarlM | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.