Skip to main content
A newer version of this page is available. .

XtraReport.Parameters Property

Provides access to a report’s collection of parameters.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v20.1.dll

NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Reporting.Core

Declaration

[SRCategory(ReportStringId.CatParameters)]
[PropertyGridTab(ReportStringId.UD_PropertyGrid_TabData)]
public ParameterCollection Parameters { get; }

Property Value

Type Description
ParameterCollection

A ParameterCollection object, specifying a collection of report parameters.

Remarks

The Parameters property provides access to the collection of report parameters.

Each parameter in this collection is represented by a Parameter object.

The Parameter.Type property defines the parameter type. When the report is being previewed, a Print Preview displays a user interface for specifying parameter values according to the parameter type.

You can disable the XtraReport.RequestParameters property to start creating a report document on loading a Print Preview without waiting for an end-user’s input.

To avoid showing the UI for submitting parameter values in a Print Preview, disable the ReportPrintTool.AutoShowParametersPanel property of a ReportPrintTool, to which the report is assigned (or, disable the XtraReportPreviewModel.AutoShowParametersPanel property of an XtraReportPreviewModel in the case of a WPF reporting application).

Tip

To refer to a parameter when using the mail merge or within a calculated field‘s expression, the parameter’s name should be specified after the question mark (?):

?parameter_Name

See the following examples online to learn how to create multi-value parameters in code:

Example

This example demonstrates how to create a report with a parameter at runtime.

After a parameter is added to the report, its value can be used in the report’s XtraReportBase.FilterString, or displayed in a XRLabel control.

Then, when the report is being previewed, an end-user can modify the parameter’s value via the Parameters UI, which is enabled using the ReportPrintTool.AutoShowParametersPanel property.

using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Parameters;
// ...

private void simpleButton1_Click(object sender, EventArgs e) {
    // Create a report instance.
    XtraReport1 report = new XtraReport1();

    // Create a parameter and specify its name.
    Parameter param1 = new Parameter();
    param1.Name = "CatID";

    // Specify other parameter properties.
    param1.Type = typeof(System.Int32);
    param1.Value = 1;
    param1.Description = "Category: ";
    param1.Visible = true;

    // Add the parameter to the report.
    report.Parameters.Add(param1);

    // Specify the report's filter string.
    report.FilterString = "[CategoryID] = ?CatID";

    // Force the report creation without previously 
    // requesting the parameter value from end-users.
    report.RequestParameters = false;

    // Show the parameter's value on a Report Header band.
    XRLabel label = new XRLabel();
    label.DataBindings.Add(new XRBinding(param1, "Text", "Category: {0}"));
    ReportHeaderBand reportHeader = new ReportHeaderBand();
    reportHeader.Controls.Add(label);
    report.Bands.Add(reportHeader);

    // Assign the report to a ReportPrintTool,
    // to hide the Parameters panel,
    // and show the report's print preview.
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.AutoShowParametersPanel = true;
    pt.ShowPreviewDialog();
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Parameters property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also