I\'m trying to run this code, and I get an exception:
Index was out of range. Must be non-negative and less than the size of the collection. Param
You are just missing one line :-P
DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridView1); // this line was missing row.Cells[0].Value = "Cell1"; row.Cells[1].Value = "Cell2"; dataGridView1.Rows.Add(row);