473,563 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB6 TreeView Node "Key" property Equivalent in VB.NET

Hi There!

I'm using VB.NET to create a TreeView application and unfortunately I could
not find "Key" property in Node items of the TreeView.

We used to have "Key" property in TreeView node object in VB6.

What is the equivalent of "Key" property of TreeView node in VB.NET? Has the
property name "Key" has been changed to something else? Or VB.NET does not
support the "Key" property anymore? If so what are the alternatives?

What I need is I need to assign "Key" (which contains text and number) to
each node I add to the TreeView. So "Index" property won't help me. I need
something similar to "Key" property that is used to support in TreeView
Nodes of VB6.

Thanks all in advance!
Don
Nov 21 '05 #1
8 14257
* "Don Wash" <do*@wash.com > scripsit:
I'm using VB.NET to create a TreeView application and unfortunately I could
not find "Key" property in Node items of the TreeView.


There is no direct replacement for this property. You can set up a
'Hashtable' and store your (key, 'TreeNode') pairs for fast lookup by a
key there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
lol seems I'm not the only one with problems...
I'm looking into your solution as we speak.

André Nogueira

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ey******** ******@tk2msftn gp13.phx.gbl...
* "Don Wash" <do*@wash.com > scripsit:
I'm using VB.NET to create a TreeView application and unfortunately I
could
not find "Key" property in Node items of the TreeView.


There is no direct replacement for this property. You can set up a
'Hashtable' and store your (key, 'TreeNode') pairs for fast lookup by a
key there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Thanks, I've tried HashTable method but it doesn't seems to work.

Here's the code...

With objNewNode
htMain.Add(strN odeKey, .Index)
htMain_IndexToK ey.Add(.Index, strNodeKey)

.Text = "Node Item " & i
.ImageIndex = 1
End With

.Nodes.Add(objN ewNode)

htMain and htMain_IndexToK ey are HashTable objects. What happens is that
Index of objNewNode is always '0' (Zero).

So I though objNewNode is an independent TreeView Node which hasn't been
associated with the real TreeView control and I tried this code instead...

Dim intNodeIndex as Integer = .Nodes.Add(objN ewNode)

htMain.Add(strN odeKey, intNodeIndex )
htMain_IndexToK ey.Add(intNodeI ndex , strNodeKey)

and still intNodeIndex equal '0' every time. How can I get the actual Node's
index currently being added to the TreeView Nodes collection?

Thanks again!

Don

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ey******** ******@tk2msftn gp13.phx.gbl...
* "Don Wash" <do*@wash.com > scripsit:
I'm using VB.NET to create a TreeView application and unfortunately I could not find "Key" property in Node items of the TreeView.


There is no direct replacement for this property. You can set up a
'Hashtable' and store your (key, 'TreeNode') pairs for fast lookup by a
key there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Hi André,

How are you getting at? Did you get it to work?

Cheers,
Don

"André Nogueira" <an**@netcabo.p t.NOSPAM> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
lol seems I'm not the only one with problems...
I'm looking into your solution as we speak.

André Nogueira

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ey******** ******@tk2msftn gp13.phx.gbl...
* "Don Wash" <do*@wash.com > scripsit:
I'm using VB.NET to create a TreeView application and unfortunately I
could
not find "Key" property in Node items of the TreeView.


There is no direct replacement for this property. You can set up a
'Hashtable' and store your (key, 'TreeNode') pairs for fast lookup by a
key there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #5
anybody plz...

Don

"Don Wash" <do*@wash.com > wrote in message
news:uD******** ******@TK2MSFTN GP10.phx.gbl...
Hi There!

I'm using VB.NET to create a TreeView application and unfortunately I could not find "Key" property in Node items of the TreeView.

We used to have "Key" property in TreeView node object in VB6.

What is the equivalent of "Key" property of TreeView node in VB.NET? Has the property name "Key" has been changed to something else? Or VB.NET does not
support the "Key" property anymore? If so what are the alternatives?

What I need is I need to assign "Key" (which contains text and number) to
each node I add to the TreeView. So "Index" property won't help me. I need
something similar to "Key" property that is used to support in TreeView
Nodes of VB6.

Thanks all in advance!
Don

Nov 21 '05 #6
anybody plz...

Don

"Don Wash" <do*@wash.com > wrote in message
news:uD******** ******@TK2MSFTN GP10.phx.gbl...
Hi There!

I'm using VB.NET to create a TreeView application and unfortunately I could not find "Key" property in Node items of the TreeView.

We used to have "Key" property in TreeView node object in VB6.

What is the equivalent of "Key" property of TreeView node in VB.NET? Has the property name "Key" has been changed to something else? Or VB.NET does not
support the "Key" property anymore? If so what are the alternatives?

What I need is I need to assign "Key" (which contains text and number) to
each node I add to the TreeView. So "Index" property won't help me. I need
something similar to "Key" property that is used to support in TreeView
Nodes of VB6.

Thanks all in advance!
Don

