How to: Specify the Default Name for User-Defined Reports 如何:指定用户定义的报表的默认名称

This example demonstrates how to change the default name of user-defined reports in WinForms and ASP.NET applications. Mobile applications do not allow user to create a new report in runtime, so the approach described in this topic cannot be implemented in the Mobile platform.

此示例演示如何更改 WinForms 和ASP.NET应用程序中的用户定义报表的默认名称。移动应用程序不允许用户在运行时创建新报表,因此本主题中描述的方法无法在移动平台中实现。

 

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 模块概述)。

 

In the Module.cs (Module.vb) file, override the ModuleBase.Setup method and handle the static ReportServiceController.QueryRootReportComponentName event to change the default name of user-defined reports. In the event handler, assign the new name to the Name parameter and set the Handled parameter to true.

在Module.cs (module.vb) 文件中,重写 ModuleBase.安装程序方法并处理静态报表服务控制器.查询根报表组件名称事件以更改用户定义的报表的默认名称。在事件处理程序中,将新名称分配给 Name 参数并将 Handled 参数设置为 true。

using DevExpress.ExpressApp.ReportsV2;
// ...
public override void Setup(XafApplication application) {
    ReportServiceController.QueryRootReportComponentName +=
        delegate(object sender, QueryRootReportComponentNameEventArgs e) {
        e.Handled = true;
        e.Name = "MyNewReport";
    };
    base.Setup(application);
}

 

The result is demonstrated in the image below.

结果如下图所示。

WinForms:

ReportsV2_QueryRootReportComponentName

ASP.NET:

ReportsV2_QueryRootReportComponentName_Web

 

posted @ 2020-01-10 14:37  code first life  阅读(205)  评论(0编辑  收藏  举报