Solved

Inserting various lines in a Static Text Control

Posted on 1998-09-10
4
186 Views
Last Modified: 2010-04-06
How can I, for a short example, add 2 texts on different lines in a Static Text control? I've tried Text1 + Chr(13) + Chr(10) + Text2, but it didn't work. Other characters, such as Chr(9), are interpreted correctly, but Chr(13) is not.

Thanks in advance
Jaime
0
Comment
Question by:skel
  • 2
4 Comments
 
LVL 2

Expert Comment

by:333
ID: 1339257
What you mean with Static Text control? If it's TLabel, then make sure the AutoSize property is set to true. I've tried this and it works:

Label1.Caption:='Text1'+#13#10+'Text2'
0
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1339258
Set AutoSize := False;
StaticText1.Caption := StaticText1.Caption + #10#13 + StaticText1.Caption;

Regareds,
Viktor Ivanov
0
 

Author Comment

by:skel
ID: 1339259
Thanks.. but I have a problem... I need to set AutoSize to true, but when, for example, I place 2 lines of text, only first line appears completely, and also a part of the second line is shown. I have this in a for loop :

Text.Caption := Text.Caption + Address + #9 + Code;
Text.Caption := Text.Caption + #9#9 + Mnemonic + #13#10;

And as I told you, only the first line and part of the second line are displayed. This always happen, even if I try to display more than 2 lines.  What can I do?

Thanks in advance
Jaime

P.S. If I set AutoSize to false, I am not able to add more lines than the size of the control. This StaticText control is placed over a Panel in order to can scroll the text using a vertical scroll bar.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339260
If you set the AutoSize to true and know exactly how many lines there are going to be then use this method....
StaticText.Caption := StaticText.Caption + #10#13+StaticText.Caption;
StaticText.Height := NumberOfTexLines * 16;
//if your caption has two lines of text then the height will be 32...2 lines * 16 = 32
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now