Some types of spreadsheets, such as ledgers, have different appearances for alternating rows. This makes it easier to see the data. Spread for Windows Forms allows you to set different appearances for multiple alternating rows. You can set up the alternating rows using an index for the alternating row appearance. The default row appearance is the first alternating row style (or style zero, since the index is zero-based). Set other alternating row appearances to subsequent indexes. Use the AlternatingRow class to create alternating row styles. The AlternatingRow class has the following properties and methods.
Property
Description
BackColor
Gets or sets the background color for cells in this alternating row.
Border
Gets or sets the border for cells in this alternating row.
CanFocus
Gets or sets whether the user can set focus to the cell using the keyboard or mouse for cells in this row.
CellPadding
Gets or sets the amount of space, in pixels, to pad cells in the alternating row(s).
CellType
Gets or sets the cell type for cells in this alternating row.
Editor
Gets or sets the editor for cells in this alternating row.
Font
Gets or sets the default font for text in cells in this alternating row.
ForeColor
Gets or sets the text color for cells in this alternating row.
Formatter
Gets or sets the formatter for cells in this alternating row.
HorizontalAlignment
Gets or sets the horizontal alignment for text in the cells in this alternating row.
ImeMode
Gets or sets the IME mode for an alternating row.
ImeSentenceMode
Gets or sets the IME sentence mode for an alternating row.
Index
Gets the index of this alternating row.
InputScope
Gets or sets the input scope for an alternating row.
Locked
Gets or sets whether cells in this alternating row are marked as locked.
NoteIndicatorColor
Gets or sets the default color for the note indicator for cells in this row.
NoteIndicatorPosition
Gets or sets the position of the note indicator for cells in this row.
NoteIndicatorSize
Gets or sets the default size for the note indicator for cells in this row.
Parent
Gets the parent AlternatingRows object that contains this alternating row.
ParentStyleName
Gets or sets the name of the parent style from which style properties are inherited for cells in this alternating row.
Renderer
Gets or sets the renderer for cells in this alternating row.
StyleName
Gets or sets the name of the custom style for cells in this alternating row.
TabStop
Gets or sets whether the user can set focus to cells in this row using the Tab key.
TextIndent
Gets or sets the amount of space, in pixels, to indent text in cells in this row.
VerticalAlignment
Gets or sets the vertical alignment for text in the cells in this alternating row.
Method
Description
Equals
Determines whether the specified object is equal to another object in this alternating row.
GetHashCode
Gets the hash code of the alternating row.
Invalidate
Invalidates the displayed cells and sends the message to repaint them.
ResetBackColor
Resets the background color for this row and makes this row inherit the background color from the default row.
ResetBorder
Resets the cell border for this row and makes this row inherit the cell border from the default row.
ResetCanFocus
Resets to the default value whether cells in this row can receive focus.
ResetCellPadding
Resets the cell padding of the alternate row.
ResetCellType
Resets the cell type for this row and makes this row inherit the cell type from the default row.
ResetFont
Resets the font for this row and makes this row inherit the font from the default row.
ResetForeColor
Resets the foreground color for this row and makes this row inherit the foreground color from the default row.
ResetHorizontalAlignment
Resets the horizontal alignment for this row and makes this row inherit the horizontal alignment from the default row.
ResetLocked
Resets the locked state for this row and makes this row inherit the locked state from the default row.
ResetNoteIndicatorColor
Resets the cell note indicator color for cells in this row.
ResetNoteIndicatorPosition
Resets the position of the note indicator for cells in this row to the default value.
ResetNoteIndicatorSize
Resets the cell note indicator size for cells in this row.
ResetTabStop
Resets to its default value whether the user can set focus to cells in this row using the Tab key.
ResetTextIndent
Resets the text indent for the row and makes the row inherit the text indent from the default row.
ResetVerticalAlignment
Resets the vertical alignment for this row and makes this row inherit the vertical alignment from the default row.
This example code creates a sheet that has three different appearance settings for rows. This pattern repeats for all subsequent rows. Alternating Rows The data in this file is from - https://www.ncdc.noaa.gov/cdo-web/datasets. C#
fpSpread1.Sheets[0].LoadTextFile("C:\\\ANNUAL\_sample\_csv.csv", FarPoint.Win.Spread.TextFileFlags.None,
FarPoint.Win.Spread.Model.IncludeHeaders.None, "\\n", ",", "");
fpSpread1.Sheets[0].AlternatingRows.Count = 3;
fpSpread1.Sheets[0].AlternatingRows[0].BackColor = Color.Bisque;
fpSpread1.Sheets[0].AlternatingRows[0].ForeColor = Color.Navy;
fpSpread1.Sheets[0].AlternatingRows[1].BackColor = Color.LightYellow;
fpSpread1.Sheets[0].AlternatingRows[1].ForeColor = Color.Navy;
fpSpread1.Sheets[0].AlternatingRows[2].BackColor = Color.PaleGoldenrod;
fpSpread1.Sheets[0].AlternatingRows[2].ForeColor = Color.Navy;
fpSpread1.Font = new System.Drawing.Font("Calibri", 11);
VB
FpSpread1.Sheets(0).LoadTextFile("C:\\ANNUAL\_sample\_csv.csv", FarPoint.Win.Spread.TextFileFlags.None,
FarPoint.Win.Spread.Model.IncludeHeaders.None, Chr(10), ",", "")
FpSpread1.Sheets(0).AlternatingRows.Count = 3
FpSpread1.Sheets(0).AlternatingRows(0).BackColor = Color.Bisque
FpSpread1.Sheets(0).AlternatingRows(0).ForeColor = Color.Navy
FpSpread1.Sheets(0).AlternatingRows(1).BackColor = Color.LightYellow
FpSpread1.Sheets(0).AlternatingRows(1).ForeColor = Color.Navy
FpSpread1.Sheets(0).AlternatingRows(2).BackColor = Color.PaleGoldenrod
FpSpread1.Sheets(0).AlternatingRows(2).ForeColor = Color.Navy
FpSpread1.Font = New System.Drawing.Font("Calibri", 11)
You can set alternating rows in the designer with the AlternatingRow editor under the Settings tab in the designer. Spread Designer You can use the SetDirectInfo method to set other style properties for a cell, column, or row directly. Cell, column, and row styles have precedence over alternating row styles. "Direct" in the style model means "not composite" or "not inherited." The SetDirectAltRowInfo method sets the alternating style properties. The alternating style is used by the viewport controls for merging alternating row styles with the composite style for a cell immediately prior to rendering. The index is zero-based and must be between 0 and (AltRowCount-1). This example uses the SetDirectAltRowInfo method to set the specified alternating row style in the model. C#
FarPoint.Win.Spread.Model.DefaultSheetStyleModel defstyleModel = new FarPoint.Win.Spread.Model.DefaultSheetStyleModel();
FarPoint.Win.Spread.StyleInfo sInfo = new FarPoint.Win.Spread.StyleInfo();
FarPoint.Win.Spread.StyleInfo composite = new FarPoint.Win.Spread.StyleInfo();
defstyleModel = (FarPoint.Win.Spread.Model.DefaultSheetStyleModel)fpSpread1.ActiveSheet.Models.Style;
sInfo.BackColor = Color.LightBlue;
defstyleModel.SetDirectAltRowInfo(0, sInfo);
composite = defstyleModel.GetDirectAltRowInfo(0, sInfo);
listBox1.Items.Add(composite.BackColor.ToString());
VB
Dim defstyleModel As New FarPoint.Win.Spread.Model.DefaultSheetStyleModel()
Dim sInfo As New FarPoint.Win.Spread.StyleInfo()
Dim composite As New FarPoint.Win.Spread.StyleInfo()
defstyleModel = FpSpread1.ActiveSheet.Models.Style
sInfo.BackColor = Color.LightBlue
defstyleModel.SetDirectAltRowInfo(0, sInfo)
composite = defstyleModel.GetDirectAltRowInfo(0, sInfo)
ListBox1.Items.Add(composite.BackColor.ToString())