Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TcxCustomPivotGrid.OnCustomDrawCell Event

In This Article

Enables you to custom paint a data cell.

#Declaration

Delphi
property OnCustomDrawCell: TcxPivotGridCustomDrawCellEvent read; write;

#Remarks

The Sender parameter specifies the pivot grid whose data cell is about to be painted.

The ACanvas parameter specifies the drawing surface.

The AViewInfo parameter provides information (a ViewInfo object) for rendering the data cell.

The ADone parameter specifies whether default painting is required. Set ADone to True, to prevent default painting.

To calculate a data cell’s custom summaries or summary variations within the OnCustomDrawCell event handler and change the data cell’s display value based on calculated values, call the AViewInfo.CalculateVisibleInfo method as shown below.

type
  TCellAccess = class(TcxPivotGridDataCellViewInfo);
procedure <Form>.<PivotGrid>CustomDrawCell(Sender: TcxCustomPivotGrid; ACanvas: TcxCanvas; AViewInfo: TcxPivotGridDataCellViewInfo; var ADone: Boolean);
begin
  if (AViewInfo.DataField = pgCustomSummaryField) and
    (AViewInfo.DataField.SummaryType = stCustom) then
  begin
    if VarIsNull(AViewInfo.CellSummary.Custom) then
      AViewInfo.CellSummary.Custom := AViewInfo.CellSummary.Sum * 2;
    if VarIsNull(AViewInfo.CellSummary.SummaryVariation) then
      AViewInfo.CellSummary.SummaryVariation := AViewInfo.CellSummary.Sum / 2;
    TCellAccess(AViewInfo).CalculateVisibleInfo;
  end;
end;
See Also