How to assign a numbering scheme to TreeNodes based on position
Posted
by TChristian
on Stack Overflow
See other posts from Stack Overflow
or by TChristian
Published on 2010-06-14T22:16:31Z
Indexed on
2010/06/14
22:22 UTC
Read the original article
Hit count: 164
I have a TreeView control in a Windows Forms application that is displaying my own subclass of TreeNode. I need to display a number along with each node's text indicating its position in the tree, like 1 for the root, 1.1 for its first child, 1.2 for its second child, etc. I'm using C# with .NET 2.0
The best that I can come up with is, after the tree is built, go to each node, recursively find the parent and append the parent's sibling number to the front of the node's text until you reach the root.
© Stack Overflow or respective owner