📅  最后修改于: 2022-03-11 14:56:32.134000             🧑  作者: Mango
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;
}
}