I‘m changing the background color based on the data but it makes my text hard to read so I need to change the font color (to white if I have a darker color) but I can‘t find a way to do it, I‘m using Delphi XE8.
if not (isSelected) then
begin
case StrToInt((Sender as TStringGrid).Cells[0, Row]) of
0:
begin
//TTextCell(CellCtrl).StyledSettings := [];
TTextCell(CellCtrl).FontColor := Cores[3 - auxCor - 1];
RowColor.Color := Cores[auxCor-1];
end;
1:
begin
//TTextCell(CellCtrl).StyledSettings := [];
TTextCell(CellCtrl).FontColor := TAlphaColors.Black;
RowColor.Color := TAlphaColors.Red;
end;
2:
begin
//TTextCell(CellCtrl).StyledSettings := [];
TTextCell(CellCtrl).FontColor := TAlphaColors.Black;
RowColor.Color := TAlphaColors.Yellow;
end;
3:
begin
//TTextCell(CellCtrl).StyledSettings := [];
TTextCell(CellCtrl).FontColor := TAlphaColors.Black;
RowColor.Color := TAlphaColors.LightGreen;
end;
end;
end;
Canvas.FillRect(Bounds, 0, 0, [], 1, RowColor);
TGrid(Sender).DefaultDrawColumnCell(Canvas, Column, Bounds, Row,
Value, State);
(Sender as TStringGrid).Selected := SelectedRow;
the TTextCell portion doesn‘t do anything (I have an else with a similar case where I set a color to Green so I need the text to be white (if white ends up being hard to read I‘ll try some other colors).
Cores is an array with Black and White TAlphaColors