Reporting Service Tips (i): Different color settings for odd and even rows in a table

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.