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.

How to: Bind Windows Forms 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.

How to: Display Related Data in a Windows Forms Application

Create a lookup table. A lookup table displays information from one table based on the value of a foreign-key field in another table.

How to: Create Lookup Tables in Windows Forms Applications

Format the way that controls display data.

Formatting and Advanced Binding Dialog Box

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.

How to: Bind Controls to Pictures from a Database

Filter or sort data in a dataset.

How to: Filter and Sort Data in a Windows Forms Application

The following topics provide examples of binding Windows Forms controls to data.

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

Data Sources Window

Concepts

Binding Controls to Data in Visual Studio

Creating and Editing Typed Datasets

Data Sources Overview

Other Resources

Data Walkthroughs