XRBinding(Parameter, String, String) Constructor
Initializes a new instance of the XRBinding class with the specified parameter, property name and format string.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
parameter | Parameter | A Parameter object specifying the parameter, to which a control’s property should be bound. |
propertyName | String | A String value specifying a control’s property name to bind to a parameter. This value is assigned to the XRBinding.PropertyName property. |
formatString | String | A String value specifying a format for the output value. This value is assigned to the XRBinding.FormatString property. |
Remarks
For more information on using parameters, refer to the Using Report Parameters document.
Example
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();
The following online examples illustrate how to create multi-value parameters in code: