我知道这是一个已经被回答了数千次的基本问题,但我无法让它发挥作用。
我正在使用 Visual Studio 2010,并且我的 Windows 应用程序中有两个表单。在第一个(Main.vb)中,用户输入他的输入并进行计算。在第二个 (DataAnalysis.vb) 中显示计算结果。
在 Main.vb 中,我创建了包含所有中间计算步骤的临时表:
Dim tableTempJDL As DataTable = New DataTable("TempJDL")
Dim column As DataColumn
column = New DataColumn("ID", GetType(System.Int32))
tableTempJDL.Columns.Add(column)
column = New DataColumn("PthObjekt", GetType(System.Double))
tableTempJDL.Columns.Add(column)
'further columns are after created using the same method
然后,在 DataAnalysis.vb 中,我尝试将 DataTable tableTempJDL
显示到 DataGridViewBerechnung
中:
Public bindingSourceBerechnung As New BindingSource()
Me.DataGridViewBerechnung.DataSource = Me.bindingSourceBerechnung
但是我不明白如何填充 DataGridView...
最佳答案
简单地,您可以通过以下方式将您的表作为绑定(bind)源的数据源:
Me.bindingSourceBerechnung .DataSource = tableTempJDL
稍后,您可以通过以下方式在 datagridview 中绑定(bind)上述绑定(bind)源:
Me.DataGridViewBerechnung.DataSource = Me.bindingSourceBerechnung
关于vb.net - VB : How to bind a DataTable to a DataGridView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12141519/