以编程方式 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"

我需要做的就是为组合框添加一个处理程序以选择第一个填充的值。

有人有想法吗?

只需使用源中的第一项设置值即可。

dgvcbc.Value = cListItems(0)

最新更新