我有一个由数据集填充的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
End Sub
然而,我实际上生成了许多列,这些列在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*) |
---------------------------------------------------------------------------------
一如既往;非常感谢帮助! =)