如何在表单中设置现有模板的打印预览?

时间:2014-02-12 08:17:00

标签: winforms devexpress report

我现在在查找编辑(下拉列表)中显示3个报告,如果他选择任何一个报告,我需要以相同的形式显示预览如何显示?

2 个答案:

答案 0 :(得分:1)

您需要使用devexpress的documentviewer控件。

将选定的报告对象传递给文档查看器。

按照以下教程

http://documentation.devexpress.com/#xtrareports/CustomDocument2668

答案 1 :(得分:1)

试试这个:

使用PrintControl在我正在执行的表单中显示您的报告..:

PrintControl control = new PrintControl();
SomeForm.Controls.Add(control);

/// Put this code to show report in Printcontrol at SomeForm
public void SetReport(XtraReport report)
{
            if (report != null)
            {
                control.PrintingSystem = report.PrintingSystem;
                SetupButtonVisability();
                report.CreateDocument();
                report.RecreateDocumentMap();                
                control.PrintingSystem = report.PrintingSystem;              
            }
}

您也可以使用以下文档链接填充打印视图的另一种方法:
How to: Invoke a Report's Print Preview

   XtraReport1 report = new XtraReport1();

    using (ReportPrintTool printTool = new ReportPrintTool(report)) {
        // Invoke the Print Preview form modally, 
        // and load the report document into it.
        printTool.ShowPreviewDialog();

        // Invoke the Print Preview form
        // with the specified look and feel setting.
        printTool.ShowPreview(UserLookAndFeel.Default);
    }