[英]fmx delphi berlin how to change font color in rows of Tgrid
NEED HELP..I am using delphi 10.1 berlin. 需要帮助..我正在使用delphi 10.1柏林。 There are some different with other previus version of Embarcadero Delphy Code Gear.
与其他先前版本的Embarcadero Delphy Code Gear有所不同。 I need to change font color in rows of TGrid.
我需要更改TGrid行中的字体颜色。 Whith this next code i will change backgrond color but i need to change only Font Color :
下一个代码我将更改背景色,但我只需要更改字体颜色:
aRowColor.Color := arSTATUS_GRID_COLOR[0];
Canvas.FillRect(Bounds, 0, 0, [], 1, aRowColor);
Column.DefaultDrawCell(Canvas, Bounds, Row, Value, State);
Instead of calling Column.DefaultDrawCell()
, you can use FMX.Graphics.TCanvas.FillText()
in the grids OnDrawColumnCell()
event. 您可以在网格
OnDrawColumnCell()
事件中使用FMX.Graphics.TCanvas.FillText()
而不是调用Column.DefaultDrawCell()
。
The documentation explains the details, but the main point is to set Canvas.Fill.Color
to the desired color before calling Canvas.FillText()
该文档解释了细节,但主要的一点是设置
Canvas.Fill.Color
之前调用所需颜色Canvas.FillText()
Sample code: 样例代码:
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;
And how it looks like: 以及它的样子:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.