I am building an application in which I want to display a button on a form. I want to display the Caption of the button on two lines. I have tried using the following code in the form’s OnCreate event but it is not showing the new line.
Button.Caption := 'Hello' + #13#10 + 'world';
Any other method to add a new line?
For very old Delphi versions which do not have the WordWrap property:
Use following code prior to setting the caption:
But the tricky part is that this code needs execution on a number of occasions. When the button is recreated, then your multiline setting is lost. Kind of similar to this dilemma.
Luckily the VCL provides a solution, but you have to subclass the TButton type, e.g. as follows: