ComponentOne FlexGrid for WinForms
Creating Custom Editors
Using the C1FlexGrid Control > Editing Cells > Custom Editors > Creating Custom Editors

Any control that derives from the Control base class can be used as a grid editor. This is possible because the grid knows enough about the base class to access properties such as Text and Bounds, and events such as Leave and TextChanged. In many cases this level of support is adequate.

In some cases, however, you may want to use controls that do not follow the base class that closely. For example, a DateTimePicker control has a Value property that should be used to retrieve the edited value instead of Text. In these cases, you can implement one or more methods in the IC1EmbeddedEditor interface to override the default behavior. For example, all controls in the C1Input library support IC1EmbeddedEditor and therefore integrate closely with C1FlexGrid (and also C1TrueDBGrid).

The IC1EmbeddedEditor interface is fairly simple, and because the grid binds to it using late binding, you don't even have to implement all its members. Only implement the ones that make sense to your editor control.

The interface does provide enough flexibility to allow virtually any control to be used as a grid editor. You can even use UITypeEditor classes as grid editors. To do this, you need a wrapper class that:

  1. Derives from Control (UITypeEditor doesn't).
  2. Implements the IC1EmbeddedEditor interface.
  3. Encapsulates the appropriate UITypeEditor.

We provide source code for this wrapper class in the CustomEditors sample.

Using the UITypeEditor wrapper class, you can use any UITypeEditors with the C1FlexGrid. .NET provides several UITypeEditors for editing colors, fonts, file names, and so on. You can also write your own UITypeEditors, in some cases that is easier than writing a control.

Note: For an example of using built-in, custom, and UITypeEditor editors with C1FlexGrid, see the CustomEditors sample on GrapeCity website.
See Also