Unique key for tree nodes

Posted on 2008-11-04
Last Modified: 2013-11-15
I use an infragistics tree control and each node requires a unique key.  If a key is not provided it uses the node text which rapidly causes and exception.  What is the best way to create a key the will always be unique?
Question by:Moed
    LVL 11

    Accepted Solution

    Why not just sequence them in the order that they are added to the tree? That is, you could just declare:
    Dim currentNodeID as Integer
    NodeID +=1
    Of course, that strategy may not work if you need to reference a node by ID without knowing the chronology of the adds. If that is likely, you may need to designate your own numbering scheme (much like a document outline.... roman numerals, with decimal children, which have alphabetic sub-children, and so forth).
    LVL 11

    Expert Comment

    Oops.. that would be
    currentNodeID +=1

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now