-3
複数の列を持つDataTableがあり、VisualBasicのDataGridViewにそのすべての行のデータを含む列の一部をインポートしたいと考えています。 私を助けてもらえますか?Visual BasicでDataTableの特定の列をインポートします。
複数の列を持つDataTableがあり、VisualBasicのDataGridViewにそのすべての行のデータを含む列の一部をインポートしたいと考えています。 私を助けてもらえますか?Visual BasicでDataTableの特定の列をインポートします。
あなたの質問は非常に一般的です。いずれの場合もここにサンプルがあります。
'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