M
Miro
I am getting an error removing columns from a datagridview.
I have a dataset created at runtime and a table with columns that are also
created at runtime.
The columns are based on other data.
When a button clicks, I want to reset the whole datagridview ( by removing
all the columns ) so I can add
a whole set of new columns to the list based on some parameters.
I can seem to delete the first column but the code gets an exception on the
'next' line.
For Each griddatacol As DataGridViewColumn In dgvTourneyLeaders.Columns
dgvTourneyLeaders.Columns.Remove(griddatacol.Name)
'dgvTourneyLeaders.Columns.Remove(griddatacol) 'same error
Next
System.InvalidOperationException was unhandled by user code
Message="Collection was modified; enumeration operation may not execute."
Thanks,
Miro
I have a dataset created at runtime and a table with columns that are also
created at runtime.
The columns are based on other data.
When a button clicks, I want to reset the whole datagridview ( by removing
all the columns ) so I can add
a whole set of new columns to the list based on some parameters.
I can seem to delete the first column but the code gets an exception on the
'next' line.
For Each griddatacol As DataGridViewColumn In dgvTourneyLeaders.Columns
dgvTourneyLeaders.Columns.Remove(griddatacol.Name)
'dgvTourneyLeaders.Columns.Remove(griddatacol) 'same error
Next
System.InvalidOperationException was unhandled by user code
Message="Collection was modified; enumeration operation may not execute."
Thanks,
Miro