Displaying Data in the Windows Forms DataGridView Control

The DataGridView control is used to display data from a variety of external data sources. Alternatively, you can add rows and columns to the control and manually populate it with data.

When you bind the control to a data source, you can generate columns automatically based on the schema of the data source. If these columns do not appear just as you want them to, you can hide, remove, or rearrange them. You can also add unbound columns to display supplemental data that does not come from the data source.

Additionally, you can display your data using standard formats (such as currency format), or you can customize the display formatting to present your data however you need to (such as changing the background color for negative numbers, or replacing string values with corresponding images).

In This Section

Data Display Modes in the Windows Forms DataGridView Control
Describes the options for populating the control with data.

Data Formatting in the Windows Forms DataGridView Control
Describes the options for formatting cell display values.

Walkthrough: Creating an Unbound Windows Forms DataGridView Control
Describes how to manually populate the control with data.

How to: Bind Data to the Windows Forms DataGridView Control
Describes how to populate the control with data by binding it to a BindingSource that contains information pulled from a database.

How to: Autogenerate Columns in a Data-Bound Windows Forms DataGridView Control
Describes how to automatically generate columns based on a bound data source.

How to: Remove Autogenerated Columns from a Windows Forms DataGridView Control
Describes how to hide or delete columns generated automatically from a bound data source.

How to: Change the Order of Columns in the Windows Forms DataGridView Control
Describes how to rearrange columns generated automatically from a bound data source.

How to: Add an Unbound Column to a Data-Bound Windows Forms DataGridView Control
Describes how to supplement data from a bound data source by displaying additional, unbound columns.

How to: Bind Objects to Windows Forms DataGridView Controls
Describes how to bind the control to a collection of arbitrary objects so that each object is displayed in its own row.

How to: Access Objects Bound to Windows Forms DataGridView Rows
Describes how to retrieve an object bound to a particular row of the control.

Walkthrough: Creating a Master/Detail Form Using Two Windows Forms DataGridView Controls
Describes how to display data from two related database tables so that the values shown in one DataGridView control depend on the currently selected row in another control.

How to: Customize Data Formatting in the Windows Forms DataGridView Control
Describes how to handle the DataGridView.CellFormatting event to change the appearance of cells depending on their values.

Reference

DataGridView
Provides reference documentation for the DataGridView control.

DataGridView.DataSource
Provides reference documentation for the DataSource property.

BindingSource
Provides reference documentation for the BindingSource component.

Data Entry in the Windows Forms DataGridView Control
Provides topics that describe how to change the way users add and modify data in the control.

See also