ActiveReports 6 Online Help
NEW Style Sheets Sample

This sample demonstrates how you can change styles at run time for a different look with the same report. The project includes two reports, three reportstyles, and a form with the ActiveReports Viewer control and several other controls that allow you to select any combination of styles and reports.

Report Style Sheets

Look in Solution Explorer to see several *.reportstyle files. These are XML-based files that hold styles that you can apply to TextBox, Label, CheckBox, and ReportInfo controls on ActiveReports. Double-click one to open it. Each reportstyle contains a set of values for each of the standard style names:

When you select one of these style names on a report control, ActiveReports retrieves the style values, such as font size and color, from the specified style sheet when it runs the report.

For more information on creating your own style sheets, see Use External Style Sheets.

Reports

Two reports, CategoryReport and ProductsReport, are included in this sample so that you can each of the styles applied in different ways. Open one of the reports, and select the TextBox and Label controls on it to see which style is used for each.

StyleSheetsForm

The form in this project features radio buttons for choosing the report and style you want, a Choose button that opens a standard Windows Open dialog where you can select a reportstyle, and a Run report button that runs the selected report, applies the selected reportstyle, and displays the results in the ActiveReports viewer control below.

To see how all of this works, right-click the form and select View Code.

Choose Button Click Event

This event contains code that sets up an Open dialog that shows only *.reportstyle files, and passes the selected reportstyle path and file name string to the externalStyleSheet variable.

Run Report Button Click Event

This event contains code that creates an empty ActiveReport object, assigns the selected report to it, and assigns a path and file name string to the styleSheet variable. It then assigns the style sheet to the report using the LoadStyles(styleSheet) method, runs the report, and displays it in the viewer.

See Also

How To