Results 1 to 5 of 5

Thread: Treeview Key not unique - any way to trap this?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Treeview Key not unique - any way to trap this?

    Is there any way to trap if a key is not unique in a Treeview without an error? Do i have to go through all of them searching? What is you have a ton in a program such as an MP3 organizer?

    Thanks!

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Treeview Key not unique - any way to trap this?

    Quote Originally Posted by WarrenW
    Is there any way to trap if a key is not unique in a Treeview without an error? Do i have to go through all of them searching? What is you have a ton in a program such as an MP3 organizer?

    Thanks!
    You can't have a duplicate key in a treeview, it will throw an error when you are loading it. You will need to trap for the error when loading it and handle the error.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Re: Treeview Key not unique - any way to trap this?

    Thanks. Is there any way to trap for this specific error? Or just use the On Error line?

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Treeview Key not unique - any way to trap this?

    If you don't have too many nodes in the treeview then you may loop through each and check whether or not key already exist or as suggested create an Error Handler using On Error GoTo Whatever and trap that error number.
    Also, you don't necessary have to assign the key at all - you may simply use node.Tag property to store some unique id or whatever text you may need to store.

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Treeview Key not unique - any way to trap this?

    If you'd like a method for always assuring that the keys are unique to begin with then take a look at the Generate unique TreeView keys link in my signature.

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