Back to Devexpress

Binding to Object Data Sources

dashboard-114435-winforms-dashboard-winforms-designer-create-dashboards-in-the-winforms-designer-providing-data-object-data-source-binding-to-object-data-sources.md

latest3.4 KB
Original Source

Binding to Object Data Sources

  • Sep 24, 2025
  • 2 minutes to read

The Dashboard Designer allows you to connect to an object data source defined in a separate class within the current project.

Creating a Data Source in the Data Source Wizard

To bind a dashboard to an object data source, do the following.

  1. Click the New Data Source button in the Data Source ribbon tab.

  2. On the first page of the invoked Data Source Wizard dialog, specify whether you want to use an existing data connection or create a new data connection.

  3. On the next page, select Object Binding and click Next.

  4. On the first page of the invoked Data Source Wizard dialog, specify whether you want to use an existing data connection or create a new data connection.

  5. On the next page, select the assembly containing the definition of the required class.

  6. Select the class providing the required data and click Next.

  7. On the final page, select the required data member used to obtain data and click Finish.

Creating a Data Source in Code

To create an object data source in code, create an instance of the DashboardObjectDataSource class and specify the following properties:

Finally, add the created DashboardObjectDataSource object to the Dashboard.DataSources collection.

The following code snippet shows how to create an object data source and add it to the collection of dashboard data sources:

csharp
using DevExpress.DashboardCommon;
// ...
            Dashboard dashboard = new Dashboard();
            DashboardObjectDataSource objectDataSource = new DashboardObjectDataSource();
            objectDataSource.DataSource = typeof(Student);
            objectDataSource.DataMember = "GetData";
            objectDataSource.Constructor = ObjectConstructorInfo.Default;
            objectDataSource.Fill();
            dashboard.DataSources.Add(objectDataSource);
vb
Imports DevExpress.DashboardCommon
' ...
            Dim dashboard As New Dashboard()
            Dim objectDataSource As New DashboardObjectDataSource()
            objectDataSource.DataSource = GetType(Student)
            objectDataSource.DataMember = "GetData"
            objectDataSource.Constructor = ObjectConstructorInfo.Default
            objectDataSource.Fill()
            dashboard.DataSources.Add(objectDataSource)