Before I begin, it seems a similar/same question might have been asked before here, however no definitive answer exists.
Suppose I have a custom winforms control which overrides the Text
property:
public class MyControl : Control
{
[DefaultValue("")]
public override string Text
{
get { return base.Text; }
set
{
base.Text = value;
...
}
}
public MyControl()
{
this.Text = "";
}
}
My question is, How do I prevent the designer from automatically assigning the Text
property?
When instances of MyControl
are created, the designer automatically assigns the Text
property to the name of the control instance, e.g., "MyControl1", "MyControl2", etc. Ideally, I would like the text property to be set to its default, an empty string.