Click here to Skip to main content
16,008,075 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a DataGridView with columns as a DataGridViewComboBoxColumn.

VB
Dim cImageCate As New DataGridViewComboBoxColumn
           dTable = FillCombo("SELECT_ON_CODE", "ImageCategory")
           cImageCate.DisplayMember = "Description"
           cImageCate.ValueMember = "ID"
           cImageCate.DataSource = dTable
           cImageCate.DataPropertyName = "Image Category"
           cImageCate.Name = "Image Category"
           cImageCate.HeaderText = "Image Category"
           cImageCate.DefaultCellStyle.NullValue = "Lineart"
           cImageCate.FlatStyle = FlatStyle.Flat
           dtGrdImageDetails.Columns.Add(cImageCate)


While binding DataSource to DGV

dtGrdImageDetails.DataSource = dTable

I am getting Error message as "system.formatexception datagridviewcomboboxcell value is not valid".

How to bind DataSource to DGV which will get the respective values selected in DataGridViewComboBoxColumn Cell
Posted
Updated 16-Dec-13 1:06am
v3
Comments
Gaurav Makwana 16-Dec-13 6:37am    
datagridview1.datasource = datatable;

use for loop for combobox understood?
rajgaikwad01 16-Dec-13 8:01am    
Hi Gaurav,

Thanks for reply.
Is there any other option to fill DGV with DataGridViewComboBoxColumn.
Because use of for loop will lower down the application performance in my case.
because I have editable grid which will interact with the Database.
ShridharPanigrahi 16-Dec-13 9:40am    
This error seems like what is been binded to combo box is different from the "ValueMember" and "DisplayMember" fields.
Can you check if the dTable contains these columns?

-Shridhar P.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900