所以,我试图将datagridview的内容显示到datareport中。但是在通过数据集链接报告后,生成的报告是空白的,代码在这里:
Dim dt As New DataTable
With dt
.Columns.Add("Roll")
.Columns.Add("Name")
End With
For Each row As DataGridViewRow In DataGridView1.Rows
dt.Rows.Add(DataGridView1.Rows(1).Cells(0).Value, DataGridView1.Rows(1).Cells(1).Value)
Next
Form2.ReportViewer1.LocalReport.DataSources.Item(0).Value = dt
Form2.ShowDialog()
感谢任何帮助。谢谢!
答案 0 :(得分:0)
Dim rds As New ReportDataSource("YourDataSet", dt)
Form2.ReportViewer1.LocalReport.DataSources.Clear()
Form2.ReportViewer1.LocalReport.DataSources.Add(rds)
Form2.ReportViewer1.RefreshReport()