How to: Access the Report Parameters Object in Calculated Fields Expressions 如何:在计算字段表达式中访问报表参数对象

This topic describes how you can access data of a report parameters object (inherited from ReportParametersObjectBase and specified using IReportDataV2.ParametersObjectType) in calculated field expressions.

本主题介绍如何在计算字段表达式中访问报表参数对象的数据(从报表参数对象库继承并使用 IReportDataV2.参数对象类型指定)。

 

Note 注意
The approach described in this topic is not supported by the Mobile platform.
移动平台不支持本主题中描述的方法。

 

Override the Parameters Object's ToString method.

覆盖参数对象的 ToString 方法。

public class DemoParameters : ReportParametersObjectBase {
    // ...
    public override string ToString() {
        return City;
    }
}

 

As a result, you can refer to the ToString result with the "[Parameters.XafReportParametersObject]" expression, e.g.:

因此,您可以使用"[参数.XafReport参数对象]" 表达式引用 ToString 结果,例如:

Concat([Full Name],' from ', [Parameters.XafReportParametersObject])

 

Alternatively, you can create a report script, handle the GetValue event of a certain field and then access a parameter value as demonstrated in the How to: Access the Report Parameters Object in Report Scripts topic.

或者,您可以创建报表脚本,处理特定字段的 GetValue 事件,然后访问参数值,如"如何:在报表脚本中访问报表参数对象"主题中所示。

复制代码
private void calculatedFieldCity_GetValue(object sender, DevExpress.XtraReports.UI.GetValueEventArgs e) {
    DevExpress.XtraReports.Parameters.Parameter param =
            (DevExpress.XtraReports.Parameters.Parameter)
                ((DevExpress.XtraReports.UI.XtraReport)e.Report).Parameters["XafReportParametersObject"];
    if (param != null) {
        ReportV2Demo.Module.BusinessObjects.Contact contact = 
        (ReportV2Demo.Module.BusinessObjects.Contact)e.Row;
        ReportV2Demo.Module.Reports.DemoParameters xafParameter =
            (ReportV2Demo.Module.Reports.DemoParameters)param.Value;
        e.Value = contact.FullName + " from " + xafParameter.City;
    }
}
复制代码

 

posted @   code first life  阅读(251)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
历史上的今天:
2015-01-08 CSharp Similarities and Differences
2015-01-08 Nemerle Quick Guide
点击右上角即可分享
微信分享提示