Skip to content

How to candy stripe a table in Reporting Services

Anthony edited this page Sep 1, 2017 · 6 revisions

Change the background color in the properties of the row to an expression.

=IIF(RunningValue(Fields!YourField.value,CountDistinct,Nothing) Mod 2, "Beige", "White")
=IIF(RowNumber(Nothing) Mod 2, "Beige", "White")

or add the following custom code to the report

Private Alt As Boolean

Public Function CandyStripe(Optional ByVal NewRow As Boolean = False, Optional ByVal OddColor as String = "Beige", Optional ByVal EvenColor as String = "White") As String
'------------------------------------------------------------------------------------------------
' Purpose:  To candy stripe the detail rows of a report
' Example:  Fill.BackgroundColor = Code.CandyStripe()
' Note:     The first column needs a parameter of "True" passed in example: Code.CandyStripe(True)
'------------------------------------------------------------------------------------------------
	If NewRow Then 
		Alt = Not Alt
	End If
	
	If Alt Then
		Return OddColor
	Else
		Return EvenColor
	End If

End Function