Preventing Editors from Being Activated

  • 2 minutes to read

You can provide in-place editors for cells, as described in the Cell Editors Overview. In-place editors specify how cell values are represented on screen (in display mode). These editors also allow you to edit data. It's possible to disable the data editing and use in-place editors to represent cell values in read-only mode. To disable the data editing, you can use:

  • the PivotGrid control's PivotGridOptionsCustomizationEx.AllowEdit property.

    This allows you to disable data editing for all cells.

  • a data field's PivotGridFieldOptionsEx.AllowEdit property.

    This allows data editing to be disabled for cells corresponding to a specific data field.

  • the PivotGridControl.ShowingEditor event.

    This event allows you to disable data editing for particular cells. It fires when an in-place editor is about to be invoked. Setting the event's Cancel parameter to true prevents the editor from being invoked. The event's other parameters allow you to identify the currently processed cell, and determine when data editing should be disabled.

Example

The following code shows how to disable data editing for total cells. This is accomplished by handling the PivotGridControl.ShowingEditor event. When handling this event, the type of the current cell can be identified via the PivotCellEventArgsBase<TField, TData, TCustomTotal>.ColumnValueType and PivotCellEventArgsBase<TField, TData, TCustomTotal>.RowValueType parameters.

using DevExpress.XtraPivotGrid;

private void pivotGridControl1_ShowingEditor(object sender, CancelPivotCellEditEventArgs e) {
    if (e.RowValueType != PivotGridValueType.Value || e.ColumnValueType != PivotGridValueType.Value)
        e.Cancel = true;
}