Control.Tag Property

 

Gets or sets the object that contains data about the control.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[<BindableAttribute(true)>]
[<TypeConverterAttribute(typeof(StringConverter))>]
member Tag : Object with get, set

Property Value

Type: System.Object

An Object that contains data about the control. The default is null.

Any type derived from the Object class can be assigned to this property. If the Tag property is set through the Windows Forms designer, only text can be assigned.

A common use for the Tag property is to store data that is closely associated with the control. For example, if you have a control that displays information about a customer, you might store a DataSet that contains the customer's order history in that control's Tag property so the data can be accessed quickly.

The following code example displays a form and stores a Customer in its Tag property. This example requires that you have defined a class that derives from Form named CustomerForm and that you have defined a Customer.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: