Assembly: System.Windows.Forms (in system.windows.forms.dll)
'Declaration <LocalizableAttribute(False)> _ <BindableAttribute(True)> _ Public Property Tag As Object 'Usage Dim instance As Control Dim value As Object value = instance.Tag instance.Tag = value
/** @property */ public Object get_Tag () /** @property */ public void set_Tag (Object value)
Property ValueAn Object that contains data about the control. The default is a null reference (Nothing in Visual Basic).
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.
Private Sub buttonNewCustomer_Click(sender As Object, _ e As EventArgs) Handles buttonNewCustomer.Click ' Create a new customer form and assign a new ' Customer object to the Tag property. Dim customerForm As New CustomerForm() customerForm.Tag = New Customer() customerForm.Show() End Sub
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.