C# – DefaultValue for System.Drawing.SystemColors

.netc++user-controlswinforms

I have a line color property in my custom grid control. I want it to default to Drawing.SystemColors.InactiveBorder. I tried:

[DefaultValue(typeof(System.Drawing.SystemColors), "InactiveBorder")]
public Color LineColor { get; set; }

But it doesn't seem to work. How do I do that with the default value attribute?

Best Solution

You need to change first argument from SystemColors to Color.
It seems that there is no type converter for the SystemColors type, only for the Color type.

[DefaultValue(typeof(Color),"InactiveBorder")]