如何在打印控件中加载报表文件? - DevExpress

时间:2014-04-27 13:17:34

标签: winforms devexpress xtrareport

我创建了报告(XtraReport)并将报告工具PrintBarManagerPrintControl拖到表单中。现在我需要将该报告加载到PrintControl。怎么加载?帮我。 我尝试了这段代码,但显示错误 - Object reference is not set to instance of object

var test = new XtraReport1();
printControl1.Container.Add(test);  // Object reference not set to instance of object
test.ShowPreview();

我尝试了这段代码但显示了 - Best overloaded method match.....

var test = new XtraReport1();
printControl1.Controls.Add(test);  // Best overloaded method, invalid arguments
test.ShowPreview();

如何将报告加载到PrintControl?

1 个答案:

答案 0 :(得分:2)

使用以下代码:

//Set the printing system
printControl.PrintingSystem = report.PrintingSystem;
//Create and build your report
XtraReport1 report = new XtraReport1(); 
report.CreateDocument();

P.S。请查看How to: Add a Print Preview to a Windows Forms Application指南。