如何将项目从dataGridview打印到rdlc报告。 dataGridView中的项目是手动填充的,而不是数据库填充的,这就是为什么这会给我带来问题。
p.s我知道有办法用PrintForm打印它,但我想用.rdlc打印它。
尝试使用DataTable,但它确实显示了正确的colums RDLC数据集
DataSet ds = new DataSet();
DataTable dt = new DataTable("ProdFromDGV");
foreach (DataGridViewColumn col in dataGridView1.Columns)
{
dt.Columns.Add(col.HeaderText);
}
foreach (DataGridViewRow row in dataGridView1.Rows)
{
DataRow dRow = dt.NewRow();
foreach (DataGridViewCell cell in row.Cells)
{
dRow[cell.ColumnIndex] = cell.Value;
}
dt.Rows.Add(dRow);
}
ds.Tables.Add(dt);
dt.WriteXml("table.xml");`