我可以对包含的文本本身设置TMemo大小吗? -火猴 [英] Can I make a TMemo size itself to the text it contains? - Firemonkey

查看:84
本文介绍了我可以对包含的文本本身设置TMemo大小吗? -火猴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现之前曾问过有关VCL的问题,但我没有运气就可以在Firemonkey TMemo 上获得该问题的答案。

I found that this question has been asked before for VCL, but I haven't had any luck getting the answers for that question to work on a Firemonkey TMemo.

我注意到 memo.Lines.Count 似乎总是根据我添加的数量来匹配行数,而不是因为重新格式化(备忘录确实打开了自动换行功能)。不知道这个数字,我不确定如何开始计算。

I've noticed that memo.Lines.Count always seems to match the line count based off how many I add, not as they're formatted (the memo does have wordwrap turned on). Without knowing that number I'm not sure how to start figuring this out.

有什么想法吗?

编辑:备忘的宽度将取决于设备的方向,显然,如果宽度改变,显示的行数可能会改变。另外,我也不想更改备忘录的字体。

The width of the memo will depend on the orientation of the device, obviously if the width changes the number of lines showing could change. Also, I'd like to not alter the font of the memo.

推荐答案

Procedure ResizeMemo(AMemo: TMemo);
const
  Offset = 4; //The diference between ContentBounds and ContentLayout
begin
  AMemo.Height := AMemo.ContentBounds.Height + Offset;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ResizeMemo(Memo1);
end;

这篇关于我可以对包含的文本本身设置TMemo大小吗? -火猴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