BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Posted by Andy Brown on 03 August 2012
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Alternate Colours using Conditional Formatting
The simplest (and most common way) to colour rows conditionally is shown below.
Creating Alternate Colours using the BackgroundColor Property
A simple way to create an alternate colour effect for a report is to set the background colour for table cells to be the following:
To do this, first select the cells that you want to conditionally format:
Use the SHIFT key (easier) or mouse to select all of the cells in the row you want to format.
Now find and change the cells' BackgroundColor property:
Find the BackgroundColor property of the cells, and choose to create an expression for it.
Use the expression builder to create an expression for the background colour like this:
Set the background colour differently according to the whether the number of the row is odd or even.
The RowNumber(Nothing) function gives the row number of the current row within the scope of the table.
When you preview your report, the row colour will alternate:
Odd and even rows are coloured differently.
Problems with this Approach
In most cases the above approach will work OK, but it breaks down for some grouped reports and it's not very flexible. An alternative - but more complicated way - is to use a custom assembly, as shown in the final part of this blog.