Given that I want my string grid to have equal height rows ...
I know that it will start with exactly 5 rows and I make it so at design time.
At run time I may want to add some extra rows (and I have code to not add below the bottom of the parent; at that point I rely on scroll bars).
It seems that sg.height := sg.height + sg.RowHeights[0]; is not producing the expected result - there is unexpecetd whitespace after the last row (I am still trying to calculate how the extra height corresponds to the number of rows, but it looks like it is the height of one row, no matter how many rows are in the grid).
Is there something else I should take into account? (perhaps GridLineWidth?) Or could I have set a property wrongly in the Object Inspector? Should I be using GridHeight, rather than Height?
Note: this problem only occurs when the stringgid is as wide as all cells and the scroll bar appears, drawing over part of the last column. If I leave an ugly blank sapce at the right of the string grid for the scroll bar to fit into, the problem does not occur.
Can anyone tell me the formula to calculate the new gridheight after adding a number of rows? Or wthere I am doing something wrong.
[Update] The fudge factor of 3 apears to correspond to the margin property
. Here is an image of a TMS AdvStringGrid. I think it is largely based on an ordinary string grid with a lot of useful extensions. To make it easier to count rows, I magnified the image using SnagIt and made the pixel gridlines visible. I added some red lines to the top row of the grid. On this grid, the DefaultRowHeight is set to 21. Between the red lines, there are 5 pixels each so to get 21 pixels for the DefaultRowHeight you would have to include the stringgrid gridline which has a height of 1 pixel. When I load this grid, I use this code: