Recent

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

ASerge

  • Hero Member
  • *****
  • Posts: 2212
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;

 

TinyPortal © 2005-2018