[SOLVED] how to RightJustify columns in a TStringGrid? lazarus / 31-LCL ---------------------------------------------------------------------- Hartmut · 2016-10-04 10:22 I want to have some columns of my TStringGrid justified to the right. I found no property for that... In the internet I found only suggestions, which write new procedures for TForm1.StringGridDrawCell() called by the string grid's OnDrawCell event. Is there really no way which is more easy like a property for that? Thanks in advance. ---------------------------------------------------------------------- wp · 2016-10-04 10:30 TStringGrid and its ancestors do not provide a property for text alignment because there is no way how to store that information for the moment when it is needed. Instead, it introduces an event OnPrepareCanvas which is called from the DrawCell method immediately before anything is painted onto the canvas. In order to achieve right-alignment of text set the Alignment in the TextStyle of the Canvas to taRightJustify: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;  aState: TGridDrawState);var  ts: TTextStyle;begin  if aCol = then begin    ts := TStringGrid(Sender).Canvas.TextStyle;    ts.Alignment := taRightJustify;    TStringGrid(Sender).Canvas.TextStyle :=ts;  end;end;This event is very important for modifying how a cell is painted. You can also change the font or background color here. [EDIT] If you work with columns there's an easier way though: Select the column in the object inspector, and set its "Alignment" to taRightJustify. This setting is valid for the entire column; the alignment of the Title can be changed by using Title.Alignment. Above solution has the advantage that individual cells can be handled separately. ---------------------------------------------------------------------- Hartmut · 2016-10-04 11:24 Thanks a lot to wp for those 2 good solutions.