Search code examples
delphimultilineword-wrap

Delphi - Show a multiline caption in the designer


I am replacing in runtime the Caption of several components to get a multiline Caption.

MySpeedButton.Caption := 'Line 1' + #13 + #10 + 'Line 2';

Is there a way to persuade Delphi to show a wordwrap also in the designer?


Solution

  • You can force the caption of a TSpeedButton to be multiline by editing the caption in Text View of the form:

      object SpeedButton1: TSpeedButton
        Left = 8
        Top = 63
        Width = 113
        Height = 50
        Caption = 'Line 1Line 2'       // original caption
        Caption = 'Line 1'#10'Line 2'  // modified caption
      end
    

    Note! You must add the two single quotes on both sides of the #10. Instead of #10 you can use #13 or both #13#10.

    For an ordinary TButton you need to set the WordWrap property in addition to the above modification to the Text View of the form.