我想知道爲什麼我的報告不會出現在報告查看器中? 我使用這段代碼從我的主窗體的listview中生成我的報告。Crystal Report將不會出現在Crystal ReportViewer
沒有運行時錯誤,它不會出現在報告查看器中。
public void PrintDVDList(frmMain frmMain)
{
try
{
var Report = new rptDVDList();
DataRow row = null;
DataSet DS = new DataSet();
DataTable DT = new DataTable();
DS.Tables.Add("tblDVDInventory");
var _with1 = DS.Tables[0].Columns;
_with1.Add("ItemCode");
_with1.Add("Title");
_with1.Add("Genre");
_with1.Add("Film");
_with1.Add("YearReleased");
_with1.Add("Classification");
_with1.Add("NumberOfDiscs");
foreach (ListViewItem LVI in frmMain.lvwInventory.Items)
{
row = DS.Tables[0].NewRow();
row[0] = LVI.Text.ToString();
row[1] = LVI.SubItems[1].Text.ToString();
row[2] = LVI.SubItems[2].Text.ToString();
row[3] = LVI.SubItems[3].Text.ToString();
row[4] = LVI.SubItems[4].Text.ToString();
row[5] = LVI.SubItems[5].Text.ToString();
row[6] = LVI.SubItems[6].Text.ToString();
DS.Tables[0].Rows.Add(row);
}
var frmReportDVDList = new frmReportDVDList();
Report.SetDataSource(DS.Tables[0]);
frmReportDVDList.crvDVDList.ReportSource = Report;
frmReportDVDList.crvDVDList.Refresh();
}
catch (Exception error)
{
MessageBox.Show(error.ToString());
}
}