?
Solved

Inserting various lines in a Static Text Control

Posted on 1998-09-10
4
Medium Priority
?
195 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 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