Glossary Item Box

Samples | Walkthroughs

See Also ActiveReports for .NET 2 Online Help Send feedback to Data Dynamics

Walkthrough: Saving and Loading to a Memory Stream

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 (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. Click on Project > Add New Item.
  3. Select ActiveReports 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 yellow report DataSource icon in the Detail section. This brings up the report DataSource dialog box.
  2. Click the Build... button.
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next >>
  4. Click on the ellipsis to browse for the access path to NWind.mdb. 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. Right-click anywhere on rptMemoryStream and select Insert > Group Header/Footer.
  2. Make the following changes to the group header:
  3. Make the following changes to the Detail section:
  4. Add six text boxes with the following properties to rptMemoryStream (widen as needed):

    DataField Name Text/Caption Section Location
    Country txtCountry Country ghCustomers 0, 0
    CustomerID txtCustomerID Customer ID Detail 0, 0
    CompanyName txtCompanyName Company Name Detail 1.125, 0
    Address txtAddress Address Detail 3, 0
    City txtCity City Detail 4.375, 0
    Phone txtPhone Phone Detail 5.5, 0

     

Adding the viewer to Form1

To add the viewer to Form1

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

Adding  code to the Form1_Load event

To write the code in Visual Basic

To write the code in C#

Samples | Walkthroughs

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.