Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread New line in TLabel
Mon, Oct 16 2017 9:21 PMPermanent Link

KimHJ

Comca Systems, Inc

Is it possible to insert a newline in a TLabel.
I have tried Chr(10) and line1 + '#10' + line2 and '\r\n'

None are working.

I don't see a WordWrap in the TLabel.

Even I set the height to three times the Fonts height it only creates one line.

Thanks,
Kim
Tue, Oct 17 2017 1:32 AMPermanent Link

Michael Dreher

KimHJ wrote:

 // Is it possible to insert a newline in a TLabel.
 // I have tried Chr(10) and line1 + '#10' + line2 and '\r\n'
 // None are working.

I tried this with success:

Label1.Caption := 'Hallo World' + #13 + #10 + 'Line two' + #13 + #10 + 'another line';

 // I don't see a WordWrap in the TLabel.

There's a "Warp" property contained in the "Format" property of the TLabel. But this is for automatically wrapping lines for a fixed width.
M. Dreher
Tue, Oct 17 2017 4:03 AMPermanent Link

Matthew Jones

Michael Dreher wrote:

> ' + #13 + #10

It is indeed the #13 (Carriage Return) that does the business, but you need the #10 (Line feed) too for full browser compatibility. Then fiddle with the Format/Wordwrap and autosize height and width until it works as required.

If you are getting into lots of text in this way, particularly with an edit box, you are better off creating and building up a TStringList and then copying it to the output each time. This is faster and more reliable than adding to the TEdit.Text each time, as  you have to go back and forth and you may lose the end of lines, as well as it being more expensive in CPU.

--

Matthew Jones
Wed, Oct 18 2017 11:46 PMPermanent Link

KimHJ

Comca Systems, Inc

"Matthew Jones" wrote:

Michael Dreher wrote:

>> ' + #13 + #10

It is indeed the #13 (Carriage Return) that does the business, but you need the #10 (Line feed) too for full browser compatibility. Then fiddle with the Format/Wordwrap and autosize height and width until it works as required.

If you are getting into lots of text in this way, particularly with an edit box, you are better off creating and building up a TStringList and then copying it to the output each time. This is faster and more reliable than adding to the TEdit.Text each time, as  you have to go back and forth and you may lose the end of lines, as well as it being more expensive in CPU. <<

I did try with #13 + #10 as well before I posted. I did see a post that said that online #10 was required, but again none are working in the TLabel. I just need 3 lines like and address.
Kim
Thu, Oct 19 2017 2:14 AMPermanent Link

Michael Dreher

KimHJ wrote:

  // I did try with #13 + #10 as well before I posted. I did see a
  // post that said that online #10 was required, but again none
  // are working in the TLabel. I just need 3 lines like and address.
  // Kim

I've attached my example compiled with EWB 2.06B8. Try out the html file. I get multible lines in the TLabel testet with FF, IE, Chrome on windows and FF with linux.

Michael Dreher



Attachments: Example.zip
Thu, Oct 19 2017 12:09 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< I've attached my example compiled with EWB 2.06B8. Try out the html file. I get multible lines in the TLabel testet with FF, IE, Chrome on windows and FF with linux. >>

Just to confirm that this is correct - EWB requires #13+#10 for manual line feeds.  It does it this way to be consistent with Windows/Delphi.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Oct 19 2017 10:47 PMPermanent Link

KimHJ

Comca Systems, Inc

Michael Dreher wrote:

>>I've attached my example compiled with EWB 2.06B8. Try out the html file. I get multible lines in the TLabel testet with FF, IE, Chrome on windows and FF with linux.<<

Thanks Michael.

In my Windows Delphi applications I make all line feeds like this: line1 + #13#10 + line2 and I got an compiler error when I tried in EWB.
Then some where in the support forum I read that I had to do this: line1 + '#13' + '#10' + line2 and that just made the line into: line1#13#10line2.

In the mean time I changed it into a TMultiLineEdit and load all lines into a TStringList then assigned the TStringList to Lines and made the TMultiLineEdit ReadOnly := True.

Kim
Fri, Oct 20 2017 1:14 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Kim,

<< In my Windows Delphi applications I make all line feeds like this: line1 + #13#10 + line2 and I got an compiler error when I tried in EWB. >>

Yes, EWB requires that you concatenate characters and strings with the + operator.

Tim Young
Elevate Software
www.elevatesoft.com
Image