How to avoid gridpanel last row take higher than others? I have 10 rows with 10 percent value
If I append a new row with 0 percent the prior row which tend to be the last row take the right height but a new row borders
appears at the bottom which I don't desire
When
SizeStyle=ssPercent
the size calculation includes adouble
value (the percentage). InVCL
the result must be rounded to a whole number (= pixels). The code usesTrunc()
, presumably to assure that the number of rows fit into theGridPanel
. Then, the excess pixels (if any) are "given" to the last row.Instead of
SizeStyle=ssPercent
you can useSizeStyle=ssAbsolute
and define the row heights as number of pixels. In this case the calculation does not include float values and there's no need for rounding. In this case you can declare the height of each row e.g. 28 an if the height ofGridPanel1
is 280, then all rows are of equal height.You can select
SizeStyle
in the IDE (Object Inspector) by selecting allTRowItem
in the structure pane underRowCollection
.You can define these settings also at runtime.
Edit after comment
If you use
SizeStyle=ssPercent
, you need to make a choise between the two cases you show in your question.If you use
SizeStyle=ssAbsolute
, you can use theTGridPanel1.OnResize()
event to recalculate the item heights:In addition, if the color of the
GridPanel1
is the same as that of the form, you may want to set theGridPanel1.BevelOuter=bvNone
which hides the border line of theGridPanel1
and the empty space that appears beneath the rows (whentoth
is not evenly divisable) becomes unnoticeable.