I am wondering what is the best way to iterate through all the rows in a datagridview and get the values from the cells. Here's what I'm going to do, but I don't like it very much, because if I reorder the columns, then the code will need to be changed as well.
for (int i = 0; i < dataGridView.RowCount; i++) { string Value0 = dataGridView1.Rows[i].Cells[0]; string Value1 = dataGridView1.Rows[i].Cells[1]; string Value2 = dataGridView1.Rows[i].Cells[2]; }
c # winforms datagridview
skid
source share