Skip to main content

TcxGridTableView.OnCustomDrawIndicatorCell Event

Occurs when painting an indicator cell within a Table View.

Declaration

property OnCustomDrawIndicatorCell: TcxGridIndicatorCellCustomDrawEvent read; write;

Remarks

The OnCustomDrawIndicatorCell event occurs every time an indicator cell needs to be painted. Similar to other custom draw events, it provides a canvas for the grid control (the ACanvas parameter) and the ViewInfo information about the indicator cell (the AViewInfo parameter). The Sender parameter is the View that initiated the repaint. The ADone parameter is initially False. You should set it to True to notify the grid control that custom drawing has been applied to this item.

The following example shows how to imitate a fixed column of the Table View using the OnCustomDrawIndicatorCell event

procedure TViewTableSimpleDemoMainForm.cxgFilmsDBTableViewCustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
  FValue: string;
  FBounds: TRect;
begin
    FBounds := AViewInfo.Bounds;
  if (AViewInfo is TcxGridIndicatorHeaderItemViewInfo) then
  begin
    ACanvas.Brush.Color := $00C56A31;
    ACanvas.FillRect(FBounds);
    ACanvas.DrawComplexFrame(FBounds, clBlack, clBlack, cxBordersAll, 1);
    ACanvas.Font.Color := clWhite;
    ACanvas.Font.Style := [fsBold];
    ACanvas.Brush.Style := bsClear;
    InflateRect(FBounds, -3, 0);
    ACanvas.DrawText('Year', FBounds, cxAlignLeft or cxAlignVCenter);
    ADone := True;
  end
  else if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
  begin
    ACanvas.FillRect(FBounds);
    ACanvas.DrawComplexFrame(FBounds, clBlack, clBlack, [bBottom, bLeft, bRight], 1);
    FValue := TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Values[cxgFilmsDBTableViewYEAR.Index];
    InflateRect(FBounds, -3, -2);
    ACanvas.Font.Color := clBlack;
    ACanvas.Brush.Style := bsClear;
    ACanvas.DrawText(FValue, FBounds, cxAlignRight or cxAlignTop);
    ADone := True;
  end;
end;

The result is shown on the following image:

See Also