In a , 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
- In the Report Explorer, right-click the Settings node and select Show.
- 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.
- 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.
- Click the Export styles to file button to save the existing styles in a style sheet.
- 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.
- 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
- In the Report Explorer, right-click the Settings node and select Show.
- In the Report Settings dialog that appears, go to the Styles page.
- On the Style page, click the Import styles from file button.
- A message box warns that current styles will be deleted. Click Yes to continue.
- 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.
- On the , select the control you want to apply the style to and right-click to choose Properties.
- 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 runtime and apply it
- Right-click the gray area outside the design surface and select Properties.
- In the Properties Window that appears, click the Events button. A list of report events appear.
- Select the ReportStart event and double click to create an event-handling method.
- 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 runtime
The following steps assume that you have already loaded an external style sheet to the report.
- On the select the section containing the control.
- In the Properties Window, click the Events button. A list of report events appear.
- Select the Format event and double click to create an event-handling method.
- 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