GridView.CustomRowCellEditForEditing Event
Allows you to assign a custom editor to a column for in-place editing and so override the default column editor, which is by default used both in display and edit modes. To avoid performance issues and increased memory consumption, assign repository items that already exist in the GridControl.RepositoryItems collection. Do not create new repository items in this handler. This event also allows you to change editors within an Edit Form.
Namespace: DevExpress.XtraGrid.Views.Grid
Assembly: DevExpress.XtraGrid.v24.2.dll
Declaration
[DXCategory("Editor")]
public event CustomRowCellEditEventHandler CustomRowCellEditForEditing
Event Data
The CustomRowCellEditForEditing event's data class is CustomRowCellEditEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
CellValue | Returns the currently processed cell value. Inherited from CustomRowCellEventArgs. |
Column | Gets the column to which the currently processed cell corresponds. Inherited from CustomRowCellEventArgs. |
RepositoryItem | Gets or sets the editor used to edit the currently processed cell. |
RowHandle | Gets the handle of the row that contains the processed cell. Inherited from CustomRowCellEventArgs. |
Remarks
You can assign an in-place editor to a column via the GridColumn.ColumnEdit property, or to an individual column cell via the GridView.CustomRowCellEdit event. This editor will be used to represent a cell’s contents in display mode (when the cell isn’t currently edited), and by default in edit mode. If you need to provide different editors to represent a cell’s contents differently in display and edit modes, handle the CustomRowCellEditForEditing event.
To assign an editor to a cell for in-place editing while handling the CustomRowCellEditForEditing event, assign a corresponding repository item to the RepositoryItem parameter. Note that the repository item must belong to the grid control’s RepositoryItems collection (see the EditorContainer.RepositoryItems property) or to an external repository (see the EditorContainer.ExternalRepository property).
When an Edit Form is used to edit row values, you can handle the CustomRowCellEditForEditing event to replace default editors within this form with custom editors. The CustomRowCellEditForEditing event fires repeatedly for all controls in the Edit Form. This only happens when the Edit Form is initialized (opened for the first time). When the form is opened subsequently, the previously initialized form is reused. The CustomRowCellEditForEditing event does not fire in these cases.
When the CustomRowCellEditForEditing event fires, the RowHandle parameter is set to GridControl.InvalidRowHandle.
Example
The following example demonstates how to assign different in-place editors to a column that will be used in display and edit modes respectively.
Assume that a grid column displays integer values that should be represented by a progress bar in display mode. In edit mode, a cell’s value must be edited by a spin editor.
To implement this task, a ProgressBar in-place editor must be assigned as the default editor to the column via the GridColumn.ColumnEdit property. This editor will be used to represent data in display mode. To provide a custom editor that will be used for in-place editing, the GridView.CustomRowCellEditForEditing
event is handled.
The following image illustrates the result:
using DevExpress.XtraEditors.Repository;
// In-place editors used in display and edit modes respectively.
RepositoryItem editorForDisplay, editorForEditing;
private void Form1_Load(object sender, EventArgs e) {
// Initialize the editors and assign the default editor to a column.
editorForDisplay = new RepositoryItemProgressBar();
editorForEditing = new RepositoryItemSpinEdit();
gridView1.GridControl.RepositoryItems.AddRange(
new RepositoryItem[] { editorForDisplay, editorForEditing });
gridView1.Columns["Quantity"].ColumnEdit = editorForDisplay;
}
// Provide the editor for in-place editing.
private void gridView1_CustomRowCellEditForEditing(object sender,
CustomRowCellEditEventArgs e) {
if (e.Column.FieldName == "Quantity")
e.RepositoryItem = editorForEditing;
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomRowCellEditForEditing event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.