Skip to content

Instantly share code, notes, and snippets.

@Larry57
Last active December 12, 2015 05:28
Show Gist options
  • Select an option

  • Save Larry57/4721581 to your computer and use it in GitHub Desktop.

Select an option

Save Larry57/4721581 to your computer and use it in GitHub Desktop.
Returns a DataGridView height to resize it correctly
int GetDataGridViewHeight(DataGridView dataGridView)
{
var sum = dataGridView.ColumnHeadersVisible ? dataGridView.ColumnHeadersHeight : 0 +
dataGridView.Rows.OfType<DataGridViewRow>().Where(r => r.Visible).Sum(r => r.Height);
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment