I have a DataGridView that contains a combo box (DataGridViewComboBoxColumn). This combo box is populated with a set of setup values. These setup values can be inactivated such that only active values are displayed in the combo box, however, existing entries(records) that use the inactive values must still be displayed.
I can successfully loop over the items in the grid and if a record has a value that is no longer active (i.e. part of the DataGridViewComboBoxCell items), I simply add it to the items for that DataGridViewComboBoxCell.
Problem:
I am unable to find a place to put this code such that I do not get the dreaded 'DataGridViewComboBoxCell value is not valid.'
For example, I can put this code into the Paint event of the DataGridView and the grid functions perfectly. No issues with editing/updating values nor do I have any issues in terms of display (inactive value is always shown)... However, it still throws the 'DataGridViewComboBoxCell value is not valid.' error.
Question:
Where can I add code (or how) to add an 'inactive' value after the active values have been added to the combo box (DataGridViewComboBoxColumn), but before the records are bound to avoid getting this error?