Posted 3 March 2025, 4:09 pm EST
I have identified the issue.
I have a class to configure the formatting of all Spread controls I use.
For some reason, I need to set the Font Color and Back color in case I remove all rows. If I don’t, all cells and rows will use the previous color.
Public Shared Sub ConfiguraSpread(FpSpread As FpSpread, Optional FpFont As System.Drawing.Font = Nothing, Optional RowHeight As Decimal = 20, Optional HeaderBackColor As Color = Nothing, Optional HeaderBorderColor As Color = Nothing, Optional HeaderForeColor As Color = Nothing, Optional RowColumnBorderColor As Color = Nothing)
If FpFont Is Nothing Then FpFont = New System.Drawing.Font("Arial", 8.2, FontStyle.Regular)
If HeaderBackColor = Nothing Then HeaderBackColor = Color.FromArgb(230, 230, 230)
If HeaderForeColor = Nothing Then HeaderForeColor = System.Drawing.SystemColors.Highlight
If HeaderBorderColor = Nothing Then HeaderBorderColor = Color.LightGray
If RowColumnBorderColor = Nothing Then RowColumnBorderColor = Color.LightGray
If FpSpread.ActiveSheet.ColumnCount > 0 Then
FpSpread.ActiveSheet.Columns(0, FpSpread.ActiveSheet.Columns.Count - 1).Font = FpFont
FpSpread.ActiveSheet.Columns(0, FpSpread.ActiveSheet.Columns.Count - 1).BackColor = Color.White
FpSpread.ActiveSheet.Columns(0, FpSpread.ActiveSheet.Columns.Count - 1).LockBackColor = Color.White
FpSpread.ActiveSheet.Columns(0, FpSpread.ActiveSheet.Columns.Count - 1).ForeColor = Color.Black
FpSpread.ActiveSheet.Columns(0, FpSpread.ActiveSheet.Columns.Count - 1).LockForeColor = Color.Black
For Each col As FarPoint.Win.Spread.Column In FpSpread.ActiveSheet.ColumnHeader.Columns
For Each RO As FarPoint.Win.Spread.Row In FpSpread.ActiveSheet.ColumnHeader.Rows
Dim cell As FarPoint.Win.Spread.Cell = FpSpread.ActiveSheet.ColumnHeader.Cells(RO.Index, col.Index)
cell.Locked = False
' cell.Renderer = New GeneralCellType
cell.LockForeColor = HeaderForeColor
cell.LockBackColor = HeaderBackColor
cell.Border = New ComplexBorder(New ComplexBorderSide(ComplexBorderSideStyle.ThinLine, HeaderBorderColor))
Next
Next
For Each col As FarPoint.Win.Spread.Column In FpSpread.ActiveSheet.Columns
Dim cell As FarPoint.Win.Spread.Column = FpSpread.ActiveSheet.Columns(col.Index)
cell.Border = New ComplexBorder(New ComplexBorderSide(ComplexBorderSideStyle.ThinLine, RowColumnBorderColor))
Next
End If
If FpSpread.ActiveSheet.RowCount > 0 Then
FpSpread.ActiveSheet.Rows(0, FpSpread.ActiveSheet.Rows.Count - 1).Height = RowHeight '20
End If
FpSpread.ActiveSheet.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1
FpSpread.ActiveSheet.OperationMode = FarPoint.Win.Spread.OperationMode.Normal
FpSpread.ActiveSheet.SelectionUnit = SelectionUnit.Cell
FpSpread.ActiveSheet.SelectionPolicy = SelectionPolicy.MultiRange
FpSpread.TextTipDelay = 250
FpSpread.TextTipPolicy = FarPoint.Win.Spread.TextTipPolicy.Floating
FpSpread.ResizeZeroIndicator = FarPoint.Win.Spread.ResizeZeroIndicator.Default
FpSpread.ActiveSheet.Protect = True
FpSpread.AsWorkbook().ActiveSheet.Protect(GrapeCity.Spreadsheet.WorksheetLocks.Default And Not (GrapeCity.Spreadsheet.WorksheetLocks.FormatColumns Or GrapeCity.Spreadsheet.WorksheetLocks.FormatRows))
End Sub
Specifically, the setting of LockForeColor, will always keep it Black, even when conditional format exists.
How can I address this issue?