1

我有一个由数据集填充的 datagridview。我正在尝试添加 3 列,其中包含组合框以及它们自己的数据源,这也将是一个数据集。

在这里删除 CRUD 控件是我尝试添加组合框列的方式。

Private Sub GenComboBoxColumns()
    Dim priorityTypesDS As New DataSet()
    Dim serviceBoardsDS As New DataSet()
    Dim serviceTypesDS As New DataSet()

    priorityTypesDS = _objhost.GetDataSet("SELECT DISTINCT abc FROM foo ORDER BY abc")
    serviceBoardsDS = _objhost.GetDataSet("SELECT DISTINCT abc FROM bar ORDER BY abc")
    serviceTypesDS = _objhost.GetDataSet("SELECT DISTINCT abc, xyz FROM foobar ORDER BY xyz")


    If dataGridView_monitorMapping IsNot Nothing AndAlso dataGridView_monitorMapping.Rows.Count > 0 Then
        Dim col_priority As New DataGridViewComboBoxColumn
        Dim col_serviceBoard As New DataGridViewComboBoxColumn
        Dim col_serviceType As New DataGridViewComboBoxColumn

        col_priority.DataSource = priorityTypesDS
        col_serviceBoard.DataSource = serviceBoardsDS
        col_serviceType.DataSource = serviceTypesDS

        dataGridView_monitorMapping.Columns.AddRange(col_priority, col_serviceBoard, col_serviceType)

    End If

结束子

但是,我实际上生成了许多列,这些列在 datagridview 中包含的视图区域(超过 7 列!)当它们应该只有 3 时。

为了帮助您了解我要完成的工作,请查看下面的示例。考虑一个组合框及其相应的选项,如 (foo*Bar*FooBar*) => 一个具有 3 个选项的组合框。

---------------------------------------------------------------------------------
|Apple          | (plant*animal) |  (blue*green*red*etc)  |     (smooth*rough*) |
|Steak          | (plant*animal) |  (blue*green*red*etc)  |     (smooth*rough*) |
|Peach          | (plant*animal) |  (blue*green*red*etc)  |     (smooth*rough*) |
---------------------------------------------------------------------------------

一如既往; 非常感谢您的帮助!=)

4

0 回答 0