How to: Connect to Data in Objects
You can connect your application to data in objects by running the Data Source Configuration Wizard and selecting Object as the data source type.
After completing the wizard, a data source based on the selected object is added to your project and is immediately available in the Data Sources Window. You can drag items from the Data Sources window onto a design surface in your project to create controls that are data-bound to the selected properties of your object. For more information, see Binding Controls to Data in Visual Studio.
For more information about using objects as data sources, see Data Sources Overview.
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Development Settings in Visual Studio.
To create a new data source from an object
On the Data menu, click Add New Data Source.
Select Object on the Choose a Data Source Type page.
On the Select the Data Objects page, expand the nodes in the tree view to locate the objects that you want to bind to. The tree view contains nodes for your project and for assemblies and other projects referenced by your project.
If you want to bind to an object in an assembly or project that does not appear in the tree view, click Add Reference and use the Add Reference Dialog Box to add a reference to the assembly or project. After you add the reference, the assembly or project is added to the tree view.
You may need to build the project that contains your objects before the objects appear in the tree view.
In the tree view, select the check box for the objects you want to bind to.
The data source is added to the Data Sources window.
To add functionality to your application
Choose Show Data Sources on the Data menu to display the Data Sources window.
Select an item in the Data Sources window and drag it onto a design surface to create a control that is bound to the properties in your object. Repeat this step as necessary for other items as needed.
For more information, see Binding Controls to Data in Visual Studio.
To support drag-and-drop data binding, objects that implement the ITypedList or IListSource interface must have a default constructor (that is, a parameterless constructor). Otherwise, Visual Studio cannot instantiate the data source object, and it will display an error when you drag the item to the design surface.