zoukankan      html  css  js  c++  java
  • How to: Use the Custom Report Preview Form 如何:使用自定义报表预览窗体

    This example demonstrates how to show a custom Report Preview form by handling the ReportServiceController.CustomShowPreview event.

    此示例演示如何通过处理报表服务控制器。自定义显示预览事件来显示自定义报表预览窗体。

    Note 注意
    Mobile applications do not support the report preview mechanism, so the approach described in this topic cannot be implemented in the Mobile platform.
    移动应用程序不支持报表预览机制,因此本主题中描述的方法无法在移动平台中实现。

    In this topic, it is assumed that you have an XAF application that uses the Reports V2 Module, and you have created one or more reports (see Reports V2 Module Overview).

    在本主题中,假定您有一个使用报表 V2 模块的 XAF 应用程序,并且您创建了一个或多个报表(请参阅报表 V2 模块概述)。

    Use the following Controller to display a report preview in a custom window (the CustomPreviewForm form, in this example).

    使用以下控制器在自定义窗口中显示报表预览(在此示例中为自定义预览窗体)。

    using DevExpress.XtraReports.UI;
    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.ReportsV2;
    // ...
    public class CustomPreviewController : ViewController {
        private ReportServiceController reportServiceController;
        protected override void OnActivated() {
            base.OnActivated();
            reportServiceController = Frame.GetController<ReportServiceController>();
            if (reportServiceController != null) {
                reportServiceController.CustomShowPreview += reportServiceController_CustomShowPreview;
            }
        }
        void reportServiceController_CustomShowPreview(object sender, CustomShowPreviewEventArgs e) {
            IReportContainer reportContainer = 
                ReportDataProvider.ReportsStorage.GetReportContainerByHandle(e.ReportContainerHandle);
            reportServiceController.SetupBeforePrint(reportContainer.Report, 
                e.ParametersObject, e.Criteria, e.CanApplyCriteria, e.SortProperty, e.CanApplySortProperty);
            CustomPreviewForm form = new CustomPreviewForm();
            form.ShowReport(reportContainer.Report);
            e.Handled = true;
        }
        protected override void OnDeactivated() {
            if (reportServiceController != null) {
                reportServiceController.CustomShowPreview -= reportServiceController_CustomShowPreview;
            }
        }
    }

    The CustomPreviewForm form can be designed as described in the following tutorials:

    • Adding Items to a Print Preview's Standard Toolbar
    • Adding Items to a Print Preview's Ribbon Toolbar

    自定义预览表单窗体可以按照以下教程中的说明进行设计:

    • 将项目添加到打印预览的标准工具栏
    • 将项目添加到打印预览的功能区工具栏

    When the CustomPreviewForm is ready, add the ShowReport method to it.

    当自定义预览表单准备就绪时,向其添加显示报表方法。

    public void ShowReport(XtraReport report){
        documentViewer1.DocumentSource = report;
        report.CreateDocument();
        Show();
    }

    In this example, documentViewer1 is the DocumentViewer component added to the current form.

    在此示例中,文档Viewer1 是添加到当前窗体的文档查看器组件。

    Tip 提示
    Refer to the API and Customization section in the XtraReports documentation to learn more about report preview customization.
    请参阅 XtraReports 文档中的 API 和自定义部分,了解有关报表预览自定义的详细信息。
  • 相关阅读:
    任何优秀的程序员, 都有早逝的风险
    租车App第一次迭代报告
    快租车app——需求分析心得
    结对编程——自动生成数学试卷的系统(javaswing,mysql)by 陈松&刘宇航
    结队编程之——阅读分析队友的代码(C++自动生成数学试卷)
    自动生成不同难度的数学试卷系统,并输出到txt文件中,命名为当前时间(java)
    代码之美——浅谈命名规则与代码优化
    关于防抖和节流
    关于sessionStorage和localstorage的一些记录
    vue应用微信二维码登录的一些记录
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Use-the-Custom-Report-Preview-Form.html
Copyright © 2011-2022 走看看