How to add padding in a cell of a TGridPanel in Delphi?

379 Views Asked by At

I created a Delphi 10.4 VCL testing program. On the form, I created a one-row-multi-column TGridPanel and placed a TSpeedButton on column 0. The properties of column 0 are:

SizeStyle: ssAuto
Value: 50

Some properties of the TSpeedButton are:

Align: alClient
Anchors: all false
Margins: all 20
Width: 105
Height: 71

As you can see, I've added margin 20 for all 4 directions for the button. But I can't see the margin in the result.

enter image description here

How can I add some space between the button and the grid cell? You can download the project source at https://www.mediafire.com/file/x65ankhk17c7xk0/test1.rar/file. Thanks.

1

There are 1 best solutions below

0
Andreas Rejbrand On

If you want the VCL to respect your Margins, you need to set AlignWithMargins to True.

You could have realised this yourself if you had read the documentation on Margins:

Note: The Margins you set for the control have effect only when AlignWithMargins is set to true and Align is not set to alNone.