You may have to use CellEndEdit Event
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.ColumnIndex == 0)
for (int row = 0; row < dataGridView1.Rows.Count-1; row++)
{
if (dataGridView1.Rows[row].Cells[0].Value != null &&
row != e.RowIndex &&
dataGridView1.Rows[row].Cells[0].Value.Equals(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value))
{
MessageBox.Show("Duplicate");
} else
{
}
}
}
catch (Exception ex)
{
}
}