473,663 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treeview and keys. Please help; I've been frustrated on this one for a long time

There has been a lot of discussion lately about extending the treeview control to allow finding a node by key rather than by index. Everyone seems to agree that a hashtable is needed to accomplish this. Also, there is a KB article (http://support.microsoft.com/default...b;en-us;311318) purporting to show you how to extend the treenode to include a key. This article seems to be nearly useless to me, as (despite adding a DictionaryEntry type property to the treenode) it ends up using a looping function in the extended treeview's CLIENT code to find the node.

Again, it seems everyone agrees that a hashtable is needed. But I don't understand how to do it. I would THINK that I need to override the TreeNodeCollect ion's Add method to not only add the node to the collection, but also add a (key, index) pair to a hashtable-type property. But I can't seem to do this because replacing a treeview's TreeNodeCollect ion with an extended TreeNodeCollect ion requires inheriting the TreeNodeCollect ion and then calling its New(Owner as TreeNode) sub, which is private.

Is there something I'm missing here? Since I've clearly been unable to understand how to implement the solution that appears to be clear to others, please include an explicit example.

Thanks a lot.

Pat
Nov 20 '05 #1
2 2589
I think the easiest way for you would be to add methods like
AddNode/RemoveNode/LookupNode to treeview and replace standard calls
treeview.Nodes. Add/Remove/RemoveAt n your code with new ones. New methods
will update / search your hashtable in addition to Nodes updates. Not 100%
foolproof, but should alleviate your woes when implemented carefully.
I don't see now the way how to extend TreeNodeCollect ion for standard
TreeView. Maybe somebody else knows?

HTH
Alex

"pmcguire67 " <an*******@disc ussions.microso ft.com> wrote in message
news:C0******** *************** ***********@mic rosoft.com...
There has been a lot of discussion lately about extending the treeview control to allow finding a node by key rather than by index. Everyone seems
to agree that a hashtable is needed to accomplish this. Also, there is a KB
article (http://support.microsoft.com/default...b;en-us;311318)
purporting to show you how to extend the treenode to include a key. This
article seems to be nearly useless to me, as (despite adding a
DictionaryEntry type property to the treenode) it ends up using a looping
function in the extended treeview's CLIENT code to find the node.
Again, it seems everyone agrees that a hashtable is needed. But I don't understand how to do it. I would THINK that I need to override the
TreeNodeCollect ion's Add method to not only add the node to the collection,
but also add a (key, index) pair to a hashtable-type property. But I can't
seem to do this because replacing a treeview's TreeNodeCollect ion with an
extended TreeNodeCollect ion requires inheriting the TreeNodeCollect ion and
then calling its New(Owner as TreeNode) sub, which is private.
Is there something I'm missing here? Since I've clearly been unable to understand how to implement the solution that appears to be clear to others,
please include an explicit example.
Thanks a lot.

Pat

Nov 20 '05 #2
Basically, what you are missing I think is that in general I and perhaps
others don't bother deriving from TreeNodeCollect ion. Its rather more
complex and convoluted than what you need.

Instead, what I do is place a tree view "dock filled" on a form, then in the
code section I add a hashtable, followed by "Add", "Remove", "GetNode"
methods to the form. Any clients of the tree have to execute methods
through the form object, not actually on the treeview itself (although I
guess you could expose the TreeView control itself from the form).

"pmcguire67 " <an*******@disc ussions.microso ft.com> wrote in message
news:C0******** *************** ***********@mic rosoft.com...
There has been a lot of discussion lately about extending the treeview control to allow finding a node by key rather than by index. Everyone seems
to agree that a hashtable is needed to accomplish this. Also, there is a KB
article (http://support.microsoft.com/default...b;en-us;311318)
purporting to show you how to extend the treenode to include a key. This
article seems to be nearly useless to me, as (despite adding a
DictionaryEntry type property to the treenode) it ends up using a looping
function in the extended treeview's CLIENT code to find the node.
Again, it seems everyone agrees that a hashtable is needed. But I don't understand how to do it. I would THINK that I need to override the
TreeNodeCollect ion's Add method to not only add the node to the collection,
but also add a (key, index) pair to a hashtable-type property. But I can't
seem to do this because replacing a treeview's TreeNodeCollect ion with an
extended TreeNodeCollect ion requires inheriting the TreeNodeCollect ion and
then calling its New(Owner as TreeNode) sub, which is private.
Is there something I'm missing here? Since I've clearly been unable to understand how to implement the solution that appears to be clear to others,
please include an explicit example.
Thanks a lot.

Pat

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1808
by: Mike Preston | last post by:
Warning - long message. Many thanks for making the A97 version of the treeview w/o activex controls available. I have taken it down a different path and ended up doing almost everything differently. It now has, built in, the ability to have 12 levels, not just 3. The tree's recordsource table (TreeviewRS) is built based on information
0
1318
by: meh | last post by:
I have a treeView that I'm trapping key strokes like below. It works fine as long as I dont define shortcut keys in the Context Menu assigned to the treeView for those keys. Can someone tell me what I'm doing wrong? private void treeView1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (treeView1.SelectedNode != null)
8
4400
by: Hrvoje Voda | last post by:
What is wrong in this code? private void tree_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter ) {
5
1150
by: Mike G. | last post by:
With the VB6 TreeView, you could identify a node with a key for quick access to it. In .NET there is no "keys" property. Can someone tell me the equivilent of the keys property? Thanks, -Mike
12
587
by: Bob Hollness | last post by:
Hi. I have a text file containing a list of files and their path. I.e. c:\MyDocs\File1.txt c:\MyDocs\File2.txt c:\MyDocs\File3.txt c:\MyDocs\File4.txt C:\MyDocs\Folder\File1.txt
8
4634
by: Shawn B. | last post by:
Greetings, I'm creating a little program that acts as a glorified Registry explorer. The TreeView doesn't allow you to show a plus sign unless a node has child nodes, so I need to determine whether a registry key has subkeys and add a dummy childnode. The way I'm doing this is to populate the child nodes as the parent is expanded. However, there are some serious performance implications. First, when I pouplate the HKEY_CLASSES_ROOT,...
16
1835
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. I'm looking for a way to programmatically retrieve the following if possible: Windows Installation Key or COA from the registry Windows installed applications, like: MS Office 97-2003 MS FrontPage MS Word MS Works
3
2496
by: rolf.oltmans | last post by:
Hello, I need to populate a TreeView control from SortedList(Winforms application). I've stored ID's as key and Nodes as value. A typical TreeView in my case would like like 1 Goal 1.1 Task1 1.2Task2 1.2.1 Goal1
5
7513
by: Max2006 | last post by:
Hi, I have a TreeView and this is my node style: <asp:TreeNodeStyle ForeColor = "#000000" Font-Size="9px" Font-Bold="false" Width="100px" NodeSpacing="3px" /> The problem is the expand button (+) resides right at the middle of multi-line text. Can I make the expand button top align instead of middle align?
0
8435
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8857
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.