我想通过将当前数据源合并到新数据表来将多个数据表添加到数据源,而无需每次创建(循环)数据集。
这是我的代码:
' Those table are the same but have different data
' Tables() array, it's an example
For Each oTable As System.Data.DataTable In Tables
DisplayResult(oTable, ColumnsAreCreated)
Next
然后我想在网格中显示结果:
Private Function DisplayResults(ByVal oTable As System.Data.DataTable, ByRef ColumnsAreCreated As Boolean) As Boolean
If oTable.Rows.Count > 0 Then
Dim compt As Integer = 0
If Not ColumnsAreCreated Then
Dim NewColumn As DevExpress.XtraGrid.Columns.GridColumn
For Each oColumn As DataColumn In oTable.Columns
NewColumn = grdv.Columns.AddField(oColumn.ColumnName)
NewColumn.OptionsColumn.ReadOnly = True
NewColumn.Visible = True
NewColumn.VisibleIndex = compt
compt += 1
Next
ColumnsAreCreated = True
' I want to do something like : grdctrl.DataSource += oTable
grdctrl.DataSource = oTable
grdv.OptionsView.ColumnAutoWidth = False
grdv.BestFitColumns()
End If
End If
Return True
End Function
我不想每次都擦除当前数据,我想将网格中的当前数据源与以下数据表一一连接。
我不想创建数据集,将数据表放入其中,最后提供数据集的 gridcontrol。
有没有办法在不创建数据集的情况下做到这一点?