Friday, May 15, 2020

Setting a Multi-Line Caption for a TLabel in Delphi

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. Whats 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 Forms .DFM file directly. Heres how: Drop a TLabel on a FormRight click the Form to activate the popup menuSelect View As TextLocate the object Label1:TLabel sectionChange the line Caption Label1 to:Caption Label1 #13#10 Second lineRight click the code to activate the popup, againSelect View As FormJob done! TLabel with multiple lines of text, at design-time!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.