Can I assign the values to datagridview cells at a time like
datagridview1[0,0].value = “zero column zero row”
datagridview1[1,0].value = “first column zero row”
datagridview1[0,1].value = “zero column first row”
datagridview1[1,1].value = “first column first row”
It gives error Index was out of range. Must be non-negative and less than the size of the collection.
Try this:
There is some “magic” that takes places behind the scenes. According to the MSDN document for the Cells property:
By specifying the
ColumnCountand calling theRows.Addmethod the the DataGridView has enough meta information to automatically create new Rows when directly accessing the Cells property.