Results 1 to 8 of 8

Thread: treeview node values [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539

    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

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    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

  3. #3
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    That's exactly what I do - use the tag property.

  4. #4

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539
    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

  5. #5

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539
    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

  6. #6
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    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...

  7. #7

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539
    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

  8. #8
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    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
  •  



Click Here to Expand Forum to Full Width