Thanks for this info. Could you post the link to the other forum for complete code?
Also, I think I'm trying to do something different than you show here. Although, in the end I want the same result. I want to be able to select a value in the first datagridcombobox and have it then provide a subset in the second datagridviewcombobox.
I tried to start with a datagridview control that already has two datagridviewcombobox columns. But I want to populate them by setting their datasource property dynamically at runtime. I can of course use the dataset/tableadapter/bindingsource approach, but I was trying for something more lightweight than that.
So, I retrieve a dataresultset as shown below and I set the datagridviewcombobox properties in some event (say Form.Load event for example). This code will work fine with a comboboxcontrol outside of the grid. But when it is set up as I have it below, it fails to populate the combobox in the grid.
Code Block
Using connection As New SqlCeConnection(My.Settings.dbLookup)
Dim comboboxColumn As DataGridViewComboBoxColumn = DataGridView1.Columns.Item("sectionNumber")
Dim command As SqlCeCommand = New SqlCeCommand("SELECT secNum, secNumDescFROM lookupNumbers", connection)
connection.Open()
Dim catResult As SqlCeResultSet = command.ExecuteResultSet(ResultSetOptions.Scrollable)
comboboxColumn.DataSource = catResult
comboboxColumn.ValueMember = "secNum"
comboboxColumn.DisplayMember =
"secNumDesc"
End Using
This will return an error "No data exists for the row/column"
Same error occurs if I build a new datagridviewcomboboxcolumn and then do a datagridview1.columns.add
I don't want to build the combobox with Items.add since the datasource will have two columsn, one display and one value.
I guess my major disconnect here is trying to treat the datagridviewcombobox as a standard form combobox control. And maybe not understanding the event model of the datagridview well enough to understand the populating of said column.