In my code, the event OnGetCellColor (from TAdvStringGrid) is used to change the look of the Cell depending on some conditions. The AlternateColor property solved part of my problems, but I needed to check the Cell's content before it's drawn. Then, after a few searches, I've found OnPrepareCanvas. A simple code to put negative numbers in red looks like this:
The standard TStringGrid from LCL has all I need: the project is one step closer to be ported. Thanks Jesus Reyes Aguilar for the great work!
procedure TForm1.StringGrid1PrepareCanvas(sender: TObject;
Col, Row: Integer; aState: TGridDrawState);
begin
if not (gdfixed in aState) then
if Pos('-',StringGrid1.Cells[Col,Row]) = 0 then begin
StringGrid1.Canvas.Font.Color := clBlue;
end else begin
StringGrid1.Canvas.Font.Color := clRed;
end;
end;
No comments:
Post a Comment