I have a custom control derived from button. One property is an instance
of the following simple class, which is used to paint the button with
different colors:
Public Class Style
Private _ColorStart As Color
Private _ColorEnd As Color
Private _ColorHighlight As Color
Public Property ColorStart() As Color
Get
Return _ColorStart
End Get
Set(ByVal Value As Color)
_ColorStart = Value
End Set
End Property
Public Property ColorEnd() As Color
Get
Return _ColorEnd
End Get
Set(ByVal Value As Color)
_ColorEnd = Value
End Set
End Property
Public Property ColorHighlight() As Color
Get
Return _ColorHighlight
End Get
Set(ByVal Value As Color)
_ColorHighlight = Value
End Set
End Property
End Class
The property is declared like this:
<TypeConverter(GetType(ExpandableObjectConverter))> _
Public Property ClickedStyle() As Style
Get
Return _ClickedStyle
End Get
Set(ByVal Value As Style)
_ClickedStyle = Value
End Set
End Property
Note that I have applied the TypeConverter attribute so that in the
PropertyGrid, the property can be expanded to show the individual colors.
This seems to work ok.
The problem is that, when I change the individual colors, it does not seem
to affect the visual display of the button. Not on the designer nor at
runtime.
For example, the defualt colors are red. In the designer I can change the
color to blue and it seems to be changed, but on the form the color of the
button does not change, nor does it change at runtime. At runtime, when I
inspect the property, it still has the default values.
It seems like the property is being changed in the PropertyGrid but the
button object is not reflecting the change.
Any clues?

Signature
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Sijin Joseph - 29 Aug 2004 08:26 GMT
Are you using a custom designer for your control, i think you will need
to use one, in order to itercept the property value change and then
update the visual appearance of your control at design time.
Check out these articles
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/c
ustdsgnrdotnet.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/c
ustcodegen.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/u
singpropgrid.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/v
snetpropbrow.asp
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> I have a custom control derived from button. One property is an instance
> of the following simple class, which is used to paint the button with
[quoted text clipped - 64 lines]
>
> Any clues?
Chris Dunaway - 01 Sep 2004 16:00 GMT
> Are you using a custom designer for your control, i think you will need
Thanks for the reply. I resolved my problem by adding an event to the
class. When a property is changed, I raise the event. That works in the
designer as well and is simpler than implementing a custom designer for the
class.

Signature
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.