I got this code in a user control:
[DefaultValue(typeof(Color), \"Red\")]
public Color MyColor { get; set; }
How can I change MyColor
It is informal, but you can use it via reflection, for example, place in your constructor the following:
foreach (PropertyInfo p in this.GetType().GetProperties())
{
foreach (Attribute attr in p.GetCustomAttributes(true))
{
if (attr is DefaultValueAttribute)
{
DefaultValueAttribute dv = (DefaultValueAttribute)attr;
p.SetValue(this, dv.Value);
}
}
}