打印报告(Rdlc)而不查看它 [英] Print Report (Rdlc) without viewing it
问题描述
大家好,
我在窗口应用程序中使用rdlc.我正在使用带有参数作为数据源的2表适配器,并在rdlc中使用自定义分页8 X 5.5.我想打印rdlc报告而不查看它.我已经通过以下链接:
http://msdn.microsoft.com/en-us/library/ms252091 (v = VS.80).aspx [
Hi All,
I am using rdlc in my window application. I am using 2 Table Adapter with parameter as datasource and custom paging 8 X 5.5 in rdlc. I want to print rdlc report without viewing it. I have gone through the following link:
http://msdn.microsoft.com/en-us/library/ms252091(v=VS.80).aspx[^]
But, it is not best for my application.
I want efficient as well as easy code or method to print it.
Regards!
Aman
推荐答案
大家好,
我只是尝试以下概念来打印而不查看报告.
Hi All,
I just tried the following concept to print without viewing report.
DialogResult ans = MessageBox.Show("Want Print Preview?", "App Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.No)
{
Int32 OrderID = Convert.ToInt32(dgvOrders.SelectedRows[0].Cells["OrdID"].Value);
//Create a ReportViewer Control.
ReportViewer _reportviewer = new ReportViewer();
LocalReport _localReport = _reportviewer.LocalReport;
//Set the LocalReport properties for the report datasource and resource
_localReport.ReportPath = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\Jobs\\PrintOrder.rdlc";
//_localReport.ReportPath = AppDomain.CurrentDomain.BaseDirectory + "Jobs\\PrintOrder.rdlc";
this.tblOrderItemsTableAdapter.Fill(this.billDataSet.tblOrderItems, OrderID);
this.tblOrderTableAdapter.Fill(this.billDataSet.tblOrder, OrderID);
ReportDataSource _reportDataSource1 = new ReportDataSource();
_reportDataSource1.Name = "BillDataSet_tblOrder";
_reportDataSource1.Value = this.billDataSet.tblOrder;
ReportDataSource _reportDataSource2 = new ReportDataSource();
_reportDataSource2.Name = "BillDataSet_tblOrderItems";
_reportDataSource2.Value = this.billDataSet.tblOrderItems;
_localReport.DataSources.Add(_reportDataSource1);
_localReport.DataSources.Add(_reportDataSource2);
_reportviewer.RenderingComplete += new RenderingCompleteEventHandler(_reportviewer_RenderingComplete);
_reportviewer.RefreshReport();
}
else
{
FormPrntOrd _Order = new FormPrntOrd(Convert.ToInt32(dgvOrders.SelectedRows[0].Cells[0].Value));
_Order.ShowDialog(this);
}
我们可以在_reportviewer_RenderingComplete中调用_reportviewer.Print()或_reportviewer.PrintDialog(). _reportviewer应该在部分类中声明.
We can call _reportviewer.Print() or _reportviewer.PrintDialog() in _reportviewer_RenderingComplete. The _reportviewer should be declare in partial class.
这篇关于打印报告(Rdlc)而不查看它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!