'How to set TGridLayout Height based off amount of items in grid

How does one set the height of A TGridLayout to be set based off the amount of items in the grid ? I have a grid with products in it which the user can purchase and need the grids height to be set based off the amount of buttons in the grid as there are times when there are less items in the same grid. From different providers. I need the Grids height to fill up to the amount of buttons inside without cutting any buttons.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source