Posted by Lee p12462 on January 28, 2009
In Reply to Re: Setting StringGrid.Height posted by webmaster Guido on
January 28, 2009
: : I have a StringGrid that I populate on the fly. Once I'm done populating it, I want
to set the .height property such that the bottom border is just below the [possible horizontal scroll
bar and] last line in the StringGrid. When I click the button with the following code, the bottom border
ends up below row 7 out of 10 rows. I'm guessing it is because I am summing the height of the characters
but not the space above and below the horizontal lines. Is there some other property(s) I should be
summing to get the results I want?
: : (...)
:
: Well, the total height of a StringGrid component is influenced by:
: Grid.RowCount,
Grid.DefaultRowHeight,
Grid.RowHeights, its "Bevels" (borders), etc...
: So, it's not easy to calculate the exact total height. I'm testing some combinations, just
give me some time ;)
: Unless... you agree with an approximation that at least shows all or most of the rows, but sometimes
with a vertical scrollbar?
Thanks Guido!
Well, it isn't scientific but, I experimented by just adding a "fudge factor" for each line. I found
by adding 8 to the StringGrid1.Canvas.TextHeight for each row, it comes close enough for what I need!
Don't spend much time on this but if you come up with something close, I'd like to see it. Having a vertical scroll bar would be OK :-)
Thank you very much for your time and effort :-)
Lee
Related articles
Follow Ups