[Solved] Stringgrid fixed row wordwrap lazarus / 31-LCL ---------------------------------------------------------------------- Windsurfer · 2014-08-31 20:00 I am looking for a way to wrap text in the header row of a string grid, so that translations of the header can be accepted without changing the column width. Changing the header row height works with Code: [Select]  StringGrid1.RowHeights[0] := stringgrid1.RowHeights[0] * 2; This old topic http://forum.lazarus.freepascal.org/index.php/topic,578 4.msg27094.html#msg27094 recommends a solution, but using it generates an error: 'Argument can't be assigned to'. Presumably this worked at the time. Does anyone have any suggestions? I am using Laz 1.2.4 with FPC 2.6.4, on i7 processor and Linux Mint 16. ---------------------------------------------------------------------- engkin · 2014-08-31 20:20 How about: Code: [Select]var   aTextStyle: TTextStyle; begin   aTextStyle := TStringGrid(Sender).Canvas.TextStyle;   aTextStyle.SingleLine := false;   aTextStyle.Wordbreak := true;   TStringGrid(Sender).Canvas.TextStyle := aTextStyle; end; ---------------------------------------------------------------------- Windsurfer · 2014-08-31 22:18 Thanks Engkin, I had completely forgotten about changing styles in that way. I changed the last line to: Code: [Select]  if aRow = 0 then     TStringGrid(Sender).Canvas.TextStyle := aTextStyle; It compiles and runs. I'll test it tomorrow. ---------------------------------------------------------------------- Windsurfer · 2014-09-01 11:33 It worked when I moved the code to the OnPrepareCanvas event. Code: [Select]procedure TfrmDataView.StringGrid1PrepareCanvas(sender: TObject;   aCol, aRow: Integer; aState: TGridDrawState);   var   aTextStyle: TTextStyle; begin   aTextStyle := TStringGrid(Sender).Canvas.TextStyle;   aTextStyle.SingleLine := False;   aTextStyle.Wordbreak := True;   if aRow = 0 then TStringGrid(Sender).Canvas.TextStyle := aTextStyle; end;