Tutorials > Tutorial 12 - Displaying Rows in Alternating Colors |
In this tutorial, you will learn how to use the AlternatingRowStyle property and built-in styles to apply alternating colors to grid rows to improve their readability.
Start with the project used in Tutorial 10.
Right-click the grid and select Properties from the context menu to display the Property Pages dialog. Click the Splits tab and expand the Splits(00) object. Double-click the AlternatingRowStyle node to toggle its value.
The grid has default settings for both the EvenRow and OddRow styles. We will use the default settings first and then change the settings for the EvenRow style.
Run the program and observe the following:
TDBGrid1 displays data as in Tutorial 10, except that even-numbered rows have a light cyan background.
Right-click the grid and select Properties from the context menu to display the Property Pages dialog. Click the Style Factory tab and expand the EvenRow style.
Next, select the BackColor property of the EvenRow style and change it from Cyan to Light Gray. Click OK to close the property page.
Run the program and observe the following:
TDBGrid1 displays data as in the previous figure, except that even-numbered rows now have a light gray background.
This concludes Tutorial 12.