Changing the Background Color of Rows and Columns
To change the background color of rows and columns in a table, set the BackColor property of the row and column.
Add the following code to the Form_Load event before the Add and Generate methods:
' Set the Column color.
table.Cols(0).Style.BackColor = Color.PapayaWhip
' Set the Row color.
table.Rows(0).Style.BackColor = Color.PaleTurquoise
• C#
// Set the Column color.
table.Cols[0].Style.BackColor = Color.PapayaWhip;
// Set the Row color.
table.Rows[0].Style.BackColor = Color.PaleTurquoise;
What You've Accomplished
The first column in the table is PapayaWhip and the first row in the table is PaleTurquoise:
|