In the report development, we all want to design the report to be very beautiful, just like Excel2007 brings us the brand-new visual feeling, lets the user feel very comfortable.
In the aesthetically pleasing setting, the odd and even rows in the report show different background colors as one of them, so let's take a look at how to implement this in reporting Services 2005.
Method One: System function
Set the background of all cells to the following expression:
Backgroudcolor=iif (RowNumber) Mod 2, "lavender", "white"
which
RowNumber (Nothing): Provides run count values for each row in the outermost data region
To achieve better versatility, we can write this as a custom function.
Method Two: Custom functions
This method is more ingenious and uses a global variable Boddrow to realize the switching of odd and even rows.
Private bOddRow As Boolean
'*****************************************************************************
'-- Display green-bar type color banding in detail rows
'-- Call from BackGroundColor property of all detail row textboxes
'-- Set Toggle True for first item, False for others.
'*****************************************************************************
Function AlternateColor(ByVal OddColor As String, ByVal EvenColor As String, ByVal Toggle As Boolean) As String
If Toggle Then bOddRow = Not bOddRow
If bOddRow Then
Return OddColor
Else
Return EvenColor
End If
End Function
When the function setting is complete, set the background color in the first column of the table to:
=code.alternatecolor ("Black", "white", True)
The other columns are set to:
=code.alternatecolor ("Black", "white", False)