1. Home
  2. Computing & Technology
  3. Delphi Programming

Setting a multi-line Caption for a TLabel (at design-time)

By Zarko Gajic, About.com Guide

A TLabel Delphi component has a WordWrap property you can set to true in order for the text in the Caption property appear wrapped (multi-lined) when it is too long for the width of the label.

What's more, at run-time, you can use the next assignment to specify multiple lines of text for a Label:

Label1.Caption := 'First line' + #13#10 + 'SecondLine';

See: "What does #13#10 stand for, in Delphi code?"

However, you *cannot* specify multi-line text for a TLabel at design-time, using Object Inspector.

One trick to add more lines of text for a Caption property of a TLabel, at design time, is to edit the Form's .DFM file directly. Here's how:

  1. Drop a TLabel on a Form
  2. Right click the Form to activate the popup menu
  3. Select "View As Text"
  4. Locate the "object Label1:TLabel" section
  5. Change the line "Caption = 'Label1'" to:
  6. Caption = 'Label1' + #13#10 + 'Second line'
  7. Right click the code to activate the popup, again
  8. Select "View As Form"
  9. Job done! TLabel with multiple lines of text, at design-time!

Delphi tips navigator:
» Get the list of events with attached event handlers (Delphi for Win32)
« How to set up the dbGo (ADO) ConnectionString for mySQL database

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Using VCL Components
  5. TLabel, TStaticText
  6. Setting a multi-line Caption for a TLabel (at design-time)

©2009 About.com, a part of The New York Times Company.

All rights reserved.