I have a class that is a subclass from User Control and I would like to have
BackColor have a default value of ... oh lets say Color.White.
I noticed that even if I use ResetBackColor and ShouldSearlizeBackColor, it
still shows up as bold unless I actually override the property directly and
provide DesignerSearlizationVisiblity attribute.
Is this the only way to get a default value in the properties view?!? Don't
really want to override properties JUST to get default values ;-(
Brett
Matt Berther - 19 May 2004 18:05 GMT
Hello msnews.microsoft.com,
I dont think you need to provide the DesignerSerializationVisibility attribute, but rather the DefaultValue attribute. In this case, overriding the property to get the default value makes sense, since the DefaultValue attribute is applied to the base.
> I have a class that is a subclass from User Control and I would like
> to have BackColor have a default value of ... oh lets say Color.White.
[quoted text clipped - 9 lines]
>
> Brett

Signature
--
Matt Berther
http://www.mattberther.com
morfy - 20 May 2004 05:51 GMT
Hi,
In your herited UserControl:
[DefaultValue(typeof(Color), "White")]
public override Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = value;
}
}
and set the usercontrols BackColor to white in the constructor.
regards, antti
> I have a class that is a subclass from User Control and I would like to have
> BackColor have a default value of ... oh lets say Color.White.