Jeff- This should work:
<Code snippet = VB.NET> Private m_AlternateBackColor As Color = SystemColors.Control <Category("Appearance"), _ Description("Gets or Sets the alternate back color."), _ DefaultValue(GetType(Color), "Control")> _ Public Property AlternateBackColor As Color Get Return m_AlternateBackColor End Get Set(ByVal Value As Color) m_AlternateBackColor = Value End Set End Property </Code Snippet> Jacob A. Grass > -----Original Message----- > From: Jeff [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 16, 2002 7:42 AM > To: [EMAIL PROTECTED] > Subject: [DOTNET] DefaultValue() Attribute Question > > > I searched the list and the net and found a few vague references to my > question, but no concrete answers. > > I have a control where I want to specify default values so > the property > grid does not incorrectly bold the default settings (visual > cue that they > have been changed from the default when this is in fact not true). > > Say I have something along the lines of: > > [Category("Appearance"), > Description("Gets or sets alternate background color."), > Browsable(true), > DefaultValue(SystemColors.Control)] > > public Color AlternateBackColor > { > get {return alternateBackColor;} > > set {alternateBackColor = value;} > } > > The error I get, of course, is: > "An attribute argument must be a constant expression, typeof > expression or > array creation expression" > > So, how to make this a constant expression? > > I have tried other things like DefaultValue(-2830136) (the > RGB value I get > returned for SystemColors.Control), but neither this, nor any > of the other > things I have tried has worked. > > Does anyone know how to specify real default settings > attributes for Color > and Font properties like this? Bool, int, string, etc are so > easy, but > it's just not intuitive for any of these complex object > types. I won't be > surprised if someone shows me it's really easy for Color, but > Font looks > like it would be a bit more complex to represent in this > attribute in some > way. > > I would say the bold in the property grid is simply a > cosmetic thing, but > it gives a completely false user cue and is unprofessional. > > Any insight into this would be appreciated. > > Thanks, > > Jeff > > You can read messages from the DOTNET archive, unsubscribe > from DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.