I have a StringGrid where some rows are colored different.
I use the following procedure for that:
procedure TForm1.StringGridPrepareCanvas(Sender: TObject; aCol, aRow: Integer;
aState: TGridDrawState);
var
MyTextStyle: TTextStyle;
begin
with (Sender as TMyStringGrid) do begin
MyTextStyle := Canvas.TextStyle;
MyTextStyle.SingleLine := false; // wrap long line in cell
MyTextStyle.Wordbreak := True; // break line in cell if linebreak found
MyTextStyle.Layout:=tlTop;
Canvas.TextStyle := MyTextStyle;
if AR[Tag].RowAttr[aRow] then begin
Canvas.Brush.Color:=$F1F1F1;
Canvas.Font.Color:=$000000;
end;
end;
end;
This works fine, except that rows with color set to gray do not change color when they are selected (blue).
What have I missed?