Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Default value for property
Message
From
17/09/2005 16:06:56
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01050633
Message ID:
01050638
Views:
8
Einar,

I thought that I had answered this stuff here before, but it may have been in another forum cuz I can't find it here.

For #1, you said I have gotten around this by setting the value of the private member (liquidColor) in this example to equal the default color in the constructor of the class.

And that's what you need to do. The DefaultValue attribute is only used for resetting in the Property Sheet, not for the initial value when instantiating the class.

For #2, you said What exactly does RefreshProperties(RefreshProperties.Repaint) do for me?

I've never used this attribute, but I looked it up in the docs, and this is what it says:
Specify this attribute on a property to repaint all properties in the PropertyGrid when the property value changes.

~~Bonnie




>I have the following property in my usercontrol:
>
>[Category("Appearance")]
>[Description("The color of the liquid that is inside the thermometer.")]
>[DefaultValue(typeof(Color),"Red")]
>[RefreshProperties(RefreshProperties.Repaint)]
>public Color LiqidColor
>{
>  get
>  {
>    return this.liquidColor;
>  }
>  set
>  {
>    this.liquidColor = value;
>  }
>}
>
>
>Now I have two issues with this.
>1. If I right-click in the property sheet and select reset the color returns to Red which is great but when I rebuild the color is all of a sudden gone. What is up with that? I have gotten around this by setting the value of the private member (liquidColor) in this example to equal the default color in the constructor of the class.
>
>2. What is supposed to happend when I change the color in the designer's property sheet? Shouldn't the color change? (I use this color in the OnPaint event. What exactly does RefreshProperties(RefreshProperties.Repaint) do for me?
>
>Thanks,
>Einar
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform