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

How to: Change the Field Value Header Appearance

If UserLookAndFeel.Style is equal to Skin, the appearance background color settings have no effect in this instance. If you want to draw a field header using a custom color, you can draw the field header manually using the PivotGridControl.CustomDrawFieldValue event.

private void pivotGridControl1_CustomDrawFieldValue(object sender, 
    DevExpress.XtraPivotGrid.PivotCustomDrawFieldValueEventArgs e) {
    if (e.Area == DevExpress.XtraPivotGrid.PivotArea.ColumnArea) {
        Rectangle rect = e.Bounds;
        ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
        Brush brush = e.GraphicsCache.GetSolidBrush(Color.LightYellow);
        rect.Inflate(-1, -1);
        e.Graphics.FillRectangle(brush, rect);
        e.Appearance.DrawString(e.GraphicsCache, e.Info.Caption, e.Info.CaptionRect);
        e.Painter.DrawIndicator(e.Info);               
        e.Handled = true;
    }
    else if (e.Area == DevExpress.XtraPivotGrid.PivotArea.RowArea) {
        e.Painter.DrawObject(e.Info);
        e.Painter.DrawIndicator(e.Info);
        e.Graphics.FillRectangle(e.GraphicsCache.GetSolidBrush(Color.FromArgb(50, 0, 0, 200)), e.Bounds);
        e.Handled = true;
    }
}