Skip to main content

TcxCustomPivotGrid.OnCustomDrawCell Event

Enables you to custom paint a data cell.

Declaration

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