A control's Tag property allows you to associate values with controls. This property was useful in prior versions of Visual Basic to allow quick data accessibility, however .NET offers a more effective and efficient way of doing this. Instead of using the Tag property, consider using inheritance to extend components with your own properties. Inheritance allows you to add as many properties as you need, and to make those properties strongly typed.
' VB
Public Class CustomButton
Inherits System.Windows.Forms.Button
Private NewProp As Integer
Property ButtonValue() As Integer
Get
Return NewProp
End Get
Set(ByVal Value As Integer)
NewProp = Value
End Set
End Property
End Class
// C#
public class CustomButton : System.Windows.Forms.Button
{
int NewProp;
int ButtonValue
{
get
{
return NewProp;
}
set
{
NewProp = value;
}
}
}