xtrareports-devexpress-dot-xtrareports-dot-ui-e7eff557.md
Provides functionality to expression bindings.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public class ExpressionBinding :
BasicExpressionBinding,
ICloneable
Public Class ExpressionBinding
Inherits BasicExpressionBinding
Implements ICloneable
The following members return ExpressionBinding objects:
A collection of ExpressionBinding objects is returned by the XRControl.ExpressionBindings property.
An expression enables you to specify a property value for a control or a parameter.
To create an expression binding for a report control, create an ExpressionBinding object, specify its properties, and add the ExpressionBinding object to the XRControl.ExpressionBindings collection.
The ExpressionBinding constructor needs the following arguments:
EventNameThe name of the event whose handler evaluates the expression. Typically you should set this property to the “BeforePrint” (the BeforePrint event) or “PrintOnPage” (the PrintOnPage event) string. If you omit this property, the expression is evaluated in the BeforePrint event. You can use the [Arguments.PageIndex] value to get the current page index in the expression evaluated in the PrintOnPage event.PropertyName The property to which the expression applies.Expression A binding expression that is parsed and processed to specify a control or parameter’s property value.
The following code snippet specifies an expression for a control’s property:
using DevExpress.XtraReports.UI;
public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport {
public XtraReport1() {
InitializeComponent();
XRLabel label = new XRLabel();
this.Report.Bands[BandKind.Detail].Controls.Add(label);
label.LeftF = 100;
label.TopF = 100;
// Specify an expression that sets the label's Text to the current date. The expression is rendered within the BeforePrint event.
label.ExpressionBindings.Add(new ExpressionBinding("Text", "TODAY()"));
// Specify an expression that makes the text bold on the first page.
label.ExpressionBindings.Add(new ExpressionBinding("PrintOnPage", "Font.Bold", "Iif([Arguments.PageIndex] == 0, true, false)"));
}
}
Imports DevExpress.XtraReports.UI
' ...
Public Class XtraReport1
Public Sub New()
InitializeComponent()
' Create a label control.
Dim label As New XRLabel()
Me.Detail.Controls.Add(label)
label.LeftF = 100
label.TopF = 100
' Specify an expression that sets the label's Text to the current date. The expression is rendered within the BeforePrint event.
label.ExpressionBindings.Add(New ExpressionBinding("Text", "TODAY()"))
' Specify an expression that makes the text bold on the first page.
label.ExpressionBindings.Add(New ExpressionBinding("PrintOnPage", "Font.Bold", "Iif([Arguments.PageIndex] == 0, true, false)"))
End Sub
End Class
The following code specifies a custom expression for the label’s XRControl.Text property. The code assumes that the report is bound to a data source with UnitPrice and UnitsInStock fields.
using DevExpress.XtraReports.UI;
public XtraReport1() {
// ...
ExpressionBinding expressionBinding = new ExpressionBinding("BeforePrint", "Text", "[UnitPrice]*[UnitsInStock]");
xrLabel1.ExpressionBindings.Add(expressionBinding);
}
Imports DevExpress.XtraReports.UI
Public Sub New()
' ...
Dim expressionBinding As New ExpressionBinding("BeforePrint", "Text", "[UnitPrice]*[UnitsInStock]")
xrLabel1.ExpressionBindings.Add(expressionBinding)
End Sub
Review the following topic for more information: Data Binding Modes.
Object BasicExpressionBinding ExpressionBinding
See Also