Skip to main content
A newer version of this page is available. .

Data Binding Modes

  • 3 minutes to read

You can switch the Report Designer to the following data binding modes:

  • Expressions is the default binding mode.

    This mode enables you to specify complex expressions that include two or more data fields, report parameters, or functions. You can also use expressions to calculate summaries of any complexity or conditionally shape your data.

    Switch the Properties panel to the Expressions tab to access the properties where you can specify an expression.

    property-grid-expression-tab

    Click a property’s ellipsis button to invoke the Expression Editor. The Expression Editor allows you to use functions, access report bands and controls, and reference data source values in the constructed expression.

    expressions-page-break

  • ExpressionsAdvanced is the advanced Expression mode.

    In this mode, the Report Designer enables you to specify an expression that is evaluated within a control’s specific event.

    property-grid-expression-advanced-tab

    The Expression Editor allows you to use event argument values in the constructed expressions. Event arguments are available in the Variables section.

    Expressions Tab - Expressions Advanced Mode

    In the BeforePrint event, you can use data fields from all queries in the data source.

    Expression Editor for the BeforePrint event

    In the PrintOnPage event, data source fields are not available because data was fetched when this event occurs. You can use the event arguments that are available in the Variables section.

    Expression Editor for the PrintOnPage event

    At runtime, the BeforePrint and PrintOnPage events are fired regardless of the data binding mode.

Note

If you have the legacy Bindings mode specified in your reports, consider converting the reports to Expressions or Expressions Advanced. See Migrate from Legacy Data Bindings to Expressions for more information.

Set Binding Mode

Design Time

Use the Data Binding Mode property in the Report Designer Options dialog to select the binding mode for your reports and controls.

report-designer-options-dialog

Reload the Report Designer after you change the binding mode.

Runtime

In code, specify the static UserDesignerOptions.DataBindingMode property to select the binding mode for your reports.

static class Program {
    static void Main() {
        DevExpress.XtraReports.Configuration.Settings.Default.UserDesignerOptions.DataBindingMode = 
            DevExpress.XtraReports.UI.DataBindingMode.ExpressionsAdvanced;
        // ...
    }
}

You can specify an expression that is rendered within the BeforePrint or PrintOnPage events. Specify the following properties in the created object:

  • EventName - specifies the event handler that evaluates the expression.
  • PropertyName - defines the property to apply a binding expression to.
  • Expression - specifies the binding expression.
// 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"));
See Also