PivotGridControl.CustomDrawCell Event

Enables data cells to be painted manually.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v20.1.dll

Declaration

public event PivotCustomDrawCellEventHandler CustomDrawCell
Public Event CustomDrawCell As PivotCustomDrawCellEventHandler

Event Data

The CustomDrawCell event's data class is PivotCustomDrawCellEventArgs. The following properties provide information specific to this event:

Property Description
Appearance Gets the painted cell's appearance settings.
Bounds Gets the cell's bounds. Inherited from PivotCellEventArgs.
ColumnCustomTotal Gets the column custom total which displays the current cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ColumnField Gets the innermost column field which corresponds to the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ColumnFieldIndex For internal use. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ColumnIndex Gets the visual index of the column that contains the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ColumnValueType Gets the type of column which contains the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
Data For internal use. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
DataField Gets the data field which identifies the column where the processed cell resides. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
DisplayText Gets the display text of the cell currently being processed. Inherited from PivotCellEventArgs.
Focused Gets whether the processed cell is the focused cell. Inherited from PivotCellEventArgs.
Graphics Gets the object used to paint a cell.
GraphicsCache Gets an object which specifies the storage for the most used pens, fonts and brushes.
Handled Gets or sets whether an event was handled, if it was handled the default actions are not required.
Item For internal use. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowCustomTotal Gets the row custom total which contains the current cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowField Gets the innermost row field which corresponds to the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowFieldIndex For internal use. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowIndex Gets the index of the row that contains the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
RowValueType Gets the type of row which contains the processed cell. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
Selected Gets whether the processed cell is selected. Inherited from PivotCellEventArgs.
SummaryType Gets the summary type of the currently processed value. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
SummaryValue Gets the summary value currently being processed. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.
ThreadSafeArgs Gets an event parameter that provides thread-safe access to event data.
Value Gets the processed cell's value. Inherited from PivotCellEventArgsBase<TField, TData, TCustomTotal>.

Remarks

The CustomDrawCell event is raised before a data cell is painted. The event parameter provides all the information necessary to paint a cell. Set the PivotCustomDrawCellEventArgs.Handled property to true to prohibit default cell painting.

NOTE

Custom drawing of any kind is ignored when printing PivotGridControl. To change the appearance of cells when the Pivot Grid Control is displayed onscreen and in the print output, handle the PivotGridControl.CustomAppearance event.

NOTE

To access event data while an asynchronous operation is being performed, use a thread-safe event parameter returned by the PivotCustomDrawCellEventArgs.ThreadSafeArgs property. To learn more, see Asynchronous Mode.

IMPORTANT

Do not change cell values, modify the control's layout, or change the control's object model in the events used for custom control painting. Actions that update the layout can cause the control to malfunction.

Examples

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

PivotGrid_CustomDrawCell

using System.Drawing.Drawing2D;
using DevExpress.XtraPivotGrid;

private void pivotGridControl1_CustomDrawCell(object sender, PivotCustomDrawCellEventArgs e) {
   if(e.ColumnValueType == PivotGridValueType.GrandTotal || 
      e.RowValueType == PivotGridValueType.GrandTotal) {
      e.GraphicsCache.FillRectangle(new LinearGradientBrush(e.Bounds, Color.LightBlue, 
        Color.Blue, LinearGradientMode.Vertical), e.Bounds);
      Rectangle innerRect = Rectangle.Inflate(e.Bounds, -3, -3);
      e.GraphicsCache.FillRectangle(new LinearGradientBrush(e.Bounds, Color.Blue, 
        Color.LightSkyBlue, LinearGradientMode.Vertical), innerRect);
      e.GraphicsCache.DrawString(e.DisplayText, e.Appearance.Font, 
        new SolidBrush(Color.White), innerRect, e.Appearance.GetStringFormat());
      e.Handled = true;
   }
}
See Also