473,387 Members | 1,318 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 21825
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: someone | last post by:
Here is my code: TreeNodeCollection nodes = tvwFolders.Nodes; if (nodes.Count > 0) { // Select the root node tvwFolders.SelectedNode = nodes; } I hope there is an easier way. I looked at...
4
by: G Uljee | last post by:
How can I find and select an specific item in an treeview control? I want to create a search feature on my treeview. Thanks in advance, Gaby
2
by: Wes | last post by:
I have a treeview that I am continually added nodes to. Each time a new node is added I would like to select that node. Is this possible? I have looked at selectedNode, but I don't know how to...
2
by: Stephen | last post by:
In asp.net 1.1, the IE treeview web control has a property called "SelectExpands" that, when set to true, expands a node when a user clicks the node text. I can't seem to replicate this in the...
13
by: André Nogueira | last post by:
Hi there. I know you can view a node's fullpath property, but is it posible to select a node using its path? Like, tell the treeview that the node that should be selected is the node with the...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
4
by: praveen | last post by:
I have a form with treeview control loaded from xml document,text box, two buttons named "Find" and "FindNext" and my treeview which looks like below. Details |__ policy status |__ created by...
4
by: KarlM | last post by:
Hallo! I'm filling my treenode tv with AD-infos with the following code: ____________________________________________________________________ private enum AdImages { AdRoot, Ou, Container,...
4
by: jmDesktop | last post by:
I have searched everywhere and tried several things. I have a treeview with and want to be able to only select a parent node. For example: root //don't want to drag this -parent1 //yes, drag...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.