【问题标题】:How to display a Devexpress XtraReport on button click in c# wpf application如何在 c# wpf 应用程序中单击按钮时显示 Devexpress XtraReport
【发布时间】:2020-08-26 14:57:42
【问题描述】:

我在我的 wpf 应用程序中创建了一个 devexpress XtraReport 文件。使用报表向导中的自定义 Sql 查询将数据加载到报表中。 如何在 xaml 用户控件屏幕中显示按钮单击报告?

目前我正在尝试显示如下:

private void GenerateZBReport_Click(object sender, RoutedEventArgs e)
{
    XtraReport report = new XtraReport();
    DocumentPreviewWindow window = new DocumentPreviewWindow();
    window.PreviewControl.DocumentSource = report;
    report.CreateDocument(true);
    window.ShowDialog();
}

【问题讨论】:

    标签: c# wpf devexpress xtrareport document-preview


    【解决方案1】:

    使用位于用户控件或窗口中的DocumentPreviewControl。如果您想要自定义预览控件,这将特别有用。此功能在以下帮助文件中进行了描述:Create a Custom Document Preview。否则,您可以使用 PrintHelper 类:Invoke a Default Document Preview

    【讨论】:

      【解决方案2】:

      在您的代码中,您使用了 XtraReport 类,但该类是空的。 你应该 创建类型化报表类

      new XtraReport1()
      

      或通过调用加载布局

      var report = new XtraReport();
      report.LoadLayout(filePath);
      

      只有在此之后,您才能将其分配给查看器并调用 CreateDocument() 方法

      【讨论】:

        【解决方案3】:

        我认为这会有所帮助:

        var tool = new ReportPrintTool(report);
        tool.ShowPreview();
        

        欲了解更多信息,请查看此链接: Report viewer in XtraReports C#.Net using Winforms Devexpress?

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-02-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多