I've got a form with a DataGridView thats bound to an business Object that inherits a bindinglist. Note the DGV is not bound direct to a database.
I've got it working well using text boxes, but now need to add a ComboBox in the first viewable column.
Currently, the columns are set using the VB IDE and I've set the first viewable one to be a DataGridViewComboBoxColumn.
When form loads, it calls a function that sets the datasource of the DGV to an Object, then sets the dataPropertyName of each column to the various properties of the Object-BindingList
myPurchaseOrderItems.getCPOItems(myPurchaseOrder.id)
dgvPurchaseOrderItems.AutoGenerateColumns = False
dgvPurchaseOrderItems.DataSource = myPurchaseOrderItems
dgvPurchaseOrderItems.Columns(0).DataPropertyName = "cpo_id"
dgvPurchaseOrderItems.Columns(1).DataPropertyName = "id"
dgvPurchaseOrderItems.Columns(2).DataPropertyName = "product_code"
dgvPurchaseOrderItems.Columns(3).DataPropertyName = "description"
etc
The first two columns are not visible. I have a property called product_code that will fill the Product Column OK if I set the Product Code Column to a DataGridViewTextBoxColumn.
However, when I set the column to DataGridViewComboBoxColumn in the IDE. I get a System.ArgumentException: DataGridViewComboBoxCell value is not valid. Not surprising as I havent populated the ComboBox.
How can I populate it?
I've seen Adding and Populating DataGridViewComboBoxcolumn to Bound Datagridview
but this looks like its adding a new column to a DGV. I dont want to do that as I already have the column setup via the IDE and have given it its value.
I can generate a bindinglist with the values that the combobox should have, or just use the results of a sql query. I just dont know how to fill it.
Thanks!