fmx delphi berlin如何改变Tgrid行的字体颜色 [英] fmx delphi berlin how to change font color in rows of Tgrid
本文介绍了fmx delphi berlin如何改变Tgrid行的字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
aRowColor.Color:= arSTATUS_GRID_COLOR [0 ]。
Canvas.FillRect(Bounds,0,0,[],1,aRowColor);
Column.DefaultDrawCell(Canvas,Bounds,Row,Value,State);
解决方案可以在网格
OnDrawColumnCell()中使用 FMX.Graphics.TCanvas.FillText()
code> event。
NEED HELP..I am using delphi 10.1 berlin. There are some different with other previus version of Embarcadero Delphy Code Gear. I need to change font color in rows of 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.
The documentation explains the details, but the main point is to set Canvas.Fill.Color
to the desired color before calling 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:
这篇关于fmx delphi berlin如何改变Tgrid行的字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文