Styles and Conditional Formatting


The topics of this section cover appearance-related information about the Report Designer.

This section consists of the following topics.

 

 

 

Understand Styles Concepts


This document describes how you can provide a professional look to your reports, by effectively adjusting the appearance of its elements.

This document consists of the following sections.

 

The Appearance Properties

In the Report Designer, a report and each of its elements (bands and controls) has a complete set of appearance options (such as Background Color, Borders, Font, Foreground Color, Text Alignment, etc.). By default, these properties aren't specified, meaning that their real values are obtained from a control's (or band's) parent, which is the report itself. So, the appearance, specified for a report, is distributed to all its child elements. Similarly, the appearance of a band is translated to the controls it contains.

 

In turn, a control's appearance can be adjusted independently from its parent.

 

When it is required to reset a value assigned to a control's appearance property, you can right-click this property in the Property Grid, and in the invoked menu, click Reset. So, the control will be restored to the appearance of its parent.

Styles Priority and Inheritance

To differentiate appearance settings in your report, you can create comprehensive styles (which are stored in the report's style sheet), and then can be assigned to individual elements. There are two ways to store a report's styles.

 

To save them to external files (with REPSS extension), and then load them to a report via its Style Sheet Path property (this is described at Store and Restore Style Sheets);  To store the styles within the report, so that they can be easily accessed via its Style Sheet property.

Note that if styles contained in a style sheet loaded via the Style Sheet Path property have the same names as styles already contained in a report, the latter ones are overridden.

When both styles and individual appearance settings are assigned to an element, you can control the priority of their differing options, via an element's Style Priority property.

By default, most of the Style Priority's options (Use Background Color, Use Border Color, etc.) are set to Yes.

 

This means that if any style is assigned to a control, its properties will have a higher priority than the appearance properties of this element or its parent. You can assign a higher priority to an element's appearance property, by disabling the corresponding Use* property.

The same principles are applied to the odd-even styles feature, which allows you to alternate the appearance of consecutive data rows in your report. For details on this, refer to Use Odd and Even Styles.

 

Note

When conditional formatting is applied to an element, its appearance definition has the highest priority.

See Also

Use Odd and Even Styles

Store and Restore Style Sheets

Conditionally Change a Control's Appearance

 

 

Use Odd and Even Styles


This tutorial describes how to apply odd and even styles to report controls, e.g. to alternate the background color for each record.

To utilize odd and even styles, do the following.

1.Create a table report.

2.Select the detail table, and in the Property Grid, expand its Styles.

Invoke the drop-down list for the Even Style, and click (New).

This will create a style and assign it to the control's Even Style.

3.Now, expand the Even Style property, and adjust the required options, e.g. set the Background Color to ControlLight.

If required, perform the same steps, to create and assign an odd style, as well.

Switch to the Preview Tab, and view the result.

 

See Also

Understand Styles Concepts

Store and Restore Style Sheets

Conditionally Change a Control's Appearance

 

 

Store and Restore Style Sheets


This tutorial describes how you can save a report's style sheet into an external file, and then load it back to the report.

You can store a report's style sheet (containing all the report's styles) in an external REPSS file. This makes it possible to easily restore a report's appearance from this file. For general information, refer to Understand Styles Concepts.

To learn how to store and restore report style sheets, do the following.

1.Create a new report and bind it to a data source.

2.Click the report's Smart Tag, and in the invoked actions list, click the ellipsis button for the Style Sheet

property.

 

3.In the invoked Styles Editor, use the button, to create new styles. For them, specify the desired

options (e.g. Background Color), and click the Save button.

 

 


Then, in the invoked Save File dialog, define a name for the style sheet file (.REPSS), and click Save.

4.Then delete the created styles, using the button, and close the dialog.

5.Select the report, and in the Property Grid, click its ellipsis button for the Style Sheet Path property. In the invoked Open File dialog, load the created REPSS file.

 


When you invoke the Styles Editor (via the report's Style Sheet property) again, you'll see that the styles are read-only, meaning that they are obtained from an external file.

 


If the Style Sheet Path property is then set to None, and a style sheet is loaded using the Styles Editor of the Style Sheet property, all these styles will become editable.

To learn how you can assign styles to report elements, refer to Use Odd and Even Styles.

 

Note

Note that the styles loaded from a style sheet file have priority over the styles which exist in a report's style sheet. So, if the styles stored in the report have the same names as the styles loaded from a style sheet file, then the styles from the file will substitute for their namesakes.

See Also

Understand Styles Concepts

Use Odd and Even Styles

Conditionally Change a Control's Appearance

 

 

Conditionally Change a Control's Appearance


This tutorial describes the steps to conditionally change a control's appearance (e.g. make a Label's text red if its value exceeds some threshold). Thanks to the formatting rules feature, to achieve this, no scripts are required, so you shouldn't write any code.

To conditionally change a control's appearance, do the following.

1.Create a data-aware report.

2.Click the report's Smart Tag, and in the invoked actions list, click the ellipsis button for the Formatting

Rule Sheet option.


And, in the invoked Formatting Rule Sheet Editor, create a new formatting rule (by using the button),

and click the ellipsis button for its Condition property.

 

3.Then, in the invoked Condition Editor, define the required Boolean condition (which means that its result is returned as either true or false). In this tutorial, we will format fields if the UnitPrice value is greater than 30.

 


To save the condition and close the dialog, click OK.

4.Now, back in the Formatting Rule Sheet Editor, define the formatting to be applied (e.g. specify the desired font color).

 


To save the changes and quit the dialog, click Close.

5.Finally, select the band or control to which the formatting rule must be applied (in this example it is the Detail band), and via its Smart Tag, access its collection of Formatting Rules.

 


And, in the invoked Formatting Rules Editor, move the rule from left to right (using the > button), for it to come into effect for this band.

 

If multiple rules are applied, it is possible to customize their precedence, by using the up and down arrow buttons at the right of the dialog. So, the rules are applied in the same order that they appear in the list, and the last rule in the list has the highest priority.

The result is shown in the following image.

See Also

 

Conditionally Hide Bands

Conditionally Change a Label's Text

 

 

Conditionally Hide Bands


This tutorial describes how to hide bands if a certain logical condition is met. Note that no scripts are required to accomplish this task.

To demonstrate this feature, we'll use a report with grouping, similar to the one created in the following tutorial: Change or Apply Data Grouping to a Report.

To conditionally hide bands in a report, do the following.

1.Select the Group Header, and click its Smart Tag. Then, in the invoked actions list, click the ellipsis button for the Formatting Rules option.

 


In the invoked Formatting Rules Editor, click the Edit Rule Sheet... button.

2.Now, in the invoked Formatting Rule Sheet Editor, click the button, to create a new rule. Then, set

its Visible property to No, and click the ellipsis button for the Condition property.

 

3.Construct the required logical expression (e.g. [CategoryID] < 2), and click OK.

 

To quit the Formatting Rule Sheet Editor, click Close.

4.Back in the Formatting Rules Editor, move the created rule to the dialog's right section (Applied Rules), to make it active.

 


And, do the same for the report's Detail band. That is, click the ellipsis button for its Formatting Rules property, and in the invoked dialog, apply the same rule to this band, as well.

Switch to the Preview Tab, and view the result. In our example, you can see that the first category isn't shown. So, the conditional formatting was applied properly.

See Also

Conditionally Change a Control's Appearance

Conditionally Change a Label's Text

 

 

Conditionally Change a Label's Text


This tutorial demonstrates how to change a label's text if a certain condition is met, without using scripts.

To conditionally change a label's text, do the following.

1.Create a new report and bind it to a data source.

2.To create a calculated field, in the Field List, right-click any item inside the created dataset, and on the

invoked menu, choose Add Calculated Field.

3.Select the calculated field, and in the Property Grid, set its Field Type to String. Then, click the ellipsis button for its Expression property.

And, in the invoked Expression Editor, define the required logical condition for the calculated field (e.g. Iif([UnitsOnOrder] == 0, 'None', [UnitsOnOrder]), which means that if the UnitsOnOrder data field's value is equal to 0, the control's text will be replaced with None).

 


To save the changes and close the dialog, click OK.

4.Finally, drop the required data fields (and the created calculated field as well) from the Field List onto the report's Detail band.

The report is now ready. Switch to the Preview Tab, and view the result.

 

See Also

Conditionally Change a Control's Appearance

Conditionally Hide Bands