[SOLVED] How can I align the strings to center in each cells in StringGrid ? lazarus / 31-LCL ---------------------------------------------------------------------- gjpneac · 2012-07-17 13:26 Hello, procedure TForm1.FormCreate(Sender: TObject); begin   StringGrid1.DefaultTextStyle.Alignment:= taCenter; end;     --> unit1.pas(34,31) Error: Argument can't be assigned to Lazarus 1.1 - 2012-07-09 - FPC 2.6.1 - SVN 37902 - i386-win32 Regards. ---------------------------------------------------------------------- KpjComp · 2012-07-17 13:35 try -> Code: [Select]procedure TForm1.FormCreate(Sender: TObject); var   s:TTextStyle; begin   s := StringGrid1.DefaultTextStyle;   s.Alignment:=taCenter;   StringGrid1.DefaultTextStyle := s; end; ---------------------------------------------------------------------- wp · 2012-07-17 13:45 Or, if you want to modify Alignment and/or other properties only for particular cells, use the OnPrepareCanvas event of the stringrid, like this: Code: [Select]procedure TForm1.GridPrepareCanvas(sender: TObject; aCol, aRow: Integer; aState: TGridDrawState); var   ts: TTextStyle; begin   if ARow=0 then     Grid.Canvas.Font.Style := [fsBold];        // bold for header row   if (ACol > 0) then begin                     // centered alignment for all data cells     ts := Grid.Canvas.TextStyle;     ts.Alignment := taCenter;     Grid.Canvas.TextStyle := ts;     if Grid.Cells[ACol, ARow] = '00:00' then   // not interesting cells in silver       Grid.Canvas.Font.Color := clSilver;   end; end; ---------------------------------------------------------------------- Avishai · 2012-07-17 14:12 At Design-Time, you can use the 'Columns Editor' and set each Column Alignment to taCenter or how ever you want it.  The Title is separate so if you want that centered, you have to set it as well. ---------------------------------------------------------------------- gjpneac · 2012-07-17 14:17 Thanks. it work's fine. @Avishai :  FixedCols := 1; So I suppose that Columns has no effect on Cols[0].