[ popmilan76 @ 29.05.2017. 21:51 ] @
Imam dve tabele,i treba da mi budu oznacene crvenom bojom isti podaci,polje koje je indeticno je rbr...imam ovaj kod,i on radi kada idem samo redom,ali kada se prebacim na neki peti red,onda zacrveni sledeci i ako nije duplikat.... private void UporediDveTabele(object sender, EventArgs e) { //use the currentRow to compare against for (int currentRow = 0; currentRow < dataGridView1.Rows.Count - 1; currentRow++) { DataGridViewRow rowToCompare = dataGridView1.Rows[currentRow]; //specify otherRow as currentRow + 1 for (int otherRow = currentRow + 1; otherRow < dataGridView2.Rows.Count; otherRow++) { DataGridViewRow row = dataGridView2.Rows[otherRow]; bool duplicateRow = true; //compare cell ENVA_APP_ID between the two rows if (!rowToCompare.Cells["rbr"].Value.Equals(row.Cells["rbr"].Value)) { rowToCompare.DefaultCellStyle.BackColor = Color.Red; rowToCompare.DefaultCellStyle.ForeColor = Color.Black; duplicateRow = false; break; } //highlight both the currentRow and otherRow if ENVA_APP_ID matches if (duplicateRow) { rowToCompare.DefaultCellStyle.BackColor = Color.Red; rowToCompare.DefaultCellStyle.ForeColor = Color.Black; row.DefaultCellStyle.BackColor = Color.Red; row.DefaultCellStyle.ForeColor = Color.Black; } } } } gde gresim |