View Full Version : Tree view control in VC++ .NET
scorpionguy
05-23-2006, 02:23 PM
I have included a treeview in my windows form in VC++.NET project. I have nearly 10,000 nodes in the tree. I wanted to know whether it is possible to control some of the nodes in this. To be more clear.. I have a button and when i press the button (for example) I want some of the nodes to change its forecolor or something like that. Is this possible?? Please help me ...I m in real trouble and need to solve this problem.
Thanks a lot
Reedbeta
05-23-2006, 02:48 PM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/custcntrlsamp3.asp
http://msdn2.microsoft.com/en-us/library/sc9ba94b.aspx
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtsksubclassinglistitemortreenode.asp
http://msdn2.microsoft.com/en-us/library/haf2a2zb.aspx
The MSDN is your friend ;)
scorpionguy
05-23-2006, 03:55 PM
Can anybody tell how to access a particular node in the tree(not the node clicked by the user).particular node here means referring a node by name
Wernaeh
05-23-2006, 05:54 PM
The problem with that is that your node names are not unique, so there may be more than one node with the same name.
Your best bet is to manually walk through each and every node inside the treeview, retrieving the associated node item data, and manually comparing the node string and the desired text.
Cheers,
- Wernaeh
alexndr
05-23-2006, 10:16 PM
scorpionguy, if you sure that names of all nodes in TreeView are unique, then you can iterate through all nodes of the TreeView recursive and find node by name; or better to use node path, in case if parent node and its child has same name.
Reedbeta
05-24-2006, 12:28 AM
If your node has a lot of elements in it (say, more than a few dozen), this linear search strategy will be inefficient...in that case, you could keep an std::map (or whatever the equivalent class is in .NET) with names as the keys and references to TreeView nodes as the values. Then you would get logarithmic-time lookup.
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.