wpf-401011-controls-and-libraries-data-grid-data-editing-and-validation-modify-cell-values-assign-an-editor-to-a-cell.md
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.
The DataViewBase.EditorButtonShowMode property specifies how to display editor buttons in cells.
You can also use the following techniques to assign editors to column cells:
Use the EditorButtonShowMode property to specify how editor buttons appear in cells:
The EditSettings property allows you to choose a DevExpress Data Editor for a column.
View Example: Assign a ComboBox Editor to a Column
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.
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 a 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
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 -->
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings/>
</dxg:GridColumn.EditSettings>
<!-- Data cells use DateEdit -->
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:DateEdit x:Name="PART_Editor"/>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
Use the CellTemplateSelector property to change a cell template based on a condition:
View Example: How to change a cell template based on custom logic
To implement this task, do the following:
Implement custom DataTemplates. Editors declared in these templates should follow our recommendations from this help topic: ColumnBase.CellTemplate:
Create a custom DataTemplateSelector descendant. This descendant should return templates according to your scenario requirements.
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.
You can specify how to process user actions related to editor activation. Refer to the following help topic for more information: Customize Editor Activation and Validation.
Format Cell ValuesUse techniques described in the following help topic: Format Cell Values.Align Cell ContentDefine the ColumnBase.EditSettings or ColumnBase.CellTemplate property and specify the HorizontalContentAlignment property in a BaseEditSettings / BaseEdit descendant.Modify Cell AppearanceApply format conditions or use the DataViewBase.CellStyle property to customize cells.Merge Duplicated Cell ValuesYou can merge neighboring cells if they display matching values.
The EditSettings property affects the cell appearance when you print the GridControl data or export it in WYSIWYG mode.
Use the PrintCellStyle property to customize cell appearance when you print or export the grid.
|
Property
|
Affects Sorting / Filtering / Grouping
|
Supports Printing / Exporting
|
Supports Standard WPF Controls
|
Supports Template Selector
|
Works in Edit Mode
| | --- | --- | --- | --- | --- | --- | |
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
|
See Also