Solved

Inserting various lines in a Static Text Control

Posted on 1998-09-10
4
190 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 330
delphi exception 7 64
Best Firemonkey component pack 1 100
Delphi: how to implement a User Shortcut mapper? 1 107
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

815 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

8 Experts available now in Live!

Get 1:1 Help Now