I am working with a DataGridView text column. The column is bound to a decimal column in a DataTable.
If I edit the cell to have an empty value and then tab out I get an exception about an issue with parsing a decimal.
I understand why this is happening and to resolve it I'd like to just force the value to be "0.00" but I can't seem to get that to work.
I tried the following but it didn't work:
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (e.ColumnIndex == amountIdx)
{
if (e.FormattedValue == "")
dataGridView1[e.ColumnIndex, e.RowIndex].Value = "0.00";
}
}
Instead of setting the value I can set e.Cancel = true but that just leaves it in edit mode which isn't what I really want.