How to assign a numbering scheme to TreeNodes based on position
- by TChristian
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.