Search code examples
c#treenodeuser-object

user object with TreeNode in C#


Can i tie a user object to a TreeNode in C#?


Solution

  • Yes. You can use the Tag property to store any user object for a particular tree node.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.treenode.tag.aspx

    TreeNode node = CreateATreeNode();
    node.Tag = myStateObject;