Skip navigation

VB.NET: Tree Nodes Don't have Key property !!

When developing an application in VB.NET I was very disappointed to know that there is no Key property provided for the TreeNode objects.

Well, at least I can't work without Key property, as I always keep the IDs of my items in the Key property only.

So, finally i used the following custom Node class for my purpose.

To access the nodes, we just have to typecast the selected node of the tree to our custom class.

You can add any property you require in the same class for extensibility.

ndCurrentNode = CType(tvwStructure.SelectedNode, clsCustomTreeNode)

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.