How to: Display Data by Using DataGridView Controls
You can display data in your application by using a data-bound DataGridView control. First you add a data source to your application, and then you can drag a DataGridView control from the Data Sources window to your application. To learn how to connect to a database, see How to: Connect to a Database (C#).
You can also display data in individual controls, such as a TextBox control. For more information, see How to: Display Data on a Form.
To display data on a DataGridView control
On the File menu, click New Project.
In the New Project dialog box, click Windows Forms Application, and then click OK.
A new Windows Forms project opens.
Add a connection to the sample database named Northwind.sdf as described in How to: Connect to a Database (C#).
On the Data menu, click Show Data Sources.
The Data Sources window opens.
In the Data Sources window, expand NorthwindDataSet, and then click the Customers table.
Click the drop-down arrow next to the Customers table and then click DataGridView.
Drag the Customers table from the Data Sources window to form1.
A DataGridView control and a tool strip (BindingNavigator) for navigating records appear on the form. You will also see a DataSet, TableAdapter, BindingSource, and BindingNavigator in the component tray.
Click the DataGridView control and change its Dock property to Fill by clicking the arrow to the right of the Dock property and clicking the center square.
Press F5 to run the code.
Resize the form and scroll through the data in the DataGridView control.