I've tried about 100 different ways of specifying a default value for a Color property to be displayed in a PropertyGrid. None of them have worked.
How do you specify a default value for a Color property using the [DefaultValue()]attribute
I've tried about 100 different ways of specifying a default value for a Color property to be displayed in a PropertyGrid. None of them have worked.
How do you specify a default value for a Color property using the [DefaultValue()]attribute
DefaultValue Attribute for property of type Color
Tryin2Bgood
[
DefaultValue(typeof(Color), "Blue")]public Color MyColor
{
get { return m_Color; }
set { m_Color = value; }
}
private Color m_Color = Color.Blue;
Michael Taylor - 8/10/06
MaggieChan
WishfulDoctor
Samoyed
[
DefaultValue(typeof(Color), "0x808080")]The above value will set the default to gray. Basically you can pass any string to this attribute that can be converted to the target type. Internally it uses the types TypeConverter to convert the string to the value. If that works then the default value will be set. For Color you can use strings containing decimal values, octals, &H hex values, etc. in addition to named colors.
Michael Taylor - 8/10/06