PropertyGrid and nested property

C

Chris Dunaway

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?

--
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.
 
C

Chris Dunaway

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.
--
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top