Alternating row colors

You've probably seen tables with alternating row colors in some applications. The alternating row colors are normally added for readability purposes. You would notice that wide tables with multiple columns are easier to read when the colors of their rows are alternate.

Let's make the row color alternate between two colors: silver and yellow.

  1. Select the whole detail row and, on the Properties window, look for the BackgroundColor property and set it to an expression (from the drop-down list select Expression).
  2. Add this expression:
    =IIF(RowNumber(Nothing) Mod 2 = 0, "Silver", "Yellow")
    

Note

In previous example, the IIF function is a decision function that returns a Boolean Value (True or False) depending on the criteria (whether it's true or False). For more info about the IIF function, check this link: http://msdn.microsoft.com/en-us/library/ms157328.aspx#DecisionFunctions

Moreover, the RowNumber function retrieves the row number of the current row. The Nothing keyword indicates that we want to start our row count at the top of our table. For more information about the RowNumber function, check this link: http://msdn.microsoft.com/en-us/library/ms157328.aspx#RowNumber

The MOD is an arithmetic operator that returns the remainder (integer) of a division.

Let's take a look at our report in action:

Alternating row colors
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.164.24