PivotGridControl.CustomAppearance Event

Allows the appearances of cells to be dynamically customized when the control is displayed on screen and in the print output.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v20.1.dll

Declaration

public event PivotCustomAppearanceEventHandler CustomAppearance
Public Event CustomAppearance As PivotCustomAppearanceEventHandler

Event Data

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

Property Description
Appearance Gets or sets the appearance settings of the currently processed cell.
Bounds Gets the cell's bounds. Inherited from PivotCellEventArgs.
ColumnCustomTotal Gets the column custom total which displays the current cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ColumnField Gets the innermost column field which corresponds to the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ColumnFieldIndex For internal use. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ColumnIndex Gets the visual index of the column that contains the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ColumnValueType Gets the type of column which contains the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
Data For internal use. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
DataField Gets the data field which identifies the column where the processed cell resides. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
DisplayText Gets the display text of the cell currently being processed. Inherited from PivotCellEventArgs.
Focused Gets whether the processed cell is the focused cell. Inherited from PivotCellEventArgs.
Item For internal use. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowCustomTotal Gets the row custom total which contains the current cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowField Gets the innermost row field which corresponds to the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowFieldIndex For internal use. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowIndex Gets the index of the row that contains the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowValueType Gets the type of row which contains the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
Selected Gets whether the processed cell is selected. Inherited from PivotCellEventArgs.
SummaryType Gets the summary type of the currently processed value. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
SummaryValue Gets the summary value currently being processed. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ThreadSafeArgs Gets an event parameter that provides thread-safe access to event data.
Value Gets the processed cell's value. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.

Remarks

Unlike custom painting applied by handling the PivotGridControl.CustomDrawCell event, appearances customized via the CustomAppearance event are used when the pivot grid is printed.

The CustomAppearance event fires for each pivot grid cell and allows you to customize the appearance of cells dynamically (depending on their contents, position, values of other cells, etc). Use the event parameter to identify the processed cell.

IMPORTANT

Do not change cell values, modify the control's layout, or change the control's object model in the events used for custom control painting. Actions that update the layout can cause the control to malfunction.

To customize the appearance settings, use the event parameter's PivotCustomAppearanceEventArgs.Appearance property.

To access event data while an asynchronous operation is being performed, use a thread-safe event parameter returned by the PivotCustomAppearanceEventArgs.ThreadSafeArgs property. To learn more, see Asynchronous Mode.

Examples

The following example shows how to customize the appearance of specific cells via the PivotGridControl.CustomAppearance event.

In this example, custom appearance settings (the yellow background and bold font) are applied to a cell if it meets the following conditions:

  • It belongs to an "ExtendedPrice" data field.
  • It's not displayed within total rows or columns.
  • It's value is larger than 1000.

The following image demonstrates code execution:

PivotGridControl.CustomAppearance

using DevExpress.XtraPivotGrid;

private void pivotGridControl1_CustomAppearance(object sender, PivotCustomAppearanceEventArgs e) {
    if (e.DataField == fieldExtendedPrice && e.ColumnValueType == PivotGridValueType.Value 
        && e.RowValueType == PivotGridValueType.Value) {
        if (e.Value != null && (decimal)e.Value > 1000) {
            e.Appearance.BackColor = Color.Yellow;
            e.Appearance.Font = new Font(e.Appearance.Font, FontStyle.Bold);
        }
    }
}
See Also