xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-f0f5d23f.md
Provides access to a report’s collection of parameters.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
[SRCategory(ReportStringId.CatParameters)]
[PropertyGridTab(ReportStringId.UD_PropertyGrid_TabData)]
public ParameterCollection Parameters { get; }
<SRCategory(ReportStringId.CatParameters)>
<PropertyGridTab(ReportStringId.UD_PropertyGrid_TabData)>
Public ReadOnly Property Parameters As ParameterCollection
| Type | Description |
|---|---|
| ParameterCollection |
A collection of report parameters.
|
Each parameter in ParameterCollection is a Parameter object.
If the parameter is visible, Preview displays the Parameters panel to allow users to specify a parameter value (or multiple values, if the parameter’s MultiValue property is enabled).
The parameter’s Type property defines the parameter type. A specific value editor is displayed in the Parameters panel depending on the parameter type.
Disable the report’s RequestParameters property to render the report in Preview without waiting for user input.
Tip
To refer to a parameter in mail merge or within a calculated field‘s expression, specify the parameter name after the question mark (?):
?parameter_Name
This example demonstrates how to create a report with a parameter at runtime.
After a parameter is added to a report, its value can be used in the report’s filter string or displayed in a Label control.
In Preview, users can modify the parameter value in the Parameters panel.
using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Parameters;
// ...
// Create a report instance.
XtraReport report = new XtraReport();
// Create a parameter and specify its name.
Parameter parameter1 = new Parameter();
parameter1.Name = "CategoryID";
// Specify other parameter properties.
parameter1.Type = typeof(System.Int32);
parameter1.Value = 1;
parameter1.Description = "Category: ";
parameter1.Visible = true;
// Add the parameter to the report.
report.Parameters.Add(parameter1);
// Specify the report's filter string.
report.FilterString = "[CategoryID] = ?CategoryID";
// Force the report creation without previously
// requesting the parameter value from end users.
report.RequestParameters = false;
// To access a parameter from the report's Parameters collection,
// you can either use the parameter's ID
// or the parameter name.
// Both lines below have the same effect: the parameter value is set to 5.
report.Parameters[0].Value = 5;
report.Parameters["CategoryID"].Value = 5;
// Show the parameter's value on a Report Header band.
XRLabel label = new XRLabel();
label.ExpressionBindings.Add(new ExpressionBinding("Text", "'Category: ' + ?CategoryID"));
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 reportPrintTool = new ReportPrintTool(report);
reportPrintTool.ShowPreviewDialog();
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.Parameters
' ...
' Create a report instance.
Private report As New XtraReport()
' Create a parameter and specify its name.
Private parameter1 As New Parameter()
parameter1.Name = "CategoryID"
' Specify other parameter properties.
parameter1.Type = GetType(System.Int32)
parameter1.Value = 1
parameter1.Description = "Category: "
parameter1.Visible = True
' Add the parameter to the report.
report.Parameters.Add(parameter1)
' Specify the report's filter string.
report.FilterString = "[CategoryID] = ?CategoryID"
' Force the report creation without previously
' requesting the parameter value from end users.
report.RequestParameters = False
' To access a parameter from the report's Parameters collection,
' you can either use the parameter's ID
' or the parameter name.
' Both lines below have the same effect: the parameter value is set to 5.
report.Parameters(0).Value = 5
report.Parameters("CategoryID").Value = 5
' Show the parameter's value on a Report Header band.
Dim label As New XRLabel()
label.ExpressionBindings.Add(New ExpressionBinding("Text", "'Category: ' + ?CategoryID"))
Dim reportHeader As 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.
Dim reportPrintTool As New ReportPrintTool(report)
reportPrintTool.ShowPreviewDialog()
The following online examples illustrate how to create multi-value parameters in code:
View Example: How to assign multiple values to a report parameterView Example: How to assign multiple values to a report parameter from a connected data source
The following code snippets (auto-collected from DevExpress Examples) contain references 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.
// to hide the Parameters Panel in the viewer.
foreach (var parameter in report.Parameters) {
parameter.Visible = false;
Reporting-Blazor-JSBased-Viewer-Specify-Parameters/CS/BlazorApp/Services/CustomReportProvider.cs#L37
// to hide the Parameters Panel in the viewer.
foreach (var parameter in report.Parameters) {
parameter.Visible = false;
var chart = report.Bands[0].Controls[0] as XRChart;
chart.Parameters.Add(new XRControlParameter("chartCategory", report.Parameters[0]));
chart.Series[0].FilterString = "CategoryID=?chartCategory";
' Configure the chart.
chartControl1.Parameters.Add(New XRControlParameter("chartCategory", report.Parameters(0)))
chartControl1.Series(0).FilterString = "CategoryID=?chartCategory"
See Also