Color Property DefaultValue

  • Thread starter Thread starter timtos
  • Start date Start date
T

timtos

I want to set a color property of a user control by default.
I am doing it like this:

....
DefaultValue(typeof(System.Drawing.Color), "Blue"),
....

The compiler likes it but my program ignores it!
I´ve also tried other things like:

DefaultValue(typeof(Color), "Blue"),
DefaultValue(typeof(Color), "Color.Blue"),
DefaultValue(typeof(System.Drawing.Color), "0, 0, 255"),
DefaultValue(typeof(System.Drawing.Color), "0; 0; 255"),

Searching the net I found a lot of solutions like the ones above.
But the problem is none of them are working for me.

Any ideas?
Thanks,
timtos.
 
Timtos,
The DefaultValue attribute tells the designer what the constructor of your
object considers the default value. You still need to set the default for
the backing field on the property to the default, I normally do this in the
constructor.

I normally use:
DefaultValue(typeof(System.Drawing.Color), "Blue"),

Hope this helps
Jay

In the constructor of your
 
Back
Top