I couldn’t find a question on SO that exactly matched my problem.
Similar to this question and this question, I’m setting the DataSource on a DataGridViewComboBoxColumn to a list of things. In my case the things are simple types like doubles and ints, so the answers talking about ValueMembers and DisplayMembers don’t do me a lot of good. When the user selects a value I get the dreaded “DataGridViewComboBoxCell value is not valid” error.
I could swallow the error with an empty dataGridView_DataError handler, but that is obviously a bad way to go.
I found the answer here. It’s also mentioned in this answer to the second link in my question. When setting the
DataSourceto a list of anything that’s not a string, set theValueTypeof the column totypeof(<your data type>)