Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 19 Data Presentation Using the DataGridView Control 481



  1. Click OK to close the dialog box.


When you run the program, the rows in the data grid view will be displayed in
alternating colors of white and yellow.

Note The color that appears around the edges of the cell is controlled by the
BackgroundColor property. To change the color of all the cells in a data grid view, you can
adjust the DefaultCellStyle property. To change the background color used for the header
cells (if you display them), you can modify the ColumnHeadersDefaultCellStyle property.


  1. Click the GridColor property, click the arrow in the second column, click the Custom
    tab, and then click Navy (a dark blue color).
    This property setting controls the color of the gridlines. If you change the background
    color of the cells, you might also want to modify the gridline color.
    Now, you’ll run the program to see the effect of your formatting changes.

  2. Click the Start Debugging button.


After a few moments, the data grid view appears with information from the Faculty
table. Your screen looks similar to the following screen shot:

Notice that the column headers have been removed, the second column is a
little narrower, and the third column is a little wider. Notice also the alternating
white-and-yellow row pattern and the blue gridlines (they are not too discernible in
the printed book, alas, but you can see them on the screen).


  1. Click the Close button on the form to stop the program.

Free download pdf