Spafa9
Spafa9

Reputation: 762

Treeview How to save a value

How do I save off a value on treenode? I am using C# Windows forms framework 4.0. Is the Tag the only place to save off a value? I need to save off the window name in order to open the window when the user clicks on it.

Upvotes: 0

Views: 322

Answers (1)

Asif Mushtaq
Asif Mushtaq

Reputation: 13150

If you need more than one value to store in the tree node then the best way is to extend TreeNode by inherent your class from it, and use your own tree node.

public class YourTreeNode : TreeNode
{
    public string WindowName { get; set; }
}

Or just the tag and store the windowname in the name.

Upvotes: 3

Related Questions