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. This event also allows you to change editors within an Edit Form.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

[DXCategory("Editor")]
public event CustomRowCellEditEventHandler CustomRowCellEditForEditing
<DXCategory("Editor")>
Public Event CustomRowCellEditForEditing As CustomRowCellEditEventHandler

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.

Examples

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:

CustomRowCellEditForEditing

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;
}
See Also