Alex Rivera | Logout

Newline character in caption of button

Asked 2011-08-02T13:32:46.537
12

I am building an application in which I want to display a button on a form. I want to display the Caption of the button on two lines. I have tried using the following code in the form's OnCreate event but it is not showing the new line.

Button.Caption := 'Hello' + #13#10 + 'world';

Any other method to add a new line?

Edit
Report

2 Answers

9

Set WordWrap to True. That's all.

answered 2011-08-02T13:56:20.373
2

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};

So if you want to make your Button wrap, make sure AutoSize is set to true, and then use the following code:

button.Caption := 'Line one'+sLineBreak+'Line two';

answered 2011-08-02T13:37:21.790

Your Answer