Using the ActiveReports WinForm Viewer
To use the ActiveReports WinForm Viewer to preview report output
- Add an ActiveReport to your Visual Studio project and rename it rptMain.
- Add a new "Windows Form" to your project.
- Click on the ActiveReports viewer control in the appropriate toolbox and drag it onto Form1.
- Set the viewer control's Dock property to Fill.
To write the code for the viewer in Visual Basic
- Right-click on Form1, and click on View Code to display the code view for the form. At the top left of the code view for Form1, click the drop-down arrow and select (Base Class Events). At the top right of the code window, click the drop-down arrow and select Load. This creates an event-handling method for the Form1_Load event. Add code to the handler to:
- Format the viewer to show the report when it is run
To write the code for the viewer in C#
- Click on the blue section at the top of Form1 to select the form. Click on the events icon in the Properties window to display available events for Form1. Double-click Load. This creates an event-handling method for the Form1_Load event. Add code to the handler to:
- Format the viewer to show the report when it is run
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
MyBase.Load
Dim rpt As New rptMain()
Viewer1.Document = rpt.Document
rpt.Run()
End Sub
//C#
private void Form1_Load(object sender, System.EventArgs e)
{
rptMain rpt = new rptMain();
this.viewer1.Document = rpt.Document;
rpt.Run();
}
Note: You need to include references to the RtfExport and TextExport dlls in order to enable the viewer's copy button
Getting Started | Walkthrough: Customizing the Viewer Control
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.