Hi,
I want to assign a custom editor to a boolean
property in a PropertyGrid
. I'm using the standard propertygrid (from namespace System.Windows.Forms
). It is possible to assign custom editors to properties using the UITypeEditor
class. However, as far as I can see, it is not possible to use it for a boolean
property.
I've tried to solve it by overriding the property grid so I can add items manually. I can add a string
property that has a custom editor by the following piece of code:
Properties.Item.Add("My Custom Editor", "", false, "Properties with custom UITypeEditor", "The component accept custom UITypeEditor.", true);
Properties.Item[Properties.Item.Count - 1].CustomEditor = new MyEditor();
So far so good, a custom editor appears (with a button in the grid). However, when I change the type to boolean
by setting the default value on false
(see below), the button to open the custom editor doesn't appear. Instead, a dropdown menu with true
/false
appears.
Properties.Item.Add("My Custom Editor", false, false, "Properties with custom UITypeEditor", "The component accept custom UITypeEditor.", true);
Properties.Item[Properties.Item.Count - 1].CustomEditor = new MyEditor();
Does anyone has a solution for this?
Thanks in forward!
Regards, Peter