corelibraries-devexpress-dot-xtrareports-dot-parameters-dot-parameter-3a9803ed.md
Specifies a parameter value.
Namespace : DevExpress.XtraReports.Parameters
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public object Value { get; set; }
Public Property Value As Object
| Type | Description |
|---|---|
| Object |
A parameter value.
|
You can set the Value property to a static value or assign an expression to this property. Set a parameter’s Type property to the type of the assigned value.
To create a parameter in code, initialize a Parameter class instance and specify its properties. Add the parameter to the report’s Parameters collection.
The code sample below demonstrates how to create a date parameter, specify an expression for the parameter’s default value, and reference the parameter in a label‘s expression.
using System.Drawing;
using DevExpress.XtraReports.UI;
// ...
using DevExpress.XtraReports.Parameters;
// ...
using DevExpress.XtraReports.Expressions;
// ...
// Create a date report parameter.
// Use an expression to specify the parameter's default value.
var dateParameter = new Parameter() {
Name = "date",
Description = "Date:",
Type = typeof(System.DateTime),
ExpressionBindings = { new BasicExpressionBinding("Value", "Now()") }
};
// Create a label and bind the label's Text property to the parameter value.
// Use the parameter's name to reference the parameter in the label's expression.
var dateLabel = new XRLabel() {
ExpressionBindings = { new ExpressionBinding("Text", "?date") },
BoundsF = new RectangleF(0, 0, 200, 50),
};
// Create a report and add the label to the report's Detail band.
var report = new XtraReport() {
Bands = { new DetailBand() { Controls = { dateLabel } } },
};
// Add the parameter to the report's Parameters collection.
report.Parameters.Add(dateParameter);
Imports DevExpress.XtraReports.UI
' ...
Imports DevExpress.XtraReports.Parameters
' ...
Imports DevExpress.XtraReports.Expressions
' ...
' Create a date report parameter.
' Use an expression to specify the parameter's default value.
Dim dateParameter = New Parameter() With {
.Name = "date",
.Description = "Date:",
.Type = GetType(Date)
}
dateParameter.ExpressionBindings.Add(New BasicExpressionBinding("Value", "Now()"))
' Create a label and bind the label's Text property to the parameter value.
' Use the parameter's name to reference the parameter in the label's expression.
Dim dateLabel = New XRLabel() With {.BoundsF = New RectangleF(0, 0, 200, 50)}
dateLabel.ExpressionBindings.Add(New ExpressionBinding("Text", "?date"))
' Create a report and add the label to the report's Detail band.
Dim report = New XtraReport()
Dim band = New DetailBand()
band.Controls.Add(dateLabel)
report.Bands.Add(band)
' Add the parameter to the report's Parameters collection.
report.Parameters.Add(dateParameter)
'
The following code snippets (auto-collected from DevExpress Examples) contain references to the Value 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.
reporting-winforms-salary-reports/CS/SalaryReports/Reports/EmployeeReport.cs#L19
EmployeeReport report = sender as EmployeeReport;
int year = Convert.ToInt32(report.Parameters["paramYear"].Value);
int month = Convert.ToInt32(report.Parameters["paramMonth"].Value);
reporting-winforms-create-hierarchical-report-from-flat-table/CS/TreeViewReport/ChildReport.cs#L18
ChildReport childReport = new ChildReport();
childReport.Parameters["Level"].Value = this.Parameters["Level"].Value;
childReport.DataSource = parentNode.Children;
if(startDateParameter != null || endDateParameter != null || startDateParameter.Type == typeof(DateTime) || endDateParameter.Type == typeof(DateTime)) {
var startDate = (DateTime)startDateParameter.Value;
var endDate = (DateTime)endDateParameter.Value;
reporting-winforms-drill-through/CS/MasterReport.cs#L20
DetailReport detailReport = new DetailReport();
detailReport.Parameters["catId"].Value = row["CategoryID"];
detailReport.Parameters["catName"].Value = row["CategoryName"];
reporting-use-multi-value-parameter-as-table-column-chooser/CS/T333639/SampleReport.cs#L32
// Specify default lookup values.
this.Parameters["ReportColumns"].Value = new string[] { "ID", "Name", "Category", "Supplier", "UnitPrice" };
}
reporting-winforms-salary-reports/VB/SalaryReports/Reports/EmployeeReport.vb#L17
Dim report As EmployeeReport = TryCast(sender, EmployeeReport)
Dim year As Integer = Convert.ToInt32(report.Parameters("paramYear").Value)
Dim month As Integer = Convert.ToInt32(report.Parameters("paramMonth").Value)
reporting-winforms-create-hierarchical-report-from-flat-table/VB/TreeViewReport/ChildReport.vb#L19
Dim childReport As ChildReport = New ChildReport()
childReport.Parameters("Level").Value = Parameters("Level").Value
childReport.DataSource = parentNode.Children
reporting-winforms-drill-through/VB/MasterReport.vb#L22
Dim detailReport As DetailReport = New DetailReport()
detailReport.Parameters("catId").Value = row("CategoryID")
detailReport.Parameters("catName").Value = row("CategoryName")
reporting-use-multi-value-parameter-as-table-column-chooser/VB/T333639/SampleReport.vb#L31
' Specify default lookup values.
Me.Parameters("ReportColumns").Value = New String() { "ID", "Name", "Category", "Supplier", "UnitPrice" }
End Sub
reporting-web-forms-handle-server-side-errors/VB/DXWebApplication1/Reports/XtraReport1.vb#L130
'INSTANT VB NOTE: The variable startDate was renamed since Visual Basic does not handle local variables named the same as class members well:
Dim startDate_Renamed = CDate(StartDate.Value)
'INSTANT VB NOTE: The variable endDate was renamed since Visual Basic does not handle local variables named the same as class members well:
See Also