Skip to main content

Styles and conditional appearance

Three tools control the appearance of the template controls: styles, which you define once and apply to many controls; formatting rules, which change the appearance when a condition is true; and expressions, which hide a control or a band. This page describes each of them and the order of priority between them.

Appearance priority​

A control inherits its appearance from the report and then from the band it is in, and then the style and its own properties apply to it. The style priority options in the control properties (Style Priority) decide, for each appearance property, whether the value of the style or the value of the control itself wins. Formatting rules have a higher priority than all of these.

Styles​

A style is a named set of appearance properties, such as the background color, borders, font, font color and text alignment. Styles are kept in a style sheet inside the report.

Create and edit styles​

  • Open the Styles Editor from the Edit Style Sheet... command in the context menu of the report, or from the Style Sheet property in the Properties of the report.
  • In Report Explorer the Styles node appears, and from it you add, clone and delete styles.
  • The Extract Style command in the ribbon creates a new style from the appearance of the selected control.
  • While the sheet has no styles, the style gallery of the ribbon stays disabled. Add a style to enable it.
Command in Styles EditorWhat it does
Add a styleCreates a new style.
Clone a styleCreates a copy of the selected style.
Delete unused stylesDeletes the styles that no control uses.
Clear stylesDeletes all the styles.
Save styles to a fileSaves the styles to a file on the computer so that you can use them in another template.
Load styles from a fileAdds the styles of a saved file to the sheet.

Apply a style​

Select the control or the band, and then choose the style in the Style property in Properties. A style on a band applies to its controls.

Odd and even rows​

To shade rows alternately, create two styles, and then set the odd-record style property and the even-record style property on the control. In a detail table, set them on the table itself, and they apply to its cells.

Formatting rules​

A formatting rule is a condition (an expression whose result is true or false) with a format that is applied to the control when the condition is true. It has a higher priority than styles and control properties. You define the rules once in the report, and then you apply them to controls.

  1. Open the Formatting Rule Sheet Editor from the Edit Formatting Rule Sheet... command in the context menu of the report, from the Formatting Rules box in the smart tag of the report, or from the Formatting Rules node in Report Explorer.
  2. Add a rule, write its condition in the Condition Editor with an expression such as [Total] < 0, and set the format you want, such as the font color, the background or the font.
  3. Select the control, choose Edit Formatting Rules..., and move the rule from the rules available in the report to the rules applied to the control.

If several rules with true conditions are applied to a control, the last rule in the list wins when they conflict. The result of the condition must be true or false.

Hide a control or a band​

To hide a control or a band when a condition is true:

  • Bind the Visible property of the control or the band to an expression in the Expression Editor whose result is true or false, such as [Discount] > 0. The control prints only when the result is true.
  • Or create a formatting rule whose condition is the case in which you want to hide, set Visible to No in it, and apply it to the control or the band.

See Hide a column or band when it is empty for full steps.

Example: shade rows and colour negative values​

In the table of the lines of a sales invoice:

  1. Create a style named Even rows with a light gray background, and set it as the even-record style of the detail table.
  2. Create a formatting rule with the condition [Total] < 0 and a red font color, and apply it to the Total cell.

The preview prints the even lines with a gray background, and prints a return line whose value is -250.00 in a red font.

This page applies to alameen ERP 10, version 10.1.79.764.