首页 文章

将项添加到datagridview comboBox列中现有的组合框单元格

提问于
浏览
1

如何在datagridview组合框列中将项添加到现有的组合框单元格中 . ProductGrid是dataGridView .

With ProductGrid
         Dim objSerialNumber As New DataGridViewTextBoxColumn
        With objSerialNumber
            .Name = "SerialNumber"
            .HeaderText = "SerialNumber"
            .Visible = False
            .Width = lGridWidth * 1.2
        End With
        .Columns.Add(objSerialNumber)
       End With

还有另一个功能,我必须在SerialNumber comboBox中添加项目 . 我必须添加的项目是数组 . 如果已经添加到ComboBox列中,将使用哪行代码从comboBox中删除项目 .

4 回答

  • 1

    通常,combobox add item命令适用,而不是使用DatagridviewCombobox Cell Name

    dgvcomb.Items.Add("30")
    
  • 0

    我以这种方式解决了上述问题 . gSerialNumberArray包含我必须添加的项目 .

    Dim cbCell As New DataGridViewComboBoxCell
    
        For k = 0 To ProductGrid.Rows.Count - 1
            cbCell = ProductGrid.Rows(k).Cells("SerialNumber")
            For iIndex = 0 To UBound(gSerialNumberArray)
                cbCell.Items.Add(gSerialNumberArray(iIndex))  
            Next
        Next
    
  • 0

    Column4.Items.Add(tds1.Tables(0).Rows(ij).Item(0))

  • 0

    您还可以使用:

    cbCell.Items.AddRange(strArray)

    如果您已将项目加载到数组中,则会在下拉列表中加载所有项目 . 如果从数据库表中收集它们,请使用arraylist函数将数据库项加载到列表中,然后将数组列表转换为数组 .

相关问题