Is there some grid with color property for each cell of the grid ? lazarus / 31-LCL ---------------------------------------------------------------------- pasc92 · 2013-03-21 03:18 Hello, I'm a newbee in Lazarus practice and I have some troubles with some "missing" documentation... I would like to know if there is a Lazarus grid component with color property for each cell of the grid. I precise that I do not want just paint with canvas a cell or few cells, but choice by coding the color of each cell. That's for very, very simple Conway's Life game, as an example to learn Lazarus. Many thanks for your answers. Pascal P.S. Sorry for my poor english. ---------------------------------------------------------------------- wp · 2013-03-21 08:26 You can use the standard TStringGrid and add a handler to the event OnPrepareCanvas. In this event you can change the color of each cell, e.g. (untested...) Code: [Select]procedure TForm1.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;   aState: TGridDrawState); begin   if odd(ACol) and odd(ARow) then     StringGrid1.Canvas.Brush.Color := clRed   else if odd(ACol) then     StringGrid1.Canvas.Brush.Color := clSilver   else if odd(ARow) then     StringGrid1.Canvas.Brush.Color := clYellow end; ---------------------------------------------------------------------- pasc92 · 2013-03-21 12:41 Hello wp, Many thanks for your answer. I have read a tutorial about StringGrid who describe this way of coding, and I try it. Each column or row or a unique cell can be painting with canvas. But this not permits to "store" the color of each cell (independently), like an array of colorised cells. Best regards. Pascal ---------------------------------------------------------------------- wp · 2013-03-21 13:45 But you can always store the colors in a separate 2D array that you use like this: Code: [Select]var   CellColors: array of TColor; //...   // call this after the cell count of the grid is known.   SetLength(CellColors, StringGrid1.ColCount, StringGrid1.RowCount);   CellColors[0,0] := clRed;   CellColors[0,1] := clBlue;   // etc. procedure TForm1.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;   aState: TGridDrawState); begin   StringGrid1.Canvas.Brush.Color := CellColors[aCol, aRow]; end; ---------------------------------------------------------------------- pasc92 · 2013-03-25 21:48 Hello wp, I try it... Very nice event "OnPrepareCanvas" !! I can progress in TStringGrid usage with your help. Thanks a lot to you. Pascal