Samples | Walkthroughs

See Also ActiveReports for .NET Web 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.

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 on Build...
  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. Add a GroupHeader/Footer section to rptMemoryStream.
  2. Make the following changes to the group header:
    • Change the name to ghCustomers
    • Change the DataField property to Country
  3. Add the following controls to the rptMemoryStream:

     

    Control DataField Name Text/Caption Section Location
    TextBox Country txtCountry Country GroupHeader 0, 0
    TextBox CustomerID txtCustomerID Customer ID Detail 0, 0
    TextBox CompanyName txtCompanyName Company Name Detail 1.125, 0
    TextBox Address txtAddress Address Detail 3.01, 0
    TextBox City txtCity City Detail 4.375, 0
    TextBox Phone txtPhone Phone Detail 5.437, 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 © 2005 Data Dynamics, Ltd. All rights reserved.