Reputation: 83
Is there any faster way other than looping through each column and increment a variable with their width?
For now this is the best solution, but is pretty slow:
int contentWidth = 0;
foreach (DataGridViewColumn column in grid.Columns) {
contentWidth += column.Width;
}
Upvotes: 0
Views: 829
Reputation: 83
This will return the length of visible columns:
contentWidth = grid.Columns.GetColumnsWidth(DataGridViewElementStates.Displayed);
Upvotes: 1