Mega Code Archive

 
Categories / Delphi / VCL
 

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

Title: 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: Drop a TLabel on a Form Right click the Form to activate the popup menu Select "View As Text" Locate the "object Label1:TLabel" section Change the line "Caption = 'Label1'" to: Caption = 'Label1' + #13#10 + 'Second line' Right click the code to activate the popup, again Select "View As Form" Job done! TLabel with multiple lines of text, at design-time!