You can subclass TreeNode, add properties, and override as needed.
Or you can assign a property to number tags when you build a tree. The algorithm will depend on how you build the tree (top to bottom and bottom to top, etc.).
More explicit information (code) will help formulate a more explicit answer.
update after OP comment:
Sorry, I do not remember; you need to override TreeView instead. Sort of
public class MyTreeView : System.Windows.Forms.TreeView
{
protected override void OnDrawNode(DrawTreeNodeEventArgs e)
{
if (e.Node.Tag != null)
{
if (e.Node.Tag.GetType() == typeof(MyDataObject))
{
MyDataObject data = (MyDataObject)e.Node.Tag;
e.Node.Name = data.Number + ". " + data.Name;
}
}
}
}
source
share