dashboard-114435-winforms-dashboard-winforms-designer-create-dashboards-in-the-winforms-designer-providing-data-object-data-source-binding-to-object-data-sources.md
The Dashboard Designer allows you to connect to an object data source defined in a separate class within the current project.
To bind a dashboard to an object data source, do the following.
Click the New Data Source button in the Data Source ribbon tab.
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.
On the next page, select Object Binding and click Next.
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.
On the next page, select the assembly containing the definition of the required class.
Select the class providing the required data and click Next.
On the final page, select the required data member used to obtain data and click Finish.
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:
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);
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)