I ran into a very similar problem on a DataGridView with a DataGridViewComboBoxColumn .
DataGridView bound to a DataSet The parameters of the DataGridViewComboBoxCell drop-down list must be filled in accordance with the value of another cell of the same row.
Whether I manually fill in the elements of the ComboBox cell (the DataGridViewComboBoxCell.Items property) or use the DataBinding property ( DataGridViewComboBoxCell.DataSource ), right before entering the CellFormatting event CellFormatting values are correct, but as soon as the steps in the handler are myComboBoxCell.Items.Count , myComboBoxCell.Items.Count omitted.
If the cell value is something other than DBNull.Value , this causes the unpleasant value of "System.ArgumentException: DataGridViewComboBoxCell" is invalid. "(Since myComboBoxCell.Value not contained in myComboBoxCell.Items )
My “solution” is more circumventing: I am handling the DataGridView.DataError event and populating the corresponding DataGridComboBoxCell DataSource inside this handler. Then throw the exception ( e.ThrowException = False ).
It is too dirty to my taste, but it works.
source share