Walkthrough: Style Sheets
ActiveReports adds style class names to allow controls to be formatted easily. With the use of style sheets, groups of controls can be set to a single style with just a few clicks. ClassName and the different controls' Style property can also be used to create specialized styles in code and through scripting.
This walkthrough illustrates how to create and use style sheets in a report.
This walkthrough is split up into the following activities:
- Opening an existing ActiveReport
- Creating style sheets
- Using created style sheets in your report at design time
- Using created style sheets in your report at run time
- Viewing the report
Opening an existing ActiveReport
To open an existing ActiveReport
- Click Open > Project.
- Select your ActiveReport project from the appropriate location and click on it to select it.
- Click Open.
Creating Style Sheets
To create a style sheet
- Click anywhere on the report design surface to select it.
- Click on Report > Settings...
- Click on Styles to display the style sheet.
- Select New to add a new style, or select a predefined style to modify.
- Name the new style "MyNewStyle" and select a base style.
- Modify the properties to set up the desired effect and click OK.
Using Created Style Sheets in a Report at Design Time
To use a created style sheet at design time
- Click on the control to which you wish to apply the style.
- Select "MyNewStyle" from the style sheets drop-down box.
- The new style is applied to your selected control.
Using Created Style Sheets in a Report at Run Time
To write the code in Visual Basic
- Right-click in any section of the design window of your report, and click on View Code to display the code view for the report. At the top left of the code view for the report, click the drop-down arrow and select Detail. At the top right of the code window, click the drop-down arrow and select Format. This creates an event-handling method for the report's Detail_Format event. Add code to the handler to:
- Update the selected control with the style sheet chosen
To write the code in C#
- Click in the Detail section of your report to select it. Click on the events icon in the Properties window to display available events for the section. Double-click Format. This creates an event-handling method for the report's Detail_Format event. Add code to the handler to:
- Update the selected control with the style sheet chosen
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub Detail_Format(ByVal sender As Object, ByVal e As System.EventArgs) Handles Detail.Format
Me.TextBox1.ClassName = "MyNewStyle"
End Sub
//C#
private void Detail_Format(object sender, System.EventArgs eArgs)
{
this.TextBox1.ClassName = "MyNewStyle";
}
Viewing the report
To view the report
- Add the ActiveReports viewer control to a Windows Form.
- Add the code needed to set the viewer document equal to the report document. See Using the ActiveReports WinForm Viewer for help.
Samples | Walkthroughs
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.