Like the title says, I'm trying to populate a combo box column in a datagridview.
Here's what i have so far:
Dim lc As System.Web.UI.WebControls.ListItemCollection = _
DataAccess.Part.GetListItems()
dgvcboPart.DataSource = lc
' This is a standalone combo box and it works ok
cboTest.DataSource = lc
Any suggestions as to what I'm missing ?
Thanks Tony W
have to call the databind method for the magic to happen!
I first suggest you bind your Collection to a BindingSource and then add the BindingSource to the DataGridView (so you know the position)
But binding a ComboBoxCell should be pretty much straight forward.
Let's say you have a DataTable tblCurrency containing two columns Id and Name. You have to bind this to your Column (I assume Column 0 ist your DataGridViewColumn)
Then you can set the DataPropertyName to the Property in your DataSource.
Be carful, tblCurrency.Id and Currency_Id have to be of the same Type (Int32 and UInt32 does not work) And you get a nasty MessageBox with a full StackTrace if Currency_Id has a value that is not in tblCurrency (so you should handle the DataError event)