I have a DataGridView in C# and I want to add rows in a programmatic way. There is no data bound to the grid but when I call dataGrid.Rows.Add(); it throws a System.InvalidOperationException.
I looked all over the internet and I only found this problem for people who have data bound to it. I want the grid to be controlled completely from the code.
Could anyone help me with this please?
Not sure if it makes a difference but I use .Net framework 3.5.
I usually go with answers provided by other people but this is not the case since the answers aren’t really helpful.
As I stated “dataGridView1.Rows.Add();” threw an exception and so did AddRange.
I found out the answer after doing a lot of checks. Apparently .Net does not like it if I add a lot of rows/second (about 30).
I receive my rows via networking so I created a pool of rows and every second I updated the rows from the datagridview.
This seems to have fixed both the rows not showing up and the exceptions.
Thank you for the input anyway!