简体   繁体   English

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

[英]Is the behaviour of the tab character in a Delphi TLabel caption defined?

If I put tab characters into a string and then assign the Caption property of a label from the string what do the tab characters do? 如果我将制表符放入字符串然后从字符串中分配标签的Caption属性,制表符的作用是什么?

CR characters cause a return, which is useful for displaying a multi-line caption. CR字符会导致返回,这对于显示多行标题很有用。 Tab characters do seem to perform some sort of tabbing action - I'm wondering if this behaviour is defined or predictable. Tab字符确实似乎执行某种标签操作 - 我想知道这种行为是否已定义或可预测。 (I guess the behaviour is determined by Windows, not Delphi). (我猜这种行为是由Windows决定的,而不是Delphi)。

If you put tab characters in a TLabel.Caption , the Caption contains tab characters. 如果将制表符放在TLabel.Caption ,则Caption包含制表符。

How the tab character is displayed depends on the font you use and Windows itself. 选项卡字符的显示方式取决于您使用的字体和Windows本身。 A quick test in XE, for instance, on Win7 displays spacing appropriate for tab characters (approximately 8 spaces, in a non-proportional font). 例如,在X7上的快速测试,在Win7上显示适合制表符的间距(大约8个空格,非比例字体)。

Here's my test. 这是我的考试。 Drop three labels on a form, and add this to the form's OnCreate event: 在表单上删除三个标签,并将其添加到表单的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;

Here's the output: 这是输出:

样品标签输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM