Editors Class Structure

  • 2 minutes to read

This topic discusses how editors are organized internally. It describes the classes used and explains how data editors can be used for in-place editing in container controls (e.g. Data Grid).

Editors Class Structure

All data editor classes derive from the BaseEdit class. These classes represent stand-alone controls that you can place onto a window. These are also the controls that are created by containers when an editor is activated (e.g. when editing a cell value with a grid). The BaseEdit class only implements the basic internal class structure required by container controls to work with their in-place editors, and does not provide any editor functionality.

When you create an in-place editor, you actually create an object that holds an editor's settings. Each editor has the helper class (the BaseEditSettings descendant) responsible for the editor's functionality. This class stores editor behavior options required by a container control to create a fully functional data editor at runtime. When the same editor is used in multiple locations, a container control uses this helper class to paint its cells. Edit settings can be accessed and customized via a container's EditSettings property.

Let's consider an editor used to edit column values in a grid. In this instance, the new BaseEditSettings descendant is created and assigned to a column's ColumnBase.EditSettings property.

<dxg:GridColumn FieldName="UnitPrice">
    <dxg:GridColumn.EditSettings>
        <dxe:ButtonEditSettings AllowDefaultButton="False">
            <dxe:ButtonEditSettings.Buttons>
                <dxe:ButtonInfo GlyphKind="Plus" Click="PlusButton_Click"/>
                <dxe:ButtonInfo GlyphKind="Minus" Click="MinusButton_Click"/>
            </dxe:ButtonEditSettings.Buttons>
        </dxe:ButtonEditSettings>
    </dxg:GridColumn.EditSettings>
</dxg:GridColumn>

The actual editors (BaseEdit descendants) are only created when end-users start to edit data, and are automatically destroyed when data editing is completed.

private void PlusButton_Click(object sender, RoutedEventArgs e) {
    // Increments the active editor's value.
    // In this example, this is SpinEdit.
    (gridControl1.View.ActiveEditor as SpinEdit).Value++;
}

private void MinusButton_Click(object sender, RoutedEventArgs e) {
    // Decrements the active editor's value.
    (gridControl1.View.ActiveEditor as SpinEdit).Value--;
}

The image below illustrates an editor's internal structure.

Editors structure

When creating custom editor controls, you need to follow this editor structure, so that container controls can manage your editor properly.