A little late to the party, but I think this can still be usefull to others. In my case I got this error because I added a combobox based on an enum like this:
// Combo
DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
combo.DataSource = Enum.GetValues(typeof(PhoneNumberType));
combo.DataPropertyName = "PhoneNumberType";
combo.Name = "PhoneNumberType";
phoneNumberGrid.Columns.Add(combo);
Now when the DataGridView created a new (empty) row, this empty value couldn't be mapped to the combo box. So instead of ignoring the error, I set the default value for the combo box. I added the event DefaultValuesNeeded
and there just set the value to one of the items from the enum. Like this:
private void phoneNumberGrid_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
{
// Prevent System.ArgumentException: DataGridViewComboBoxCell value is not valid
e.Row.Cells["PhoneNumberType"].Value = PhoneNumberType.Private;
}
.. and the exception went away.