Skip to main content
.NET Framework 4.6.2+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Access the Report Parameters Object in Calculated Fields Expressions

  • 2 minutes to read

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.

Override the Parameters Object’s ToString method.

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.:

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.

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;
    }
}
See Also