A newer version of this page is available. Switch to the current version.

Bind a Report to an Object Data Source

  • 4 minutes to read

This tutorial describes how to bind a report to an object data source defined in a separate class within a Visual Studio project.

Create a Project and Prepare a Data Source

Perform the following steps before creating a new data-bound report:

  1. Start Microsoft Visual Studio 2010, 2012, 2013, 2015 or 2017, and open an existing application or create a new one.
  2. Add a class containing the data source definition (for instance, the Fishes.cs file in this tutorial).


  3. Add the DevExpress.DataAccess assembly to your project's references list. Right-click the References item in the Solution Explorer and select Add Reference. In the invoked Reference Manager, switch to the Extensions tab, enable this assembly's checkbox and click OK.


  4. Highlight the added class and a data member using the HighlightedClassAttribute and HighlightedMemberAttribute as demonstrated in the code below.

    using System.Collections.Generic;
    using System.ComponentModel;
    using System.IO;
    using DevExpress.DataAccess.ObjectBinding;
    // ...
    public class Fishes : List<Fish> {
        public Fishes(string filePath) {
            if(File.Exists(filePath)) {
                using(Stream stream = File.OpenRead(filePath)) {
    // ...
  5. Open the AssemblyInfo.cs file in the project's Properties directory. You can find the AssemblyInfo.vb file in the My Project directory in Visual Basic projects.


  6. Apply the HighlightedAssemblyAttribute to the current assembly to add it to the relevant assemblies list.

    using DevExpress.DataAccess.ObjectBinding;
    // ...
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: HighlightedAssembly]
    // ...
  7. Rebuild the solution.

Run the Wizard and Access the Data Source

Do the following to run the Report Wizard and bind a report to an object data source:

  1. Select Add New Item in the PROJECT menu or press CTRL+SHIFT+A to invoke the Add New Item dialog. In this dialog, choose the DevExpress v18.2 Report item and click Add.

  2. In the invoked Report Wizard, select Table Report and click Next to proceed.


  3. On the next wizard page, choose the Object option and click Next.


  4. The following wizard page allows you to select an assembly that contains the data source's class type definition. Use the Show only highlighted assemblies checkbox to exclude irrelevant assemblies from this list.


  5. On the next wizard page, select a data source type. Enable the Show only highlighted types checkbox to hide irrelevant classes from this list.


  6. The next wizard page enables you to select whether to obtain the data source schema (enabling you to edit the report layout without having access to the actual underlying data) or retrieve the actual data from the data source.


    Proceed to the Adjust the Report Layout section (the first option), or continue to the next section's steps (the second option).

Retrieve the Actual Data

Perform the steps described below to retrieve the actual data from a custom object data source. The wizard skips these steps when you choose to obtain the data source schema only.

  1. On the following wizard page, select a data source constructor and click Next. Use the Show only highlighted constructors checkbox to exclude irrelevant constructors from this list.


  2. The next wizard page allows you to specify the constructor parameters.

    Enabling the checkbox in the Expression column allows you to specify the parameter expression (using the Expression Editor), as well as pass an existing report parameter to the constructor (or create a new report parameter using the in-place editor).


Follow the steps in the next section to continue with the report layout customization.

Adjust the Report Layout

Perform the steps below to construct the required report layout:

  1. On the following wizard page, select which data fields the report should display and click Next.


  2. The next page allows you to group report data against one or more fields using the arrow buttons. You can click Next to skip this step.


  3. On the final wizard page, specify the report title and click Finish.


The Field List reflects the data source structure after wizard completion.


View the Result

The Design Surface displays the resulting report layout:


The following image shows the report document in Print Preview.


Customize Data Source Settings

Selecting the data source in the Report Explorer enables you to modify the data source settings in the Properties panel.


For instance, clicking the ObjectDataSource.Constructor property's ellipsis button opens the following wizard page: