Back to Devexpress

Preventing Editors from Being Activated

windowsforms-5897-controls-and-libraries-pivot-grid-data-shaping-editing-preventing-editors-from-being-activated.md

latest2.3 KB
Original Source

Preventing Editors from Being Activated

  • Jan 23, 2019
  • 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:

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.

csharp
using DevExpress.XtraPivotGrid;

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

Private Sub PivotGridControl1_ShowingEditor(ByVal sender As System.Object, _
ByVal e As CancelPivotCellEditEventArgs) Handles PivotGridControl1.ShowingEditor
    If e.RowValueType <> PivotGridValueType.Value OrElse e.ColumnValueType <> PivotGridValueType.Value Then
        e.Cancel = True
    End If
End Sub