XRControl.ExpressionBindings Property
Provides access to a control’s collection of expression bindings.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v21.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Property Value
Type | Description |
---|---|
ExpressionBindingCollection | An ExpressionBindingCollection object. |
Remarks
You can create a binding expression to specify a control or parameter property. Create a ExpressionBinding object and set its properties:
- EventName - the event handler that evaluates the expression. Set this property to BeforePrint or PrintOnPage. If you omit this property, the expression is evaluated in the BeforePrint event.
- PropertyName - the property that the expression applies to.
- Expression - the expression.
See Data Binding Modes for more information.
The following code example illustrates how to specify an expression to a control’s property:
// Create a label control.
XRLabel label = new XRLabel();
// Specify an expression that sets the label's Text to the current date. The expression is rendered within the BeforePrint event.
XRLabel.ExpressionBindings.Add (new ExpressionBinding("Text", "TODAY()"));
// Specify an expression that is rendered within the PrintOnPage event.
XRLabel.ExpressionBindings.Add (new ExpressionBinding("PrintOnPage","Font.Bold","true"));
The following code snippet demonstrates how to specify a custom expression for a label’s XRControl.Text property. This code assumes that a report is bound to a data source containing the UnitPrice and UnitsInStock fields.
using DevExpress.XtraReports.UI;
public XtraReport1() {
// ...
ExpressionBinding expressionBinding = new ExpressionBinding("BeforePrint", "Text", "[UnitPrice]*[UnitsInStock]");
xrLabel1.ExpressionBindings.Add(expressionBinding);
}