Column.DefaultDrawCell()
您可以FMX.Graphics.TCanvas.FillText()
在 gridsOnDrawColumnCell()
事件中使用,而不是调用。
文档解释了细节,但重点是Canvas.Fill.Color
在调用之前设置为所需的颜色Canvas.FillText()
示例代码:
procedure TForm28.Grid1DrawColumnCell(Sender: TObject; const Canvas: TCanvas;
const Column: TColumn; const Bounds: TRectF; const Row: Integer;
const Value: TValue; const State: TGridDrawStates);
begin
case Row of
0: Canvas.Fill.Color := TAlphaColors.Red;
1: Canvas.Fill.Color := TAlphaColors.Blue;
2: Canvas.Fill.Color := TAlphaColors.Green;
3: Canvas.Fill.Color := TAlphaColors.Blueviolet;
end;
Canvas.FillText(Bounds, Value.AsString, false, 1, [], TTextAlign.Leading, TTextAlign.Center);
end;
以及它的外观: