Hi Every One,
i wrote this code in cell validating but here my problem is
i enter duplicate data delete previous enter data but what i want
which data i enter second time that data delete and cursor focus shoukd be current
cell,
if any body knows please reply me.
Thanks In advance.
private void DGV1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
//DGV1 MY DataGridView Name
for (int i = 0; i < DGV1.Rows.Count; i++)
{
for (int j = 1; j < DGV1.Rows[i].Cells.Count; j++)
{
foreach (DataGridViewRow row in DGV1.Rows)
{
if (row.Index != e.RowIndex & !row.IsNewRow)
{
if(row.Cells[j].Value.ToString() == e.FormattedValue.ToString())
{
DGV1.Rows[e.RowIndex].ErrorText = "Duplicate value not allowed ";
e.Cancel = true;
return;
}
}
}
}
}
}