Export (0) Print
Expand All

How to: Set Alternating Row Styles for the Windows Forms DataGridView Control

Tabular data is often presented to users in a ledger-like format where alternating rows have different background colors. This format makes it easier for users to tell which cells are in each row, especially with wide tables that have many columns.

With the DataGridView control, you can specify complete style information for alternating rows. This enables you use style characteristics like foreground color and font, in addition to background color, to differentiate alternating rows.

There is support for this task in Visual Studio. For more information, see How to: Set Alternating Row Styles for the Windows Forms DataGridView Control Using the Designer and How to: Set Alternating Row Styles for the Windows Forms DataGridView Control Using the Designer and How to: Set Alternating Row Styles for the Windows Forms DataGridView Control Using the Designer and How to: Set Alternating Row Styles for the Windows Forms DataGridView Control Using the Designer and How to: Set Alternating Row Styles for the Windows Forms DataGridView Control Using the Designer.

To set alternating row styles programmatically

This example requires:

For maximum scalability, you should share DataGridViewCellStyle objects across multiple rows, columns, or cells that use the same styles, rather than setting the style properties for each element separately. For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.

Community Additions

ADD
Show:
© 2014 Microsoft