Как сравнить значения столбцов dataggridview1 и datagridview2 в каждой строке
int x = 0; int y = 0; int i = -1; int z = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { i++; if ((dataGridView1.Rows[i].Cells[i].Value) == (dataGridView2.Rows[i].Cells[i].Value)) { x++; } else { y++; } if (z < dataGridView2.Rows.Count) { z++; } if (z == dataGridView2.Rows.Count) { z--; //subtract 1 from the total count because the datagrid is 0 index based. } MessageBox.Show("Matched: " + x.ToString() + "\r\n" + "Not Matched: " + y.ToString());
Что я уже пробовал:
Need code to show if one datagridview has different string than the other by columns. Gridview 1 Gridview2 Col1 Col1 John John match Mark Sam Don't match This is the code I'm trying to get in C# windows for to compare two data Gridviews