DataGrid - Working with Cells and Rows
void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
// Ignore cell if it's not dirty
if (dataGridView.isCurrentCellDirty)
return;
// Validate current cell.
}
void dataGridView_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
// Ignore Row if it's not dirty
if (!dataGridView.IsCurrentRowDirty)
return;
// Validate all cells in the current row.
}
void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
// Validate all cells in the current row and return if any are invalid.
// If they are valid, save changes to the database
// This is when I would expect dataGridView.IsCurrentRowDirty to be false.
// When this row loses focus it will trigger RowValidating and validate all
// cells in this row, which we already did above.
}
https://stackoverflow.com/questions/2043210/datagridview-row-is-still-dirty-after-committing-changes