471,573 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,573 software developers and data experts.

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 21690
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 XIAOLAOHU | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.