既然你已經有了SingleVertical CellBorderStyle,你可以用一個大空白最後一行填充剩下的空間:
//calculate the space already filled by column headers and rows
int currentContentHeight = Grid.ColumnHeadersHeight;
for (int i = 0; i < Grid.Rows.Count; i++)
{
currentContentHeight += Grid.Rows[i].Height;
}
//then calculate the space remaining
int remainingHeightToEndOfControl = Grid.Height - currentContentHeight;
//then fill it with one big blank final row:
if (remainingHeightToEndOfControl > 0)
{
Grid.Rows.Add();
Grid.Rows[Grid.Rows.Count - 1].Height = remainingHeightToEndOfControl;
}
您可能需要從remainingHeight扣除2點左右,考慮到控制邊界。
來源
2012-05-19 00:35:24
Dil