0

Note before I begin.. this is what the customer wants it to look like, so if anyone has any "that's terrible UI/Style/looks/etc", I may or may not agree, but this is what they want. Opinions appreciated, but this is their request. :)

I've got a DataGridView that I've applied the SingleVertical CellBorderStyle to. I'm trying to get the vertical column separator lines to go all the way down to the end of the control, instead of ending at the last cell. Is there a way to do this without having to override OnPaint or something similar?

4

1 回答 1

0

由于您已经有了 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;
}

您可能必须从剩余高度中减去 2 点左右才能考虑控制边界。

于 2012-05-19T00:35:24.667 回答