DataGridView error in changing ComboBox cell value

Murray Brown
Murray Brown used Ask the Experts™
on
Hi

I have a DataGridView ComboBox column where I have to programatically
change the value using the following code but I am getting the error shown in the image even though the value is the same as one of the ComboBox items

DataGridView1.Rows(0).Cells(intColumn - 1).Value = strValue

1
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
You are getting that error because the datagridviewcombobox has not got an item of that value.
Handle the DataError event of the datagridview which will make the error go away, then try again and see if you get the value set.
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
thanks. I was adding the ComboBox items programatically so the item wasn't there. My mistake

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial