Share via


Differences Between the Windows Forms DataGridView and DataGrid Controls

The DataGridView control is a new control that replaces the DataGrid control. The DataGridView control provides numerous basic and advanced features that are missing in the DataGrid control. Additionally, the architecture of the DataGridView control makes it much easier to extend and customize than the DataGrid control.

The following table describes a few of the primary features available in the DataGridView control that are missing from the DataGrid control.

DataGridView control feature Description

Multiple column types

The DataGridView control provides more built-in column types than the DataGrid control. These column types meet the needs of most common scenarios, but are also easier to extend or replace than the column types in the DataGrid control. For more information, see Column Types in the Windows Forms DataGridView Control.

Multiple ways to display data

The DataGrid control is limited to displaying data from an external data source. The DataGridView control, however, can display unbound data stored in the control, data from a bound data source, or bound and unbound data together. You can also implement virtual mode in the DataGridView control to provide custom data management. For more information, see Data Display Modes in the Windows Forms DataGridView Control.

Multiple ways to customize the display of data

The DataGridView control provides many properties and events that enable you to specify how data is formatted and displayed. For example, you can change the appearance of cells, rows, and columns depending on the data they contain, or you can replace data of one data type with equivalent data of another type. For more information, see Data Formatting in the Windows Forms DataGridView Control.

Multiple options for changing cell, row, column, and header appearance and behavior

The DataGridView control enables you to work with individual grid components in numerous ways. For example, you can freeze rows and columns to prevent them from scrolling; hide rows, columns, and headers; change the way row, column, and header sizes are adjusted; change the way users make selections; and provide ToolTips and shortcut menus for individual cells, rows, and columns.

The DataGrid control is retained for backward compatibility and for special needs. For nearly all purposes, you should use the DataGridView control. The only feature that is available in the DataGrid control that is not available in the DataGridView control is the hierarchical display of information from two related tables in a single control. You must use two DataGridView controls to display information from two tables that are in a master/detail relationship.

Upgrading to the DataGridView Control

If you have existing applications that use the DataGrid control in a simple data-bound scenario without customizations, you can simply replace the old control with the new control. Both controls use the standard Windows Forms data-binding architecture, so the DataGridView control will display your bound data with no additional configuration needed. You might want to consider taking advantage of data-binding improvements, however, by binding your data to a BindingSource component, which you can then bind to the DataGridView control. For more information, see BindingSource Component.

Because the DataGridView control has an entirely new architecture, there is no straightforward conversion path that will enable you to use DataGrid customizations with the DataGridView control. Many DataGrid customizations are unnecessary with the DataGridView control, however, because of the built-in features available in the new control. If you have created custom column types for the DataGrid control that you want to use with the DataGridView control, you will have to implement them again using the new architecture. For more information, see Customizing the Windows Forms DataGridView Control.

See Also

Reference

DataGridView
DataGrid
BindingSource

Concepts

Column Types in the Windows Forms DataGridView Control
Cell Styles in the Windows Forms DataGridView Control
Data Display Modes in the Windows Forms DataGridView Control
Data Formatting in the Windows Forms DataGridView Control
Sizing Options in the Windows Forms DataGridView Control
Column Sort Modes in the Windows Forms DataGridView Control
Selection Modes in the Windows Forms DataGridView Control

Other Resources

DataGridView Control (Windows Forms)
DataGrid Control (Windows Forms)
BindingSource Component
Customizing the Windows Forms DataGridView Control