How to grow/shrink TDBAdvGrid to fit data?

After I execute the query associated with a TDBAdvGrid I would like the height  of a second grid to shrink ( if there are fewer records to display now or to grow if tehre aremore.

When it grows, I would like to specify a maximum number of rows, or max height, so as to fit my form. I probably also need to add/remove scrollbars depending on how many rows.

What I have is a master / detail with 2 grids of one column each. When the user clicks a row of the first grid, the second should resize if necessary, to avoid showing empty rows, which looks ugly.

Is there a coding example of this?

Sorry, unfortunately we do not have a ready to use sample for this specific request. In fact it is the first time we receive such request. I'd suggest to determine the nr. of records in the dataset and then set grid.Height = Min(MaxHeight, NrOfRecords * rowheight);

Plus also the lines between.

When I work out the formula, I will post it here.   Thansk for replying, Bruno