Skip to main content

Assign Editors to Cells

  • 5 minutes to read

The GridControl assigns editors to column cells based on the column’s data type. Refer to the Smart Columns Generation topic for a complete list of supported data types and corresponding data editors.

You can also use the following techniques to assign editors to column cells:

Use a DevExpress Editor

The EditSettings property allows you to choose a DevExpress Data Editor for a column.

View Example: Assign a ComboBox Editor to a Column

Implement a Custom Control

Use the CellTemplate property to implement a custom cell editor for a column. You can specify any DevExpress WPF Control or Standard WPF Control.

The CellTemplate is intended for complex customization that you cannot achieve with EditSettings alone. If you want to specify and configure a DXEditor, we recommend that you use EditSettings instead. Refer to the Address Possible Issues if You Use Cell Templates section for more information.

Assign Editors Separately for Display and Edit Modes

You can use templates to define custom cell editors separately for display and edit modes.

The ColumnBase.CellEditTemplate is only used when a cell is in edit mode. Therefore, it has less impact on performance compared to CellTemplate that is used in both edit and display modes and applies to all cells within a column.

Use the ColumnBase.CellDisplayTemplate to use a different (or differently configured) editor for cells in display mode.

Template Description
ColumnBase.CellDisplayTemplate / DataViewBase.CellDisplayTemplate Defines a template that displays column values.
ColumnBase.CellEditTemplate / DataViewBase.CellEditTemplate Defines a template that is used to edit cell values.

View Example: How to Use Custom Editors to Edit Cell Values

Use a Separate Editor for Automatic Filter Row

The EditSettings property affects the Automatic Filter Row. Specify the CellTemplate to assign a different editor for data cells:

 <dxg:GridColumn FieldName="Date">
    <!-- Automatic Filter Row uses TextEdit -->
    <!-- Data cells use DateEdit -->
            <dxe:DateEdit x:Name="PART_Editor"/>

Assign Different Editors to the Same Column

Use the CellTemplateSelector property to change a cell template based on a condition:

Grid - CellTemplateSelector

View Example: How to change a cell template based on custom logic

To implement this task, do the following:

  1. Implement custom DataTemplates. Editors declared in these templates should follow our recommendations from this help topic: ColumnBase.CellTemplate:

        <DataTemplate x:Key="booleanEditor">
            <dxe:CheckEdit Name="PART_Editor"/>
        <DataTemplate x:Key="buttonEditor">
            <dxe:ButtonEdit Name="PART_Editor"/>
        <DataTemplate x:Key="comboboxEditor">
            <dxe:ComboBoxEdit Name="PART_Editor">
        <DataTemplate x:Key="dateEditor">
            <dxe:DateEdit Name="PART_Editor"/>
        <DataTemplate x:Key="textEditor">
            <dxe:TextEdit Name="PART_Editor"/>
    <dxg:GridControl Name="grid">
            <dxg:GridColumn FieldName="Editor"/>
            <dxg:GridColumn FieldName="Value">
            <dxg:TableView Name="view" AutoWidth="True" EditorButtonShowMode="ShowAlways"/>
  2. Create a custom DataTemplateSelector descendant. This descendant should return templates according to your scenario requirements.


    Each GridControl cell contains an object of the EditGridCellData data type in its DataContext. This object’s RowData.Row property contains your data item. You can use this property if your logic should take property values from data items into account:

    public class EditorTemplateSelector : DataTemplateSelector {
        public override DataTemplate SelectTemplate(object item, DependencyObject container) {
            EditGridCellData data = (EditGridCellData)item;
            var dataItem = data.RowData.Row as TestData;
            return string.IsNullOrEmpty(dataItem.Editor) ? null : (DataTemplate)((FrameworkElement)container).FindResource(dataItem.Editor);

Address Possible Issues if You Use Cell Templates

The CellDisplayTemplate and CellEditTemplate override the CellTemplate for the same column.

The CellTemplate does not affect data processing (sorting, grouping, filtering, summary calculation) and export.

When you use the CellTemplate, specify the EditSettings value to configure the format settings, data processing (sorting, grouping, filtering, summary calculation), and export. The editor itself specified in the EditSettings property is ignored.

Performance depends on the current cell editor. The difference is not noticeable when you use lightweight controls (for example, TextBlock). When you use heavier controls, the EditSettings property allows you to gain maximum performance. For example, ComboBoxEditSettings, LookUpEditSettings, and so on.

Process User Actions

The GridControl has the following events to process user actions:

Event Description
DataViewBase.GetIsEditorActivationAction Allows you to specify whether an action (key press, text input, or left mouse button click) activates the focused editor.
DataViewBase.ProcessEditorActivationAction Allows you to make the focused editor process an activation action.
DataViewBase.GetActiveEditorNeedsKey Allows you to specify whether an active editor responds to keys a user presses.

View Example: How to Specify Navigation in Custom Cell Editors

Change How Data Cells Look in Printed and Exported Documents

The EditSettings property affects the cell appearance when you print the GridControl‘s data or export it in WYSIWYG mode.

Use the PrintCellStyle property to customize cell appearance when you print or export the grid.

Comparative Table


Affects Sorting / Filtering / Grouping

Supports Printing / Exporting

Supports Standard WPF Controls

Supports Template Selector

Works in Edit Mode

























See Also