Spread for ASP.NET 9.0 Product Documentation > Developer's Guide > Customizing the Appearance > Customizing the Appearance of Rows and Columns > Creating Alternating Rows |
You might want to set up your sheet so that alternating rows have different appearance. For example, in a ledger, alternating rows often have a green background. In Spread, you can set up multiple alternating row appearances, which are applied in sequence, starting with the first row. The following image displays alternating row colors:
Set up the alternating rows using an index into the alternating row appearances. It might help to think of the default row appearance as the first alternating row style (or style zero, because the index is zero-based). Set the other alternating row appearances to subsequent indexes. Refer to the AlternatingRow class.
This example code creates a sheet that has three different appearance settings for rows. The first row uses the default appearance. The second row has a light blue background with dark blue text, and the third row has an orange background with dark red text. This pattern repeats for all subsequent rows.
C# |
Copy Code
|
---|---|
FpSpread1.Sheets[0].AlternatingRows.Count = 3; FpSpread1.Sheets[0].AlternatingRows[1].BackColor = Color.LightBlue; FpSpread1.Sheets[0].AlternatingRows[1].ForeColor = Color.DarkBlue; FpSpread1.Sheets[0].AlternatingRows[2].BackColor = Color.Orange; FpSpread1.Sheets[0].AlternatingRows[2].ForeColor = Color.DarkRed; |
VB |
Copy Code
|
---|---|
FpSpread1.Sheets(0).AlternatingRows.Count = 3 FpSpread1.Sheets(0).AlternatingRows(1).BackColor = Color.LightBlue FpSpread1.Sheets(0).AlternatingRows(1).ForeColor = Color.DarkBlue FpSpread1.Sheets(0).AlternatingRows(2).BackColor = Color.Orange FpSpread1.Sheets(0).AlternatingRows(2).ForeColor = Color.DarkRed |