DataGridView を DataTable に変換したい。
using (DataTable dt = new DataTable())
{
dt.Columns.Add("column1", typeof(int));
dt.Columns.Add("column2", typeof(string));
dt.Columns.Add("column3", typeof(int));
foreach (DataGridViewRow dgvR in dgQBM)
{
dt.Rows.Add(dgvR.Cells[0].Value, dgvR.Cells[1].Value);
}
}
エラー:
foreach statement cannot operate on variables of type
'System.Windows.Forms.DataGridView' because 'System.Windows.Forms.DataGridView'
does not contain a public definition for 'GetEnumerator'