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!
Printable View
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.Quote:
Originally Posted by WarrenW
Thanks. Is there any way to trap for this specific error? Or just use the On Error line?
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.
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.