我知道這是一個已經回答了幾千次的基本問題,但我無法完成它的工作。VB:如何將DataTable綁定到DataGridView?
我在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,我嘗試顯示數據表tableTempJDL
到DataGridViewBerechnung
:
Public bindingSourceBerechnung As New BindingSource()
Me.DataGridViewBerechnung.DataSource = Me.bindingSourceBerechnung
但我不知道如何填寫在DataGridView ...
[如何:將數據綁定到Windows窗體DataGridView控件(HTTP以下列方式的BindingSource的://msdn.microsoft.com/en-us/library/fbk67b6z.aspx) –
@TimSchmelter我問這個問題之前,我讀了這個,但我不能讓它工作。另一個很好的例子是在MSDN上:[如何:將數據綁定到Windows窗體DataGridView控件](http://msdn.microsoft.com/en-us/library/fbk67b6z(v = vs.100).aspx)。但是這個使用外部數據庫並需要使用連接字符串。 – Nicolas