On Thu, 16 May 2002 07:45:51 -0500, Jacob Grass
<[EMAIL PROTECTED]> wrote:

>DefaultValue(GetType(Color), "Control")

Thanks, I should have read ALL the overloads more carefully to see the one
that included type.

However, this still does not work because the compiler reports:
"'System.Drawing.Color' denotes a 'class' where a 'variable' was expected"

I did find, however, that the following (C#) DOES work perfectly:

DefaultValue(typeof(Color), "Control")

Thanks so much for pointing me to that overload, DOH!!!

Jeff

>> -----Original Message-----
>> From: Jeff
>> 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.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to