I have a custom UITypeEditor that is in use for Colour Selection with my program using the propertygrid, but I can’t seem to get it to activate if I just expose system.drawing.color. I need to wrap the Color with a CustomType before it will invoke my UITypeEditor.
Note the Property TheColour it works. The Colour doesn’t.
When I open the propertyGrid, I can see GetEditStyle is called via both methods, but when it comes to EditValue it is only called when you select TheColour in the propertygrid. The Normal Colour dropdown is shown when you select Colour Property
What am I missing?
<CategoryAttribute("Order Colour"), _
Browsable(True), _
DisplayName("The Colour"), _
Description("The background colour for orders from this terminal"), _
EditorAttribute(GetType(IKMDependency.ColourSelectorEditor), _
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property TheColour() As MyColour
Get
Return mMyColor
End Get
Set(ByVal value As MyColour)
If value.Colour <> mMyColor.Colour Then
mColor = value.Colour
mMyColor = value
mIsDirty = True
End If
End Set
End Property
<CategoryAttribute("Order Colour"), _
Browsable(True), _
DisplayName("Colour"), _
Description("The background colour for orders from this terminal"), _
EditorAttribute(GetType(IKMDependency.ColourSelectorEditor), _
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property Colour() As Color
Get
Return mColor
End Get
Set(ByVal value As Color)
If mColor <> value Then
mColor = value
mMyColor = New MyColour(mColor)
mIsDirty = True
End If
End Set
End Property
The problem is that it is noticing that the associated
TypeConvertersupports enumerated values. We need to disable that; note we can also inherit from the default implementations to get things like the color preview painting (examples in C#, but should be easy to translate):If you want this to apply to all
Colorproperties, there is also a way to do it such that you don’t need to decorate every property; somewhere during your app’s initialization code, execute: