Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi TGridLayout layout and padding between items

I have gotten some results trying to use TGridLayout to hold series of TImage object each with a bitmap loaded. However, there is no margin between the cotrols. I have already tried to make the TImage width/height smaller than TGridLayout itemheight/itemwidth, but no luck.

Example code:

ImageRef := TImage.Create(GridLayoutGallery);
ImageRef.Visible := False; // se true later
ImageRef.Width := GridLayoutGallery.ItemWidth - 10;
ImageRef.Height := GridLayoutGallery.ItemHeight - 10;
GridLayoutGallery.AddObject(ImageRef);
like image 749
Tom Avatar asked Jul 18 '26 01:07

Tom


1 Answers

You were close to an answer yourself, here is how I would achieve this:

Lets say your Grid holds a series of Images with a size of 40 x 40 px

enter image description here

To apply the margin between the images simply set the ItemWidth and ItemHeight properties of the TGridLayout component to a value larger then the size of the actual image, for example 42 x 42 px.

enter image description here

This should create a margin around every Image placed in the TGridLayout.

like image 81
Peter Avatar answered Jul 20 '26 15:07

Peter