Chapter 19
Data Presentation Using the DataGridView Control
After completing this chapter, you will be able to:
Create a data grid view object on a Windows form, and use it to display a database table.
Sort database tables by column.
Change the format and color of cells in a data grid view object.
Add and remove columns and column headings.
Display multiple data tables and navigation bars on a form, and switch among them.
Permit changes in grid cells, and write updates to the underlying database.
In Chapter 18, “Getting Started with ADO.NET,” you learned how to use Microsoft ADO.NET database programming techniques to establish a connection to a Microsoft Access database and display columns from the database in a Windows form. You also learned how to add a navigation bar to a form and how to organize database information using SQL statements and the Query Builder tool.
Upgrade Notes: Migrating Visual Basic 6 Code to Visual Basic 2005
If you're experienced with Microsoft Visual Basic 6, you'll notice some new features in Microsoft Visual Basic 2005, including the following:
In Visual Basic 6, you can use several grid controls to display database information on a form, including FlexGrid, Hierarchical FlexGrid, and DataGrid. In Visual Basic 2005, the DataGridView control is the only spreadsheet-style control that's provided to display a database table.
The DataGridView control included with Visual Basic 2005 is somewhat different from the DataGrid control included with Microsoft Visual Studio .NET 2003, and quite different from the DataGrid control included with Visual Basic 6. One important improvement is that the Visual Basic 2005 DataGridView control doesn't require data-specific commands because the underlying data adapter and dataset objects handle all the data access functionality.
In this chapter, you'll continue working with the database programming features of Microsoft Visual Studio 2005 and the useful classes, objects, and design tools in ADO.NET. In particular, you'll learn how to use the DataGridView control, which allows you to present an entire table of database information to the user.