ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Saving and Loading to a Memory Stream
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Walkthrough: Saving and Loading to a Memory Stream

Glossary Item Box

ActiveReports allows you to save and load a report as a memory stream. Saving a report as a memory stream makes it possible to save and load reports from a database or pass reports back and forth between DLLs.

This walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data\NWIND.MDB.

When you have completed this walkthrough, you will have a report that looks similar to the following.

Adding an ActiveReport to a Visual Studio project

To add an ActiveReport to your project

  1. Open a new project in Visual Studio.
  2. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptMemoryStream.
  4. Click Open (Add in Visual Studio 2005).

Connecting the report to a data source

To connect the report to a data source

  1. Click on the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Click Build.
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next.
  4. Click the ellipsis button to browse for the access path to the NorthWind database. Click Open once you have selected the appropriate access path.
  5. Click OK to continue.
  6. In the Query field, type "Select * from customers ORDER BY country".
  7. Click OK to return to the report design surface.

Adding controls to the report to contain data

To add controls to the report

  1. Add a GroupHeader/Footer section to rptMemoryStream by right-clicking on the design surface of the report and selecting Insert > Group Header/Footer.
  2. Make the following changes to the group header:
    • Change the name to ghCustomers
    • Change the BackColor property to RosyBrown 
    • Change the DataField property to Country
  3. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto rptMemoryStream and set the properties of each textbox as indicated.

    Field Section Location Text
    Country GroupHeader 0, 0 Country
    CustomerID Detail 0, 0 Customer ID
    CompanyName Detail 1.125, 0 Company Name
    Address Detail 3.01, 0 Address
    City Detail 4.375, 0 City
    Phone Detail 5.437, 0 Phone
  4. Set the CanShrink property of the Detail Section to True.

Adding the viewer to the Windows Form

To add the viewer to the Windows Form

  1. Click on the ActiveReports viewer control in the appropriate toolbox and drag it onto the Windows Form.
  2. Set the viewer control's Dock property to Fill.

Adding  code to the Form_Load event

To write the code in Visual Basic or C#

Viewing the report

To view the report

You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer.

See Also

©2009. All Rights Reserved.