datagridview combobox cell value is not valid how to fix code example
Example: datagridview combobox cell value is not valid how to fix
if (e.Exception.Message == "DataGridViewComboBoxCell value is not valid.")
{
object value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (!((DataGridViewComboBoxColumn)dataGridView1.Columns[e.ColumnIndex]).Items.Contains(value))
{
((DataGridViewComboBoxColumn)dataGridView1.Columns[e.ColumnIndex]).Items.Add(value);
e.ThrowException = false;
}
}