In datagridview how to find out the cell is empty when iam leaving the cell,if it is empty i want to handle that cell,i.e ristrict the user go forward.if data fill user can go forword normally,how can acheave this task.
Asked
Active
Viewed 95 times
1 Answers
0
in the event of DataGridView
CellValidating
or RowValidating
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (dataGridView1.IsCurrentCellDirty)
if (e.ColumnIndex == 0)
{
if (string.IsNullOrWhiteSpace(dataGridView1[e.ColumnIndex, e.RowIndex].EditedFormattedValue.ToString()))
{
e.Cancel = true;
MessageBox.Show("Please enter some text before you leave.");
}
else
{
//Some logic here
}
}
}

spajce
- 7,044
- 5
- 29
- 44
-
then you can mark my post +1 as a useful answer and welcome :) – spajce Dec 15 '12 at 05:46