ActiveReports 6 Online Help
Customize the Viewer Control
Show AllShow All
Hide AllHide All

ActiveReports includes a control to view report output in custom preview forms. The viewer allows developers to modify the toolbars or add custom menu commands to the preview form.

To create a basic preview form

  1. Open a new Windows Forms project in Visual Studio and size the form according to your needs.
  2. From the Visual Studio toolbox, drag the Viewer control onto the form. If you have not added the viewer to the toolbox, see Adding ActiveReports Controls for more information.

  3. In the Properties window, set the Dock property to Fill.
  4. From the Project menu, select Add New Item.
  5. Select ActiveReports 6 File and click the Add button.
  6. Double-click in the title bar of the form to create a Form Load event.
  7. Add the following code to run the report and display the resulting document in the viewer.

    To write the code in Visual Basic.NET

    To write the code in C#

  8. Press F5 to run the project.

To use split windows on the viewer control

  1. With the project running, click the splitter control and drag downward.
  2. When the viewer is split into two sections, report layouts can be examined and report pages can be compared easily.

To add a custom print button to the viewer control

  1. Add a second Windows Form to the project created above and name it frmPrintDlg.
  2. Add a label to frmPrintDlg and change the Text property to This is the custom print dialog.
  3. Add a button to frmPrintDlg and change the Text property to OK.
  4. Back on the viewer form, double-click the title bar of the form to create a Form Load event.
  5. Add the following code to the Form Load event to remove the default print button and add your own.

    To write the code in Visual Basic.NET

    To write the code in C#

  6. Add the following code to the Viewer ToolClick event to display frmPrintDlg when the custom print button is clicked.

    To write the code in Visual Basic.NET

    To write the code in C#

  7. Press F5 to run the project and see the custom MyPrint button on the viewer.
See Also

Getting Started