-
August 12th, 2010, 03:37 PM
#1
DataGridViewComboBoxCell value is not valid
Using VS2010 and VS2008
I have a DataGridView bound to a DataTable which has an Int16 DataColumn. The DGV has a DataGridViewComboBoxColumn tied to the DataColumn.
I enter integer values in the Items section of the DGVCBColumn properties. When I run the program I get "DataGridViewComboBoxCell value is not valid".
I assume this is because my Items are text and the data column is integer so I created a List of Integer, added my integer values/choices to the list and made the List my data source for the ComboBox column. Same error.
I then created another DT in the DS with one column type Int16, added my integer choices to the DT, created a BS for the ChoicesDT and set this BS as the DataSource, the column as the DisplayMember and the ValueMember. Same error.
There are no issues like this when the DataColumn is bound to a ComboBox outside of the DGV so I assume there is some issue with the DGV understanding the underlying binding.
I have read some solutions that include trapping and discarding the error but would like something cleaner if anyone has it.
thx
-
August 12th, 2010, 04:32 PM
#2
Re: DataGridViewComboBoxCell value is not valid
-
October 25th, 2010, 12:25 AM
#3
Re: DataGridViewComboBoxCell value is not valid
Try to set AutoSizeColumnsMode to none
-
April 4th, 2012, 06:42 AM
#4
Re: DataGridViewComboBoxCell value is not valid
Hi Wirah,
That worked for me!
You saved me a LOT of time with this fix, I would never have thought to change the AutoSizeColumnsMode, as I thought it was an error relating to the content of the databinding.
Also worth noting that you can also use the "Fill" AutoSizeColumnsMode. (Probably because those modes are not data-dependant).
Thanks again,
Wodge
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|