The C1PropertyGrid control has a set of built-in editors which support all common data types: string, numeric, bool, Enum, Color, Brush, Image, and so on.
The most suitable editor is automatically selected depending on the type of the property. When no suitable editor is found for the current property type, the string editor is used by default.
The list of editors is exposed by the AvailableEditors property of the C1PropertyGrid class. You can add your own custom editors to this list. The next section, Creating Custom Editors, explains how you can implement your own custom editors.
For each property, the C1PropertyGrid control checks the list of available editors and selects the first one that supports the current property type. This allows you to specify your own editor for all properties of a given type. Simply add your editor to the start of the AvailableEditors list and it will be used for all suitable properties. For example:
Visual Basic |
Copy Code
|
---|---|
Dim pg = New C1PropertyGrid() pg.AvailableEditors.Insert(0, New DateTimeEditor()) |
C# |
Copy Code
|
---|---|
var pg = new C1PropertyGrid(); pg.AvailableEditors.Insert(0, new DateTimeEditor()); |
If you want to use a custom editor only for specific properties and not for all properties of a certain type you can either add an "Editor" attribute to the object being edited or use the PropertyAttributes property described above.