我有一个包含多个列的DataTable,我想将一些列的每行数据导入VisualBasic中的DataGridView。 你能帮我吗?
答案 0 :(得分:0)
你的问题非常通用。无论哪种情况,这里都是一个样本。
'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