This control is nothing but a class, not a
sealed one. So, naturally, you can create a derived class and add any property you want, as well as any other member:
class MyTextBox : System.Windows.Forms.TextBox {
string MyNewProperty { get; set; }
}
[EDIT]
Now, with your
Mandatory
you really need fully-fledged property features, such as the
setter:
class MyTextBox : System.Windows.Forms.TextBox {
internal bool Mandatory {
get { return mandatory; }
set {
if (value == mandatory) return;
mandatory = value;
Invalidate();
}
}
bool mandatory;
protected override void OnPaint(PaintEventArgs eventArgs) {
base.OnPaint(eventArgs);
if (mandatory) {
RenderItOneWay(eventArgs.Graphics);
} else {
RenderItAnotherWay(eventArgs.Graphics);
}
}
}
Got the idea?
—SA