[Lazarus] StringGrid

zeljko zeljko at holobit.net
Sun Jul 7 08:09:49 CEST 2013


On 07/07/2013 02:24 AM, Kamen Ketev wrote:
> Hello, I want to change certain cells in StringGrid. Here is an example,
> but it changes all cells. Any idea where is wrong?
>
> procedure TForm1.StringGrid1Click(Sender: TObject);
> var
>      i, j: integer;
> begin
>      for i := 1 to 4 do
>        for j := 1 to 4 do Begin
>          if i=j
>            then StringGrid1.Font.Style := [fsBold]
>            else StringGrid1.Font.Style := [];
>          StringGrid1.Cells[i,j] := 'StrTest';
>      end;
> end;

That's wrong. You're changing TStringGrid.Font. If you want to change 
font of one (few) cells only then you should use OnDrawCell or something 
similar where you can change canvas.Font per cell.

z.





More information about the Lazarus mailing list