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);
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
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.

This should create a margin around every Image placed in the TGridLayout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With