Back to Devexpress

PivotCustomDrawCellEventArgs Class

windowsforms-devexpress-dot-xtrapivotgrid-05ff9e81.md

latest5.2 KB
Original Source

PivotCustomDrawCellEventArgs Class

Provides data for the PivotGridControl.CustomDrawCell event.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public class PivotCustomDrawCellEventArgs :
    PivotCustomDrawCellBaseEventArgs
vb
Public Class PivotCustomDrawCellEventArgs
    Inherits PivotCustomDrawCellBaseEventArgs

PivotCustomDrawCellEventArgs is the data class for the following events:

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.

csharp
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;
  }
}
vb
Imports DevExpress.XtraPivotGrid
Imports System.Drawing

Private Sub PivotGridControl1_CustomDrawCell(ByVal sender As Object, ByVal e As PivotCustomDrawCellEventArgs)
  If e.ColumnValueType = PivotGridValueType.GrandTotal OrElse e.RowValueType = PivotGridValueType.GrandTotal Then
    Dim r As Rectangle
    Dim brushFillTotals As Brush
    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
  End If
End Sub

Inheritance

Object EventArgs PivotCellEventArgsBase<PivotGridField, DevExpress.XtraPivotGrid.Data.PivotGridViewInfoData, PivotGridCustomTotal> PivotCellBaseEventArgs PivotCellEventArgs PivotCustomDrawCellBaseEventArgs PivotCustomDrawCellEventArgs

See Also

PivotCustomDrawCellEventArgs Members

DevExpress.XtraPivotGrid Namespace