gpt4 book ai didi

delphi - Delphi TLabel 标题中制表符的行为是否已定义?

转载 作者:行者123 更新时间:2023-12-03 02:51:52 26 4
gpt4 key购买 nike

如果我将制表符放入字符串中,然后从字符串中分配标签的 Caption 属性,制表符会做什么?

CR 字符会导致返回,这对于显示多行标题很有用。制表符似乎确实执行某种制表操作 - 我想知道这种行为是否已定义或可预测。(我猜这个行为是由 Windows 决定的,而不是 Delphi)。

最佳答案

如果将制表符放入 TLabel.Caption 中,则 Caption 包含制表符。

制表符的显示方式取决于您使用的字体和 Windows 本身。例如,在 XE 中进行快速测试,在 Win7 上显示适合制表符的间距(大约 8 个空格,采用非比例字体)。

这是我的测试。将三个标签放在表单上,​​并将其添加到表单的 OnCreate 事件中:

procedure TForm1.FormCreate(Sender: TObject);
begin
Label2.Left := Label1.Left;
Label3.Left := Label2.Left;
Label1.Caption := 'Some text'#9'Some text'#9'More text';
Label2.Caption := Label1.Caption;
Label3.Caption := Label1.Caption;
end;

这是输出:

Sample label output

关于delphi - Delphi TLabel 标题中制表符的行为是否已定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7884159/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com