软件开起来然后点击预览没有问题,然后关闭预览窗口后,再次预览,第一页就会消失,是什么问题啊?》
code:
预览按钮:
DataSet ds = GetDs();
ds.Tables[1].TableName = "NewDataSet_CustToProDtl";
frmReportsViewer frm = new frmReportsViewer(ds, System.Windows.Forms.Application.StartupPath + @"\Reports\CustToPro.rdlc", "");
ReportParameter[] rptParams = SetReportParameter(ds);
frm.RvReportViewer.LocalReport.SetParameters(rptParams);
ReportDataSource rds_OrderDtl = new ReportDataSource("NewDataSet_CustToProDtl", ds.Tables[1]);
frm.RvReportViewer.LocalReport.DataSources.Add(rds_OrderDtl);
frm.RvReportViewer.RefreshReport();
frm.ShowDialog();
这个预览winfrom页面---------------------------------------------
public frmReportsViewer(DataSet ds, String reportName, String formName) { InitializeComponent();
SetReport(ds, reportName, formName);
}
public void SetReport(DataSet ds, String reportName, String formName) { try
{ this.RvReportViewer.Clear();
this.Text = formName + "预览";
this.RvReportViewer.ProcessingMode = ProcessingMode.Local; this.RvReportViewer.LocalReport.ReportPath = reportName; this.RvReportViewer.LocalReport.DataSources.Clear();
for (int i = 0; i < ds.Tables.Count; i++) { RvReportViewer.LocalReport.DataSources.Add(new ReportDataSource(ds.Tables[i].TableName, ds.Tables[i])); } this.RvReportViewer.ZoomMode = ZoomMode.Percent; this.RvReportViewer.ZoomPercent = 100; this.RvReportViewer.RefreshReport();
} catch (Exception ex)
{ MessageBox.Show(ex.Message.ToString());
}
}
private void frmReportsViewer_Load(object sender, EventArgs e) {
this.RvReportViewer.RefreshReport();
this.RvReportViewer.SetDisplayMode(DisplayMode.PrintLayout); this.RvReportViewer.ZoomMode = ZoomMode.Percent; this.RvReportViewer.ZoomPercent = 100; }
只要预览过,第一页就会没。软件关闭了,再打开预览第一页是有的,是不是资源占用的问题呢?
我记得ReportViewer有个Refresh的方法,你加在SetReport的第一行。