问题描述
我想创建一个跨多行的字符串来分配给标签标题属性。如何在Delphi中完成?
在System.pas(自动使用)中定义了以下内容: p>
const
sLineBreak = {$ IFDEF LINUX} AnsiChar(#10){$ ENDIF}
{$ IFDEF MSWINDOWS} AnsiString(#13#10){$ ENDIF};
这是从Delphi 2009(注意使用AnsiChar和AnsiString)。 (由我添加的换行符)
所以如果你想使你的TLabel换行,确保将AutoSize设置为true,然后使用以下代码: p>
label1.Caption:='Line one'+ sLineBreak +'Line two';
在sLineBreak引入之后,所有版本的Delphi都可以使用,我相信是Delphi 6。 >
I want to create a string that spans multiple lines to assign to a Label Caption property. How is this done in Delphi?
In the System.pas (which automatically gets used) the following is defined:
const
sLineBreak = {$IFDEF LINUX} AnsiChar(#10) {$ENDIF}
{$IFDEF MSWINDOWS} AnsiString(#13#10) {$ENDIF};
This is from Delphi 2009 (notice the use of AnsiChar and AnsiString). (Line wrap added by me.)
So if you want to make your TLabel wrap, make sure AutoSize is set to true, and then use the following code:
label1.Caption := 'Line one'+sLineBreak+'Line two';
Works in all versions of Delphi since sLineBreak was introduced, which I believe was Delphi 6.
这篇关于如何在Delphi中的字符串中添加换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!