A way to set New line/ Linebreak in a TWebLabel caption?

74 views Asked by At

Usually one would set it like this at runtime:

Label1.Caption := 'First line' + #13#10 + 'SecondLine';

but for some reason, this does not seem to work even if you turn WordWrap on or off.

What is the solution to create a linebreak in TMS Web Core at runtime?

1

There are 1 answers

0
Shaun Roselt On

First note. You can use sLineBreak instead of #13#10. sLineBreak is a constant defined in the System unit:

const
   sLineBreak = {$IFDEF POSIX} _AnsiStr(#10) {$ENDIF}
       {$IFDEF MSWINDOWS} _AnsiStr(#13#10) {$ENDIF};

If you're using TMS WEB Core v2.3.2 or newer, then linebreaks should work perfectly fine, but older versions don't have support for linebreaks. So you're obviously using an old version of TMS WEB Core.

So either update your TMS WEB Core to the latest version or follow the answer below for older versions.


If you have an older version of TMS WEB Core before v2.3.2, then you can use the following:

WebLabel1.ElementHandle.innerHTML := 'First line' + '<br>' + 'SecondLine';

The <br> is the linebreak and that works:

Button, Label, Memo