StringGrid lazarus / 13-General ---------------------------------------------------------------------- Anonymous · 2005-10-21 20:07 Hi, How can I align the strings to center in each cells in StringGrid? ---------------------------------------------------------------------- jesusr · 2005-10-22 05:39 Quote from: "Anonymous"Hi, How can I align the strings to center in each cells in StringGrid? There is a grid.DefaultTextStyle property available but currently it's a protected property, I think it will be public. Once it's public, case a) below could be written in form's OnCreate as: grid.DefaultTextStyle.Alignment := taCenter. For the moment there could be many ways for doing this, but the most flexible one (IMHO) is making a handler for OnPrepareCanvas. 1. Select the grid 2. in  object inspector select events tab 3. make a handler for OnPrepareCanvas event 4. in generated handler code write: a) if you want all cells, fixed and not fixed to be center aligned simply write something like: Code: [Select]    Stringgrid1.Canvas.TextStyle.Alignment := taCenter; b) just one column, say column 2 Code: [Select]    if Col=2 then      Stringgrid1.Canvas.TextStyle.Alignment := taCenter; c) just cells[1,1] Code: [Select]    if (Col=1)and(Row=1) then      Stringgrid1.Canvas.TextStyle.Alignment := taCenter; All other cells gets a default (left) alignment taken from DefaultTextStyle property. ---------------------------------------------------------------------- Anonymous · 2005-10-22 08:37 Thanks for this great step by step tutorial. Works OK!