Skip to main content

PivotCustomDrawCellEventArgs Class

Provides data for the PivotGridControl.CustomDrawCell event.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v24.1.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public class PivotCustomDrawCellEventArgs :
    PivotCustomDrawCellBaseEventArgs

Remarks

The PivotCustomDrawCellEventArgs class provides properties that allows you to identify the painted cell’s bounding rectangle, appearance settings, content, etc. The field whose cell is being painted is represented by the PivotCustomDrawCellBaseEventArgs.DataField property.

The PivotCustomDrawCellEventArgs.Handled property specifies whether default painting is required after the event handler has executed. If this property is set to true within a handler then the default painting is cancelled. Otherwise, any custom painting performed within an event handler will be overridden by the Pivot Grid Control’s standard painting.

Note

You cannot use the PivotCustomDrawCellEventArgs class members to access event data while an asynchronous operation is being performed. Use the pivot grid’s IThreadSafeAccessible.IsAsyncInProgress property to determine whether an operation is in progress. If this property returns true, use a thread-safe event parameter returned by the PivotCustomDrawCellEventArgs.ThreadSafeArgs property to access event data. To learn more, see Asynchronous Mode.

Example

The following sample code handles the PivotGridControl.CustomDrawCell event to custom paint Grand Total cells. The image below shows the result.

PivotGrid_CustomDrawCell

using DevExpress.XtraPivotGrid;
using System.Drawing;

private void PivotGridControl1_CustomDrawCell(object sender, PivotCustomDrawCellEventArgs e)
{
  if (e.ColumnValueType == PivotGridValueType.GrandTotal ||
    e.RowValueType == PivotGridValueType.GrandTotal)
  {
    Rectangle r;
    Brush brushFillTotals;
    brushFillTotals = e.GraphicsCache.GetSolidBrush(ColorTranslator.FromHtml("#0099cc"));
    r = e.Bounds;
    e.GraphicsCache.FillRectangle(brushFillTotals, e.Bounds);
    r.Inflate(-4, -4);
    e.GraphicsCache.DrawString(e.DisplayText, e.Appearance.Font,
    Brushes.White, r, e.Appearance.GetStringFormat());
    e.Handled = true;
  }
}

Inheritance

See Also