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

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

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

[{'answer_id': 43751, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 4, 'selected': False, 'text': '<p>You need to change first argument from <code>SystemColors</code> to <code>Color</code>.<br>\nIt seems that there is no type converter for the <code>SystemColors</code> type, only for the <code>Color</code> type.</p>\n\n<pre><code>[DefaultValue(typeof(Color),"InactiveBorder")]\n</code></pre>\n'}, {'answer_id': 44073, 'author': 'roomaroo', 'author_id': 3464, 'author_profile': 'https://Stackoverflow.com/users/3464', 'pm_score': 2, 'selected': False, 'text': "<p>According to the link Matt posted, the DefaultValue attribute doesn't set the default value of the property, it just lets the form designer know that the property <em>has</em> a default value. If you change a property from the default value it is shown as bold in the properties window.</p>\n\n<p>You can't set a default value using automatic properties - you'll have to do it the old-fashioned way:</p>\n\n<pre><code>class MyClass\n{\n    Color lineColor = SystemColors.InactiveBorder;\n\n    [DefaultValue(true)]\n    public Color LineColor {\n        get {\n            return lineColor;\n        }\n\n        set {\n            lineColor = value;\n        }\n    }\n}\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/43738', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/976/']