According to Matt, the DefaultValue attribute does not set a default value for a property; it simply lets the form designer know that the property has a default value. If you change the default property, it will be in bold in the properties window.
You cannot set the default value using automatic properties - you will have to do it the old fashioned way:
class MyClass
{
Color lineColor = SystemColors.InactiveBorder;
[DefaultValue(true)]
public Color LineColor {
get {
return lineColor;
}
set {
lineColor = value;
}
}
}
source
share