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

XRBinding(String, Object, String) Constructor

Initializes a new instance of the XRBinding class with the specified property name, data source and data member.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v20.2.dll

NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Reporting.Core

Declaration

public XRBinding(
    string propertyName,
    object dataSource,
    string dataMember
)

Parameters

Name Type Description
propertyName String

A String value specifying a control’s property name to bind to a data field. This value is assigned to the XRBinding.PropertyName property.

dataSource Object

A Object class descendant, which specifies a data source to provide data for a control’s property. This value is assigned to the XRBinding.DataSource property.

dataMember String

A String value, which specifies a navigation path to a data field in a data source. This value is assigned to the XRBinding.DataMember property.

Remarks

To learn which objects can be passed as a dataSource parameter to this constructor, refer to the Bind Reports to Data document.

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 demo Northwind database (nwind.mdb file located in the directory, where you installed DevExpress demos).

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;
}
See Also