Re: Unique identifier in every treenode?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Thu, 03 Jan 2008 11:40:34 -0800, Rob Stevens <robbstephens@xxxxxxxxxx> wrote:

Is there some sort of unique identifier in every treenode
that is consistent? I was looking at the handle of every
treenode, but it appears that the handle changes everytime
the tree is built.

I have seen in some databases where they store the treenodes
they are using some serial number of the node. I don't have
a clue what that is, but can someone tell me if there is something
that is unique to every node.

Not by default, no. It would be up to the client code (i.e. what you write) to impose any sort of unique identifier and store it with the TreeNode (you can either use the TreeNode.Tag property to store something, or subclass the TreeNode class and put whatever you want in that derived class).

You may or may not actually need to store a unique identifier. Even in a regular database you can use the database itself to specify relationships between records in the database representing nodes, something like XML provides a natural "containment" semantic that would allow the tree structure to be represented without explicit references between nodes, and even a plain text file can be used to reliably store a tree structure as long as you have _some_ way of describing the structure (for example, instead of specifying explicit relationships between nodes, simply storing a given node's depth within the tree along with making sure the nodes are stored and recovered in a specific order is sufficient...this was even a recent example in a previous thread in this newsgroup).

Pete
.



Relevant Pages

  • Re: Parsing and storing formulas
    ... you could easily store different views/stored ... >I was wondering how I can parse a mathematical formula in a storable way. ... > be stored for in the database. ... > The second idea is to represent the formula as a tree. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: TreeView bound to database
    ... the tree is not bound directly to the database. ... selected by the user on the treeview. ... >> contained in the table and not just typical TreeNode ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Tree design with generics
    ... You won't be able to do this for a general Tree unless you restrict ... public TreeNode(E element, TreeNode parent, int depth) ... // Check against the class type. ...
    (comp.lang.java.programmer)
  • How to delete the whole binary search tree?
    ... a list of customers records are read from a file. ... have to store them in a binary search tree. ...
    (comp.lang.java.help)
  • Re: Unique identifier in every treenode?
    ... And it's really confusing the way the tree is being stored to whatever ... Then in the "Load" method, it deserializes the stored data into an array of TreeNodes, representing the root nodes, and adds each root node to the tree. ... Since TreeNode implements ISerializable and assuming the code you posted works, it must include logic for serializing the entire structure under a given TreeNode. ...
    (microsoft.public.dotnet.languages.csharp)