Data binding 在Visual Basic中导入数据表的特定列
我有一个包含多个列的DataTable,我想将其中的一些列及其每一行的数据导入VisualBasic中的DataGridView。Data binding 在Visual Basic中导入数据表的特定列,data-binding,datagridview,import,Data Binding,Datagridview,Import,我有一个包含多个列的DataTable,我想将其中的一些列及其每一行的数据导入VisualBasic中的DataGridView。 你能帮帮我吗?你的问题非常笼统。无论哪种情况,这里都有一个示例 'Create a new datatable Dim table2 As New DataTable table2.Columns.Add("Name") 'loop through your existing datatable - add the records to
你能帮帮我吗?你的问题非常笼统。无论哪种情况,这里都有一个示例
'Create a new datatable
Dim table2 As New DataTable
table2.Columns.Add("Name")
'loop through your existing datatable - add the records to the columns you want
For Each dr As DataRow In Table1.Rows
Dim R As DataRow = dt.NewRow
R("Name") = dr("TABLE1_COLUMNNAME")
dt.Rows.Add(R)
Next
'turn the new datatable into the datagridview.
DataGridView1.DataSource = table2