Share via


DataGridView Control Overview (Windows Forms)

NoteNote

The DataGridView control replaces and adds functionality to the DataGrid control; however, the DataGrid control is retained for both backward compatibility and future use, if you choose. For more information, see Differences Between the Windows Forms DataGridView and DataGrid Controls.

With the DataGridView control, you can display and edit tabular data from many different kinds of data sources.

Binding data to the DataGridView control is straightforward and intuitive, and in many cases it is as simple as setting the DataSource property. When you bind to a data source that contains multiple lists or tables, set the DataMember property to a string that specifies the list or table to bind to.

The DataGridView control supports the standard Windows Forms data binding model, so it will bind to instances of classes described in the following list:

The DataGridView control supports data binding to the public properties of the objects returned by these interfaces or to the properties collection returned by an ICustomTypeDescriptor interface, if implemented on the returned objects.

Typically, you will bind to a BindingSource component and bind the BindingSource component to another data source or populate it with business objects. The BindingSource component is the preferred data source because it can bind to a wide variety of data sources and can resolve many data binding issues automatically. For more information, see BindingSource Component.

The DataGridView control can also be used in unbound mode, with no underlying data store. For a code example that uses an unbound DataGridView control, see Walkthrough: Creating an Unbound Windows Forms DataGridView Control.

The DataGridView control is highly configurable and extensible, and it provides many properties, methods, and events to customize its appearance and behavior. When you want your Windows Forms application to display tabular data, consider using the DataGridView control before others (for example, DataGrid). If you are displaying a small grid of read-only values, or if you are enabling a user to edit a table with millions of records, the DataGridView control will provide you with a readily programmable, memory-efficient solution.

In This Section

See Also

Tasks

DataGridView Control Sample

Reference

Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control
DataGridView
BindingSource

Concepts

Default Functionality in the Windows Forms DataGridView Control

Other Resources

DataGridView Control (Windows Forms)