Binding Windows Forms Controls to Data in Visual Studio
You can display data to users of your application by binding data to Windows Forms. To create these data-bound controls, you can drag items from the Data Sources window onto the Windows Forms Designer in Visual Studio. This topic describes some of the most common tasks, tools, and classes involved in creating data-bound Windows Forms applications.
For general information about how to create data-bound controls in Visual Studio, see Binding Controls to Data in Visual Studio. For more information about data binding in Windows Forms, see Windows Forms Data Binding.
Tasks Involved in Displaying Data on a Form in a Windows Application
The following table lists common tasks related to displaying data on a form in a Windows application.
Task |
More information |
---|---|
Create data-bound controls. Bind existing controls to data. |
|
Create controls that display related data in a parent-child relationship: when the user selects a data record in one control, another control displays related data for the selected record. |
|
Create a lookup table. A lookup table displays information from one table based on the value of a foreign-key field in another table. |
|
Format the way that controls display data. |
|
Change the behavior of the smart-captioning feature in the Data Sources window. |
How to: Customize How Visual Studio Creates Captions for Data-bound Controls |
Add controls that execute a parameterized query. |
How to: Add a Parameterized Query to a Windows Forms Application |
Set a column to use an image control to display images in a database. |
|
Filter or sort data in a dataset. |
The following topics provide examples of binding Windows Forms controls to data.
Walkthrough: Displaying Data on a Windows Form
Provides step-by-step details on querying data from a database and displaying the data on a Windows Form.Walkthrough: Displaying Related Data on a Windows Form
Provides step-by-step details on displaying data from two related tables and displaying the data on a Windows Form.Walkthrough: Creating a Windows Form to Search Data
Provides step-by-step details about how to create a Windows Form that conducts a database search based on user input.Walkthrough: Creating a Lookup Table in a Windows Forms Application
Provides step-by-step details on displaying data from one table that is based on the data that is selected in another table.Walkthrough: Passing Data Between Windows Forms
Provides step-by-step details about how to pass values from one form to another form in an application.Walkthrough: Creating a Windows Forms User Control that Supports Simple Data Binding
Provides step-by-step details about how to create a custom control that can be used in the Data Sources window.Walkthrough: Creating a Windows Forms User Control that Supports Complex Data Binding
Provides step-by-step details about how to create a custom control that can be used in the Data Sources window.Walkthrough: Creating a Windows Forms User Control that Supports Lookup Databinding
Provides step-by-step details about how to create a custom control that can be used in the Data Sources window.
Data Smart Tags
Smart tags specific to working with data are available on many controls. When certain controls are added to a form, a set of possible actions that relate to data are available on the smart tag.
BindingSource Component
The BindingSource component serves two purposes. First, it provides a layer of abstraction when binding the controls on your form to data. Controls on the form are bound to the BindingSource component (instead of being bound directly to a data source).
Second, it can manage a collection of objects. Adding a type to the BindingSource creates a list of that type.
For more information about the BindingSource component, see:
BindingNavigator Control
This component provides a user interface for navigating through data displayed by a Windows application. For more information, see BindingNavigator Control (Windows Forms).
DataGridView Control
The DataGridView control lets you display and edit tabular data from many different kinds of data sources. You can bind data to a DataGridView by using the DataSource property. For more information, see DataGridView Control Overview (Windows Forms).
See Also
Tasks
Walkthrough: Displaying Data on a Windows Form
Walkthrough: Creating a Windows Forms User Control that Supports Simple Data Binding
Walkthrough: Creating a Windows Forms User Control that Supports Complex Data Binding
Walkthrough: Creating a Windows Forms User Control that Supports Lookup Databinding
Reference
Concepts
Binding Controls to Data in Visual Studio
Creating and Editing Typed Datasets