Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / May 2004

Tip: Looking for answers? Try searching our database.

Default Values in Properties Window

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
msnews.microsoft.com - 19 May 2004 17:58 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.