How to: Bind a Windows Forms Control to a Type Using the Designer
When you are building controls that interact with data, you sometimes need to bind a control to a type, rather than an object. You typically need to bind a control to a type at design time, when data may not be available, but you still want your data-bound controls to display data from a type's public interface. The following procedures demonstrate how to create a new BindingSource that is bound to a type, and then how to bind one of the type's properties to the Text property of a TextBox.
To bind the BindingSource to a type
Create a Windows Forms project.
For more information, see How to: Create a New Windows Forms Application Project.
In Design view, drag a BindingSource component onto the form.
In the Properties window, click the arrow for the DataSource property.
In the DataSource UI Type Editor, click Add Project Data Source.
On the Choose a Data Source Type page, select Object and click Next.
Select the type to bind to:
If the type you want to bind to is in the current project, or the assembly that contains the type is already added as a reference, expand the nodes to find the type you want, and then select it.
If the type you want to bind to is in another assembly, not currently in the list of references, click Add Reference, and then click the Projects tab. Select the project that contains the business object you want and click OK. This project will appear in the list of assemblies, so you can expand the nodes to find the type you want, and then select it.
If you want to bind to a type in a framework or Microsoft assembly, clear the Hide assemblies that begin with Microsoft or System check box.
Click Next, and then click Finish.
To bind the control to the BindingSource
Add a TextBox to the form.
In the Properties window, expand the (DataBindings) node.
Click the arrow next to the Text property.