|
Got it:
had to change the gridcolor right before calling the DefaultDrawColumnCell method:
procedure TFrmMainMaximized.StringGridDrawColumnCell(
Sender: TObject; const Canvas: TCanvas; const Column: TColumn;
const Bounds: TRectF; const Row: Integer; const Value: TValue;
const State: TGridDrawStates);
var
RowColor : TBrush;
isSelected : boolean;
FontColor : Integer;
SelectedRow : Integer;
begin
RowColor := Tbrush.Create(TBrushKind.Solid, TAlphaColors.Alpha);
isSelected := ((Sender as TStringGrid).Selected = Row) and
((Sender as TStringGrid).ColumnIndex = Column.Index);
SelectedRow := (Sender as TStringGrid).Selected;
if not (isSelected) then
begin
case StrToInt((Sender as TStringGrid).Cells[0, Row]) of
0:
begin
FontColor := Cores[3 - auxCor - 1];
RowColor.Color := Cores[auxCor-1];
end;
1:
begin
FontColor := TAlphaColors.Black;
RowColor.Color := TAlphaColors.Red;
end;
2:
begin
FontColor := TAlphaColors.Black;
RowColor.Color := TAlphaColors.Yellow;
end;
3:
begin
FontColor := TAlphaColors.Black;
RowColor.Color := TAlphaColors.LightGreen;
end;
end;
end
else
begin
case StrToInt((Sender as TStringGrid).Cells[0, Row]) of
0:
begin
FontColor := Cores[auxCor - 1];
RowColor.Color := Cores[3 - auxCor-1];
end;
1:
begin
FontColor := TAlphaColors.Black;
RowColor.Color := TAlphaColors.Pink;
end;
2:
begin
FontColor := TAlphaColors.Black;
RowColor.Color := TAlphaColors.LightYellow;
end;
3:
begin
FontColor := TAlphaColors.White;
RowColor.Color := TAlphaColors.Green;
end;
end;
end;
Canvas.FillRect(Bounds, 0, 0, [], 1, RowColor);
TGridAccess((Sender as TStringGrid)).GetTextSettingsControl.ResultingTextSettings.FontColor := FontColor;
TGrid(Sender).DefaultDrawColumnCell(Canvas, Column, Bounds, Row,
Value, State);
inherited;
end;
the TextSettingControl property from the grid is protected so I had to make an access Class with this function:
function TGridAccess.GetTextSettingsControl: TTextCell;
begin
result := inherited TextSettingsControl;
end;
|