Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Inserting various lines in a Static Text Control

Posted on 1998-09-10
4
Medium Priority
?
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 150 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

610 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