Back to Devexpress

XRBinding Class

xtrareports-devexpress-dot-xtrareports-dot-ui-ffb73fa9.md

latest4.2 KB
Original Source

XRBinding Class

A simple binding between the property value of an object and the property value of an instance of the XRControl class or one of its descendants.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public class XRBinding :
    IXRBinding,
    IDisposable,
    ICloneable,
    IDataContainerBase
vb
Public Class XRBinding
    Implements IXRBinding,
               IDisposable,
               ICloneable,
               IDataContainerBase

The following members return XRBinding objects:

Remarks

Use the XRBinding class to create and maintain a simple binding between an object’s property and a property of the control that represents the XRControl class or one of its descendants.

Example

The following example demonstrates how to create a binding of the XRBinding class, and add it to a control’s binding collection. The constructor method takes four arguments:

  • “Text” - the name of the control’s property to be bound,
  • dsOrders1 - the data source used,
  • “Orders.OrderDate” - a string containing a navigation path resolving to the property of an object,
  • “{0:MM/dd/yyyy}” - a string containing the bound value’s format (date/time format in this case).

Note that for this example to work correctly, a report must contain the dsOrders dataset, which should use data in the Orders table (“SELECT Orders.* FROM Orders”) from the sample Northwind database.

csharp
using DevExpress.XtraReports.UI;
// ...

public XRLabel CreateBoundLabel() {
    // Create a label.
    XRLabel label = new XRLabel();

    // Create a data binding object.
    XRBinding binding = new XRBinding("Text", dsOrders1, "Orders.OrderDate", "{0:MM/dd/yyyy}");

    // Add the data binding to the label's collection of bindings.
    label.DataBindings.Add(binding);

    return label;
}
vb
Imports DevExpress.XtraReports.UI
' ...

Public Function CreateBoundLabel()
    ' Create a label.
    Dim label As New XRLabel()

    ' Create a data binding object.
    Dim binding As New XRBinding("Text", dsOrders1, "Orders.OrderDate", "{0:MM/dd/yyyy}")

    ' Add the data binding to the label's collection of bindings.
    label.DataBindings.Add(binding)

    Return label
End Function

Implements

DevExpress.XtraReports.IXRBinding

Inheritance

Object XRBinding

See Also

XRBinding Members

Bind Report Controls to Data Using Expression Bindings

DevExpress.XtraReports.UI Namespace