ApplicationContext.Tag ApplicationContext.Tag ApplicationContext.Tag ApplicationContext.Tag Property

定义

获取或设置一个对象,该对象包含控件的数据。Gets or sets an object that contains data about the control.

public:
 property System::Object ^ Tag { System::Object ^ get(); void set(System::Object ^ value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter))]
public object Tag { get; set; }
member this.Tag : obj with get, set
Public Property Tag As Object

属性值

一个 Object,其中包含有关控件的数据。An Object that contains data about the control. 默认值为 nullThe default is null.

注解

从类派生的Object任何类型都可以分配给此属性。Any type derived from the Object class can be assigned to this property. 如果通过 Windows 窗体设计器来设置属性,则只能分配文本。TagIf the Tag property is set through the Windows Forms designer, only text can be assigned.

Tag属性的常见用途是存储与控件密切关联的数据。A common use for the Tag property is to store data that is closely associated with the control. 例如,如果您具有显示有关客户的信息的控件,则可以将包含客户订单DataSet历史记录的设置存储在该控件的Tag属性中,以便可以快速访问数据。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.

适用于