user object with TreeNode in C#

user34537 picture user34537 · Mar 12, 2009 · Viewed 10.1k times · Source

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

Answer

JaredPar picture JaredPar · Mar 12, 2009

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;