首页 新闻 会员 周边 捐助

winfrom 中ReportViewer 问题

0
[已解决问题] 解决于 2016-03-08 17:18

软件开起来然后点击预览没有问题,然后关闭预览窗口后,再次预览,第一页就会消失,是什么问题啊?》

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;      }

 

问题补充:

只要预览过,第一页就会没。软件关闭了,再打开预览第一页是有的,是不是资源占用的问题呢?

夜星冷的主页 夜星冷 | 初学一级 | 园豆:71
提问于:2014-01-08 13:20
< >
分享
最佳答案
0

我记得ReportViewer有个Refresh的方法,你加在SetReport的第一行。

奖励园豆:5
水晶途途 | 小虾三级 |园豆:1443 | 2014-01-09 10:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册