Column header lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- kjteng · 2019-10-27 13:58 Is there a way to made the column header of tsworksheet left align or right align horizontally? ---------------------------------------------------------------------- wp · 2019-10-27 14:49 You probably mean the TsWorksheetGrid because TsWorksheet itself is the datastructure for the cells and does not have header. Well, the TsWorksheetGrid derives from TCustomGrid, and therefore you can apply the standard methods of TCustomGrid to modify painting (see https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Description_o f_grid.27s_drawing_process). For overriding the default alignment you can hook into the OnPrepareCanvas event which is called after the default properties of the Canvas have been set and before the cell is painted: Set the alignment of the Canvas' TextStyle to taLeftJustify or taRightJustify for the very first row (index 0): 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.sWorksheetGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer; aState: TGridDrawState);var  ts: TTextStyle;begin  if ARow = 0 then  begin    ts := (Sender as TCustomGrid).Canvas.TextStyle;    ts.Alignment := taRightJustify;    (Sender as TCustomGrid).Canvas.TextStyle := ts;  end;end; ---------------------------------------------------------------------- kjteng · 2019-10-27 23:27 TQVM.   I can override the default taCenter setting now. (Y) ---------------------------------------------------------------------- kjteng · 2019-10-28 00:04 Quote from: wp on October 27, 2019, 03:49:45 pmCode: 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.sWorksheetGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer; aState: TGridDrawState);var  ts: TTextStyle;begin  if ARow = 0 then  begin    ts := (Sender as TCustomGrid).Canvas.TextStyle;    ts.Alignment := taRightJustify;    (Sender as TCustomGrid).Canvas.TextStyle := ts;  end;end; Master, the code compiled/run successfuly but the column header text is still aligned to center. Did I miss out something? ---------------------------------------------------------------------- wp · 2019-10-28 00:11 Did you assign this code to the OnPrepare event of the grid? Convince yourself with the attached demo that this code works. ---------------------------------------------------------------------- kjteng · 2019-10-28 03:09 Still cannot get it work (see attached pic). Something wrong with my version of  Lazars (v1.84)? ---------------------------------------------------------------------- wp · 2019-10-28 16:54 Yes I can confirm your observation with Laz 1.8.4. I don't have 2.0 any more, but 2.0.2 already behaves correctly. I did not investigate in detail but the svn commit notes show a variety of commits affecting painting. So, probably it is easiest for you if you upgrade to a newer version - wait a few days and v2.0.6 will be released, or select 2.0.4. If you fear that the new version might introduce some new behavior in your projects you should install the new version as a "secondary installation" which leaves your old version untouched so that you easily can return to the old version. You can select this feature in the installer. Always make sure to have a backup copy of critical projects when switching between Lazarus versions because the new version may add new properties to the lfm file which cause reading errors when going back to the old version. ---------------------------------------------------------------------- kjteng · 2019-10-28 23:25 Thanks. Good advice. ---------------------------------------------------------------------- kjteng · 2019-11-02 12:43 tested. The above code works on Lazarus 2.06.