/// <summary>
        /// 设置报表
        /// </summary>
        private void SetReport()
        {
            if (reportModel != null)
            {
                if (ReportSource.Count > 0) ReportSource.Clear();
                if (this.reportViewer1.LocalReport.DataSources.Count > 0) this.reportViewer1.LocalReport.DataSources.Clear();               
                ReportSource.Add(reportModel);               
                this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("SMAccidentInfo_SimpleReport", ReportSource));
              
                this.reportViewer1.LocalReport.Refresh();
                this.reportViewer1.RefreshReport(); 
              
            }        } private void tsbPrint_Click(object sender, EventArgs e)
        {
            try
            {
                
                SetReport();
                this.reportViewer1.PrintDialog();
              
            }
            catch (Exception ex)
            {
                Sys_Error.WriteError(this, ex);
            }
        }捕捉到 System.InvalidOperationException
  Message="对象的当前状态使该操作无效。"
  Source="Microsoft.ReportViewer.WinForms"
  StackTrace:
       在 Microsoft.Reporting.WinForms.ReportViewer.PrintDialog()
       在 Report.FrmSimpleReport.tsbPrint_Click(Object sender, EventArgs e) 位置 

解决方案 »

  1.   

    rdlc不熟悉
    你用得是c/s还是b/s
      

  2.   

    这是因为SetReport();的时候会加载报表,而报表还没有加载完就调用了this.reportViewer1.PrintDialog();引起的
    调用RefreshReport的时候,报表会加载数据并绘制(没有深入了解,怀疑这个地方不是在主进程里面进行的,所以就直接执行PrintDialog(),而不是等待数据加载完成后再执行PrintDialog(),从而导致错误)
      

  3.   

    Me临时解决办法.加入一个timer1控件在reportviewer1的RenderingComplete事件
    timer1.start()在timer1的Tick事件
    me.ReportViewer1.PrintDialog()以上可以解决提示出错的问题.
    感觉出错的原因是数据未加载完所致的.望有高手能切底解决这一个问题.