Colored cells of a string grid lazarus / 8-Other ---------------------------------------------------------------------- MartinK · 2008-04-08 18:13 Is it possible to give any cell of a string grid a colored background? ---------------------------------------------------------------------- OnixJr · 2008-04-08 20:53 This code paint a blue background in StringGrid1.Cells[2, 2] (OnPrepareCanvas event): Code: [Select] procedure TForm1.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;   aState: TGridDrawState); begin   If ((aCol = 2) and (aRow = 2)) then     StringGrid1.Canvas.Brush.Color := clBlue; end; Regards, Júnior ---------------------------------------------------------------------- CM630 · 2012-05-16 11:12 So if I want to change the background of several cells, does it mean, that I have to store the background colours in an array and to recolour them with a loop each time when the StringGrid is repainted? ---------------------------------------------------------------------- Blaazen · 2012-05-16 12:01 No, if you assign OnPrepareCanvas event and your StringGrid has 100 cells then this event is raised 100 times. You don't need any loop. ---------------------------------------------------------------------- CM630 · 2012-05-16 12:34 Ideed, no loop is needed, just   If aRow> 0 then       StringGrid1.Canvas.Brush.Color := BG[aCol, aRow]; ---------------------------------------------------------------------- Jvan · 2020-08-02 00:42 Quote from: CM630 on May 16, 2012, 02:34:31 pmIdeed, no loop is needed, just   If aRow> 0 then       StringGrid1.Canvas.Brush.Color := BG[aCol, aRow]; I have this problem message using your code: " main.pas(100,36) Error: Identifier not found "BG" "