Nov 21 '05 #7
Don,
Look carefully at how the TreeView Nodes are owned.

The TreeView itself only owns the root nodes, with indexes from 0 to however
many root nodes.

Each root node will own their children, their children will have indexes
from 0 to however many children each respective root has.

The grand children (of root) will have indexes from 0 to however many
children each parent (child of root) has respectively.

And so on.

In other words all the nodes in the following will have an index of 0,
except Grand Child 2 & Root 2 which will have indexes of 1.

Root 1 (index = 0)
Child 1 (index = 0)
Grand Child 1 (index = 0)
Great Grand Child 1 (index = 0)
Grand Child 2 (index = 1)
Great Grand Child 2 (index = 0)
Child 2 (index = 0)
Grand Child 3 (index = 0)
Great Grand Child 3 (index = 0)
Root 2 (index = 1)
Child 3 (index = 0)
Grand Child 4 (index = 0)
Great Grand Child 4 (index = 0)

If you need to index the nodes by both Key & Index, where Index is across
all nodes in the tree) I would recommend a
System.Collecti ons.Specialized .NameValueColle ction instead of a HashTable.
As the NameValueCollec tion supports indexing by both Key & Index.

Hope this helps
Jay

"Don Wash" <do*@wash.com > wrote in message
news:On******** *****@TK2MSFTNG P11.phx.gbl...
Thanks, I've tried HashTable method but it doesn't seems to work.

Here's the code...

With objNewNode
htMain.Add(strN odeKey, .Index)
htMain_IndexToK ey.Add(.Index, strNodeKey)

.Text = "Node Item " & i
.ImageIndex = 1
End With

.Nodes.Add(objN ewNode)

htMain and htMain_IndexToK ey are HashTable objects. What happens is that
Index of objNewNode is always '0' (Zero).

So I though objNewNode is an independent TreeView Node which hasn't been
associated with the real TreeView control and I tried this code instead...

Dim intNodeIndex as Integer = .Nodes.Add(objN ewNode)

htMain.Add(strN odeKey, intNodeIndex )
htMain_IndexToK ey.Add(intNodeI ndex , strNodeKey)

and still intNodeIndex equal '0' every time. How can I get the actual Node's index currently being added to the TreeView Nodes collection?

Thanks again!

Don

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ey******** ******@tk2msftn gp13.phx.gbl...
* "Don Wash" <do*@wash.com > scripsit:
I'm using VB.NET to create a TreeView application and unfortunately I could not find "Key" property in Node items of the TreeView.


There is no direct replacement for this property. You can set up a
'Hashtable' and store your (key, 'TreeNode') pairs for fast lookup by a
key there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #8

' set the key:
aTreeNode.Tag = aKey

' get the key:
aKey = CStr(aTreeNode. Tag)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #9

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

Similar topics

0
3123
by: jy2003 | last post by:
1. Does MyISAM support FOREIGN KEY constraints? When I read the online MySQL Reference Manual, it said "InnoDB also supports FOREIGN KEY constraints". Does it mean MyISAM does not support FOREIGN KEY constraints? It this is the case, what should I keep in mind when I design MyISAM tables? 2. I have seen the following CREATE statement...
2
2344
by: minjingshu | last post by:
Bob orderA 13 orderB 11 i want to know how to save 13 as node key of orderA thx
14
3619
by: Daniel Bass | last post by:
is there an equivalent key word for C++'s "continue" in VB (.net) in this context? CString szLine; szLine = myReader.ReadLine(); while ( !szLine.IsEmpty() ) { if ( szLine(0) == '-' ) {
1
1654
by: Richard Markus | last post by:
I used to make good use of the KEY property on the NODE object in a TreeView control in VB 6.0. In VB.NET, I do not find the KEY property for NODES. How do I get the same functionality? More: I could maintain a separate array of node index/key name that I could write a function to convert a key string to an existing index, but I was...
8
9459
by: Nick | last post by:
I have a table with columns (product_id,related_product_id,related_counter) If product A is related to product B then a record should be created, if the record already exists then the related_counter should be incremented. This is very easy to do with MySQL using INSERT... ON DUPLICATE KEY. Standard or not, it is very usefull.
3
2587
by: Charles Law | last post by:
This is driving me mad. Can someone please put me out of my misery? I have a DataSet which I wish to use as the data source for a grid control (it is actually an Infragistics grid). When I assign to the DataSource property like this UltraGrid1.DataSource = MyDataSet I get the following exception:
3
10257
by: Adhal | last post by:
This is probably a dumb question. But how do you get the key from a treeview node object? thanks -- Adhal Freeware http://www.adhal.org
1
2664
by: ramprakashjava | last post by:
hi , i hav this error while running this customerDetails.jsp <html:html> <head> <html:base/> </head> <body> <html:errors/> <html:form action="/submitCustomerForm"> <bean:message key="prompt.customer.firstname"/>
0
7658
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...
0
7877
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. ...
1
7631
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...
0
7943
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...
0
5204
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2077
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.