ColumnView.ShowingEditor Event

Occurs when a cell inplace editor is about to open, and allows you to cancel this action.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

[DXCategory("Editor")]
public event CancelEventHandler ShowingEditor
<DXCategory("Editor")>
Public Event ShowingEditor As CancelEventHandler

Event Data

The ShowingEditor event's data class is CancelEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets a value indicating whether the event should be canceled.

Remarks

To identify the cell whose editor is about to be invoked, use the ColumnView.FocusedRowHandle and ColumnView.FocusedColumn properties. You can then set the e.Cancel parameter to true to prevent the editor from being shown.

The code sample below illustrates how to suppress in-place editor activation for all ID column cells if they belong to even grid rows. You can test this sample in this live demo.


gridView.ShowingEditor += (s, e) => {
    e.Cancel = gridView.FocusedColumn.FieldName == "ID" && gridView.FocusedRowHandle % 2 == 0;
};

If you need to prevent users from editing any Grid cells (or any cells that belong to the individual column), do not cancel the ShowingEditor event. Instead, disable the ColumnViewOptionsBehavior.Editable or OptionsColumn.AllowEdit settings.

The ShowingEditor occurs before the editor opens. If you need to perform specific actions after the editor is shown, handle the ColumnView.ShownEditor event instead.

NOTE

The ShowingEditor event does not fire for Auto Filter Row cells.

Online Video

WinForms Grid: Prevent Editing in Specific Cells.

See Also