可能重复:
Can I make a TMemo size itself to the text it contains?自动调整备忘录
需要做自动调整备忘录:高度和宽度。
我自动调整高度如下:
function TForm1.AutoSizeMemoY(Memo: TMemo): word;
begin
Canvas.Font := Memo.Font;
Result := Canvas.TextExtent(Memo.Lines.Strings[0]).cy * Memo.Lines.Count +
Canvas.TextExtent(Memo.Lines.Strings[0]).cy;
end;
但我不知道该怎么做自动调整宽度。我有一个想法:如果滚动条被激活,然后增加宽度,直到它变为不活动,但我不知道如何实现。
Austosizing只能在一个方向上实现。要么固定高度并调整宽度或固定宽度并调整高度。 – hubalu
@SimaWB,我需要,并在宽度和高度。 +字体可以不同! – dedoki