This sample demonstrates how you can change styles at run time to provide a different look to a same report. The project includes two reports, three report styles and a form containing the ActiveReports Viewer control and other controls that allow you to select any combination of styles and reports.
Visual Basic.NET
https://github.com/activereports/Samples18/tree/main/API/Section/Stylesheets/VB.NET
C#
https://github.com/activereports/Samples18/tree/main/API/Section/Stylesheets/C#
Choose Report
Choose between the type of report, Categories and Product List, you want to display in the Viewer control.
Choose Style
Choose between Classic, Colored and External style sheet options to apply the style to the selected report.
Clicking the Choose button option for External style sheet displays the 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 this button to display the selected report with the applied style in a Viewer control. Clicking this button creates an SectionReport 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.
The sample consists of:
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 Working with External Style Sheets.
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 SectionReport 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.