Modify the Datagridviewcombobox element programmatically VB.NET

Dim cListItems As New System.Collections.Generic.List(Of Combobox_values)
                If ds.Tables("items_prices").Rows(0).Item("item_selldozen") > 0 Then
                    Dim item_selldozen As String = ds.Tables("items_prices").Rows(0).Item("item_selldozen")
                    cListItems.Add(New Combobox_values("Dozen", item_selldozen))
                End If

                Dim dgvcbc As DataGridViewComboBoxCell = DirectCast(CType(main.ActiveMdiChild, discount_new_discount).discountitems_new_discount.Rows(last_row).Cells(3), DataGridViewComboBoxCell)
                dgvcbc.DataSource = cListItems 'Fill cListItems
                dgvcbc.DisplayMember = "Text"
                dgvcbc.ValueMember = "Value"

      

All I need to do is add a handler for the combobox to select the first of the filled values.

Does anyone have any idea?

+3


source to share


1 answer


Just set the value using the first element from the source.



dgvcbc.Value = cListItems(0)

      

0


source







All Articles