9.2. Link Data to a Control
Problem
You need to link an object to a specific control (perhaps to store some arbitrary information that relates to a given display item).
Solution
Store a reference to the object in the Tag property of the control.
How It Works
Every class that derives from Control inherits a Tag property. The Tag property is not used by the control or the .NET Framework. Instead, it's reserved as a convenient storage place for application-specific information. In addition, some other classes not derived from Control also provide a Tag property. Useful examples include the ListViewItem, TreeNode, and MenuItem classes.
Because the Tag property is defined as an Object type, you can use it to store any value type or reference type, ...
Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.