Skip to main content
A newer version of this page is available. .

How to: Customize Appearances of Cells via an Event

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