ActiveReports 11
Use External Style Sheets
ActiveReports 11 > ActiveReports User Guide > How To > Section Report How To > Use External Style Sheets

In a section layout, you can set custom style values in the Styles page of the Report Settings Dialog, and then apply the styles to controls using the ClassName property from the Properties Window.

You can also apply these same styles to controls in other reports, by exporting them to a XML file of type *.reportstyle and selecting it in other reports using the Report Settings dialog.

Note: You can apply styles to the CheckBox, Label, TextBox, and ReportInfo controls only.

To modify or create a style and save it to an external style sheet

  1. In the Report Explorer, right-click the Settings node and select Show.
  2. In the Report Settings dialog that appears, go to the Styles page. On the Styles page, there are four predefined styles: Normal, Heading1, Heading2 and Heading3.
  3. Click any of these styles in the list to modify them using the fields on the right, or click the New button to add a new style.
  4. Click the Export styles to file button to save the existing styles in a style sheet.
  5. In the Save As dialog that appears, navigate to the location where you want to save the style sheet, provide an name for the file and click the Save button to save it as an external *.reportstyle file.
  6. In the Report Settings dialog, click the OK button to close the dialog and save the styles in the current report.

To load and apply an external style sheet at design time

  1. In the Report Explorer, right-click the Settings node and select Show.
  2. In the Report Settings dialog that appears, go to the Styles page.
  3. On the Style page, click the Import styles from file button.
  4. A message box warns that current styles will be deleted. Click Yes to continue.
  5. In the Open dialog that appears, navigate to the *.reportstyle file that you want to use and click the Open button to load the external style sheet.
  6. On the design surface, select the control you want to apply the style to and right-click to choose Properties.
  7. In the Properties Window, from the Class Name property drop down select a style to apply (like Heading1).

To load an external style sheet at run time and apply it

  1. Right-click the gray area outside the design surface and select Properties.
  2. In the Properties Window that appears, click the Events button. A list of report events appear.
  3. Select the ReportStart event and double click to create an event-handling method.
  4. Add the following code to the handler to load an external style sheet.
    Visual Basic.NET code. Paste INSIDE the ReportStart event.
    Copy Code
    Me.LoadStyles("C:\MyStyleSheet.reportstyle")
    C# code. Paste INSIDE the ReportStart event.
    Copy Code
    this.LoadStyles(@"C:\MyStyleSheet.reportstyle");

To apply a style to a control at run time

The following steps assume that you have already loaded an external style sheet to the report.

  1. On the design surface select the section containing the control.
  2. In the Properties Window, click the Events button. A list of report events appear.
  3. Select the Format event and double click to create an event-handling method.
  4. Add the following code to the handler to apply a style to a control.
    Visual Basic.NET code. Paste INSIDE the Format event.
    Copy Code
    Me.TextBox.ClassName = "Heading1"
    C# code. Paste INSIDE the Format event.
    Copy Code
    this.textBox.ClassName = "Heading1";
See Also

Concepts