How does one tell the designer the default value of a Property when it is not one of the types supported by DefaultValue()
? For instance, a Padding
, or a Font
.
Normally, when you use a Windows Forms control, the default values will be in a normal font in the Properties window, and changed (non-default) values will be in bold. E.g.
In this sample, the default value of ShowAddress
is false
and the default value of ShowName
is true
. This effect is achieved with the following:
[DefaultValue(false)]
public bool ShowAddress {
get { return mShowAddress; }
set {
mShowAddress = value;
Invalidate();
}
}
[DefaultValue(true)]
public bool ShowName { ... }
However, when I tried to do something for Padding
, I failed miserably:
[DefaultValue(new Padding(2))]
public Padding LabelPadding { ... }
Which of course won't compile.
How on Earth would I do this?