OK, here is the code for binding combobox column along with other columns.
Note two things:
- binding column name on the combobox column is the same as value member. The names are not neccessarily the same, but values should be. That is, if you're binding status list into combobox, DataPropertyName should reference column that contains status(es) in grid datasource.
- datasource for combobox column and gridview are different (this is obvious, but still to make it clear)
Calling this code from page load - if you don't know your data at that point, you can assign datasource at a later point in time - just bind the columns with column names.
With dgv
.AutoGenerateColumns = False
.Columns(1).DataPropertyName = "quantity"
.Columns(2).DataPropertyName = "value_type"
With DirectCast(.Columns(2), DataGridViewComboBoxColumn)
.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox
.ValueMember = "value_type"
.DisplayMember = "value_type_name"
.DataSource = _source
End With
.Columns(3).DataPropertyName = "unit_price"
.DataSource = ds.Tables(1)
End With
If this helps please take time to accept the solution. Thank you.