How to: Customize the Cell Appearance

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);
        }
    }
}