Bonnie,
Thanks for the answers. You might have answered something similar before (I might be loosing my mind today). I started looking through some old user controls and I noticed that I can get around initializing the values in the constructor by initializing the private variable that the property is using. I do this when the variable is declared.
I have been using the RefreshProperties attribute in the past when I create usercontrol that consists of other controls and it seems to refresh the design surface when I change a property. In this case I am painting my own control and I am trying to get the designer to change based on my selection in the property sheet. Do I have to call the onpaint or refresh by myself in the set of the property?
Einar
>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
Semper ubi sub ubi.