|
-
Jul 4th, 2004, 10:31 AM
#1
Thread Starter
Fanatic Member
treeview node values [RESOLVED]
Hey All
Can the treeview control display a friendly name to the user and store a id as a value. ?
I mean i have list of customers to user i want to display the customers name and to the application when a user selects a customer i wish to pass the customers id to what ever code ive wrote ?
Last edited by carlblanchard; Jul 15th, 2004 at 04:54 PM.
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Jul 5th, 2004, 09:13 AM
#2
Fanatic Member
Unless I'm mistaken (but I don't believe so) Microsoft removed our beloved "Key" property. But for what you are wanting, I think you could use the "Tag" property off the node object.
When the user clicks a node, just pass the Tag property along.
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Jul 5th, 2004, 09:42 AM
#3
Fanatic Member
That's exactly what I do - use the tag property.
-
Jul 15th, 2004, 03:24 PM
#4
Thread Starter
Fanatic Member
have you got any good clean code examples of this ?
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Jul 15th, 2004, 03:41 PM
#5
Thread Starter
Fanatic Member
Ive got a private variable to the form
Private CustomerNode As New TreeNode
and in my onload event i have
CustomerNode.Text = strTitle
CustomerNode.Tag = currentRow("customerid")
TreeView1.Nodes.Add(CustomerNode)
this is contained within a loop of a dataset
For Each currentRow In mCustomerDs.Tables(0).Rows
next
In my data i will have customers with the same name but im getting this error
can not add or insert the item "MY CUSOTMERS NAME" in more than one place. you must first remove it from its current location or clone it; Parameter name Node ????
any ideas
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Jul 16th, 2004, 01:08 AM
#6
Hi.
You just need to set the variable to a new instance of a treenode before adding it.
CustomerNode=New TreeNode
CustomerNode.Text = strTitle
CustomerNode.Tag = currentRow("customerid")
TreeView1.Nodes.Add(CustomerNode)
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Jul 16th, 2004, 01:13 AM
#7
Thread Starter
Fanatic Member
nice one pax i managed to work that out last night
however i seem to be getting duplicate entries for each node
it gets to the 3 or 4th one in the tree and then starts duplicating
im using the clear method but dosnt seem to do much
its as soon as the first db entry is null it does it
any ideas
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Jul 16th, 2004, 01:24 AM
#8
hmmm...not to sure. Never actually tried that before but it sounds like there might be some thing going on with the loop it self.
I assume there's a While...End While or something of that nature.
Could it be that it skips a MoveNext for the recordset/dataset thus adding the same node twice?
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|