According to MSDN (http://msdn.microsoft.com/en-us/library/system.windows.forms.label.autosize.aspx), there’s a note about Label‘s AutoSize property:
When added to a form using the designer, the default value is true. When instantiated from code, the default value is false.
The question is: how can I override a Label control and set its AutoSize property’s design-time default value to false?
(Update)
And this doesn’t work:
class MyLabel : Label
{
const bool defaultAutoSize = false;
public MyLabel()
{
AutoSize = defaultAutoSize;
}
[DefaultValue(defaultAutoSize)]
public override bool AutoSize
{
get
{
return base.AutoSize;
}
set
{
base.AutoSize = value;
}
}
}
The
Labelcontrol has an attribute:which cause the strange
AutoSizeproblem.I can disable it by this: