Recent

Author Topic: AutoSize TMemo.Height?  (Read 14361 times)

ASerge

  • Hero Member
  • *****
  • Posts: 2480
Re: AutoSize TMemo.Height?
« Reply #15 on: April 19, 2018, 08:38:48 pm »
Does someone know how to AutoSize the height of TMemo so that it displays all Lines?  I've tried several calculations but none of them seem to work.  I'm trying to avoid showing the scrollbars.
I have this function works:
Code: Pascal  [Select][+][-]
  1. procedure ChangeMemoHeightToFitLines(Memo: TMemo);
  2. var
  3.   TestMemo: TMemo;
  4. begin
  5.   TestMemo := TMemo.Create(nil);
  6.   try
  7.     TestMemo.Parent := Memo.Parent;
  8.     TestMemo.Width := Memo.Width;
  9.     TestMemo.Font.Assign(Memo.Font);
  10.     TestMemo.Text := Memo.Text;
  11.     TestMemo.AdjustSize;
  12.     if TestMemo.Height > Memo.Height then
  13.       Memo.Height := TestMemo.Height;
  14.   finally
  15.     TestMemo.Free;
  16.   end;
  17. end;

laz_one_or2

  • Newbie
  • Posts: 1
Re: AutoSize TMemo.Height?
« Reply #16 on: March 15, 2026, 09:51:55 am »
Aserge, your solution works.
i try in all directions  with adjustsize, without success.
Thanks :D :D :D

wp

  • Hero Member
  • *****
  • Posts: 13483
Re: AutoSize TMemo.Height?
« Reply #17 on: March 15, 2026, 05:55:05 pm »
1. There seems to be a bug in both TLabel and TMemo:
None of them wraps on the comma in „йдсалкйфдлксайфдклйдсайлкдасйлкдйклсдалкйдлс,асдфласйдфлксадйфлкдаслдфк‟.
No. Add a space after the comma, and the word-wrap will work. Without the space it won't even wrap with purely ASCII characters.

 

TinyPortal © 2005-2018