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

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