all groups > dotnet windows forms designtime > may 2004 >
You're in the

dotnet windows forms designtime

group:

Default Values in Properties Window


Re: Default Values in Properties Window Matt Berther
5/19/2004 10:05:18 AM
dotnet windows forms designtime:
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.

[quoted text, click to view]
--

--
Matt Berther
Default Values in Properties Window msnews.microsoft.com
5/19/2004 12:58:26 PM
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


Re: Default Values in Properties Window morfy
5/20/2004 7:51:42 AM
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

[quoted text, click to view]

AddThis Social Bookmark Button