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:
procedure ChangeMemoHeightToFitLines(Memo: TMemo);
var
TestMemo: TMemo;
begin
TestMemo := TMemo.Create(nil);
try
TestMemo.Parent := Memo.Parent;
TestMemo.Width := Memo.Width;
TestMemo.Font.Assign(Memo.Font);
TestMemo.Text := Memo.Text;
TestMemo.AdjustSize;
if TestMemo.Height > Memo.Height then
Memo.Height := TestMemo.Height;
finally
TestMemo.Free;
end;
end;