Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1
467

Chapter 19


Data Presentation Using


the DataGridView Control


After completing this chapter, you will be able to:
n Create a data grid view object on a Windows form, and use it to display a database
table.
n Sort database tables by column.
n Change the format and color of cells in a data grid view object.
n Add and remove columns and column headings.
n Display multiple data grid view objects on a form.
n Permit changes in data grid view 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 Structured
Query Language (SQL) statements and the Query Builder tool.

In this chapter, you’ll continue working with the database programming features of Microsoft
Visual Studio 2010 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.

Using DataGridView to Display Database Records


The DataGridView control presents information by establishing a grid of rows and columns
on a form to display data as you might see it in a program such as Microsoft Excel or Access.
A DataGridView control can be used to display any type of tabular data: text, numbers, dates,
or the contents of an array. In programming terms, DataGridView is also quite convenient
because the underlying data adapter and dataset objects associated with DataGridView
handle all the data access functionality automatically.

Table of Contents


Data Presentation Using the DataGridView Control............. 467


Using DataGridView to Display Database Records..................... 467
Formatting DataGridView Cells...................................... 479
Adding a Second Data Grid View Object............................... 482
One Step Further: Updating the Original Database...................... 485
Chapter 19 Quick Reference.......................................... 488
Free download pdf