Setting a Multi-Line Caption for a Tlabel (At Design-Time)

Young woman using laptop at work
Geber86 / Getty Images

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';

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

Instructions

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!
Format
mla apa chicago
Your Citation
Gajic, Zarko. "Setting a Multi-Line Caption for a Tlabel (At Design-Time)." ThoughtCo, Sep. 8, 2021, thoughtco.com/setting-multi-line-caption-for-tlabel-1057575. Gajic, Zarko. (2021, September 8). Setting a Multi-Line Caption for a Tlabel (At Design-Time). Retrieved from https://www.thoughtco.com/setting-multi-line-caption-for-tlabel-1057575 Gajic, Zarko. "Setting a Multi-Line Caption for a Tlabel (At Design-Time)." ThoughtCo. https://www.thoughtco.com/setting-multi-line-caption-for-tlabel-1057575 (accessed March 19, 2024).