DataGridView dg = sender as DataGridView; string newValue = e.FormattedValue.ToString(); if (e.ColumnIndex != 1 && e.ColumnIndex != 0) return; if (newValue != string.Empty) { int otherCell = e.ColumnIndex==0 ? 1 : 0; string sameRowValue = dg.Rows[e.RowIndex].Cells[otherCell].FormattedValue.ToString(); if (newValue == sameRowValue) { MessageBox.Show("Duplicate Currencies"); e.Cancel = true; return; } if (sameRowValue != string.Empty) { string checkA = newValue + sameRowValue; string checkB = sameRowValue + newValue; var v = from DataGridViewRow x in dg.Rows where x.Index != e.RowIndex select new { CheckA = x.Cells[0].FormattedValue.ToString() + x.Cells[1].FormattedValue.ToString() }; var matches = (from xx in v where xx.CheckA == checkA || xx.CheckA == checkB select xx).FirstOrDefault(); if (matches != null) { MessageBox.Show("Row already present"); e.Cancel = true; } } }Assuming that you know the two columns holding the currency codes (0 and 1 in the above)