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
- From the File menu of Visual Studio, select Open > Project.
- Navigate to your ActiveReport project 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.
- From the Report menu, select Settings.
- Click on Styles to display the style sheet.
- Click 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.
- Set the ClassName property to MyNewStyle.
- 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 or C#
- Double-click the Detail section of rptParent to create an event-handling method for the Detail Format event of rptParent. 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 Detail1_Format(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Detail1.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 Windows Form Viewer for help.
You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer. |