C#では、ReportViewerのレポートに画像を動的に渡します.-自動印刷

1200 ワード

  private void frmReport_Load(object sender, EventArgs e)
        {
                this._reportViewer.Reset();
                this._reportViewer.LocalReport.ReportPath = "LabelTemplate.rdlc";

         

                _reportViewer.ProcessingMode = ProcessingMode.Local;
                ReportDataSource dsSource = new ReportDataSource("ds", LabelModels);
                this._reportViewer.LocalReport.DataSources.Clear();
                this._reportViewer.LocalReport.DataSources.Add(dsSource);
                this._reportViewer.ShowParameterPrompts = false;
                this._reportViewer.RefreshReport();
                this._reportViewer.RenderingComplete += new RenderingCompleteEventHandler(PrintLabelDirectly);
            //}
        }
        public void PrintLabelDirectly(object sender, RenderingCompleteEventArgs e)
        {
            try
            {

                _reportViewer.PrintDialog();
                _reportViewer.Clear();
                _reportViewer.LocalReport.ReleaseSandboxAppDomain();
                this.Close();
            }
            catch (Exception ex)
            {
            }
        }