Activereports For - Net User Guide PDF
Activereports For - Net User Guide PDF
Activereports For - Net User Guide PDF
ActiveReports for .NET is a fully-integrated product which combines the features of the Visual
Studio programming languages with user-friendly controls to provide a powerful report designer.
o ActiveReports Editions
o Data Dynamics Copyright Notice
o ActiveReports License Agreement
o Frequently Asked Questions
o Installation and Setup
o Upgrading Reports
o Architecture and Concepts
o Getting Started
ActiveReports Editions
o Standard Edition Features
o Professional Edition Features
Designer
Reporting Engine
Managed code
Binding to ADO.NET, XML and custom data sources
Easy deployment with the report processing engine as a single assembly dll
All of ActiveReports 2.0 features
Report Viewer
Managed C# code
Very small deployment assembly, suitable for use on the Internet
Table of Contents/Bookmarks
Hyperlinking
Export Filters
ActiveReports includes export filters to generate output into Rich Text Format (RTF) for word-
processing, Portable Document Format (PDF), Microsoft Excel worksheets, HTML and DHTML
for publishing your reports to the internet, TIFF for optical archiving and faxing and delimited text
for spreadsheets and databases.
The End-User Report Designer control is a run-time designer that may be distributed royalty free.
It allows the ActiveReports designer to be hosted in an application and provides end-user report
editing capabilities. The control's methods and properties provide easy access to save and load
report layouts, monitor and control the design environment, and customize the look and feel to
the needs of end users.
ASP.NET Integration
Web server control provides convenience for running and exporting reports in ASP.NET.
HTTP Handler extensions allow report files (RPX) or compiled assemblies containing
reports to be dropped on the server and hyperlinked.
The Web Viewer control allows quick viewing of ActiveReports on the web as well as
printing capability with the ActiveXViewer and AcrobatReader ViewerType properties.
HTTP Handlers
The RPX HTTP Handler allows hyperlinking of an ActiveReport on a web page to return a
HTML format or PDF format of the report for viewing and/or printing.
Compiled Report HTTPHandler allows hyperlinking of an ActiveReport compiled in an
assembly on a web page to a HTML format or PDF format of the report for viewing and/or
printing.
Copyright Notice
Information in this document, including URL and other Internet Web site references, is subject to
change without notice. Unless otherwise noted, the example companies, organizations, products,
domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious,
and no association with any real company, organization, product, domain name, e-mail address,
logo, person, place or event is intended or should be inferred. Complying with all applicable
copyright laws is the responsibility of the user. No part of this document may be reproduced,
stored in or introduced into a retrieval system, or transmitted in any form or by any means
(electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the
express written permission of Data Dynamics, Ltd.
ActiveReports and the ActiveReports logo are registered trademarks of Data Dynamics, Ltd.
All other trademarks are property of their respective owners.
License Agreement
The product in this package (libraries and object code) is proprietary to Data Dynamics, Ltd. and
is protected by Federal Copyright Law. Data Dynamics retains the title to and ownership of the
Product. You are licensed to use this Product on the following terms and conditions:
LICENSE:
The licensee is defined as the individual software developer utilizing the Product. This license is
not for an entire company but for a single developer. Data Dynamics hereby grants the licensee a
nonexclusive license authorizing the licensee to use the enclosed Product on one computer at a
time for development purposes. Distribution of the application(s) using ActiveReports is royalty-
free, requiring no additional license fees. You may incorporate the sample code into your
applications. Use of this product by more than one individual or by anyone other than the licensee
terminates, without notification, this license and the right to use this product.
Distribute, rent, sub-license or otherwise make available to others the software or documentation
or copies thereof, except as expressly permitted in this License without prior written consent from
Data Dynamics. In the case of an authorized transfer, the transferee must agree to be bound by
the terms and conditions of this License Agreement.
RESTRICTIONS:
You may use this Product in your business application for sale or distribution as long as:
The product that you produce and/or distribute is NOT a software development product, a product
that is sold primarily to software developers or system integrators or a development environment
of any kind. Please contact Data Dynamics, Ltd. for special commercial licensing provisions in
these circumstances.
The software serial number and user must be registered with Data Dynamics in order to receive
support or distribution rights.
You may not remove any proprietary notices, labels, and trademarks on the software or
documentation.
You may not modify, de-compile, disassemble, reverse engineer or translate the software.
Use, duplication or disclosure by the United States Government is subject to restrictions as set
forth under DFARS 252.227-7013 or in FARS 52.227-19 Commercial Computer Software -
Restricted Rights.
TERM:
You may terminate your License and this Agreement at anytime by destroying all copies of the
Product and Product Documentation. They will also terminate automatically if you fail to comply
with any term or condition in this Agreement.
LIMITED WARRANTY:
This software and documentation are sold "as is" without any warranty as to their performance,
merchantability or fitness for any particular purpose. The licensee assumes the entire risk as to
the quality and performance of the software. Data Dynamics warrants that the media on which the
Program is furnished will be free from any defects in materials. Exclusive remedy in the event of a
defect is expressly limited to the replacement of media. In no event shall Data Dynamics or
anyone else who has been involved in the creation, development, production, or delivery of this
software be liable for any direct, incidental or consequential damages, such as, but not limited to,
loss of anticipated profits, benefits, use, or data resulting from the use of this software, or arising
out of any breach of warranty.
Unmanaged DLLs:
ActiveReports.Interop.DLL - This is the auxiliary COM interop DLL. Unsafe C# code for
OLE object hosting and other COM functions.
ARExport*.DLL - These are the export filters. Managed wrappers around unmanaged
VC++ code.
Note The export DLLs will be converted to managed C# after the first release. The above are
the only distributable DLLs. The core components are all managed and use all of what .NET has
to offer.
1. The control selected in the components list was for the wrong viewer control.
ActiveReports has two separate viewer controls. One is
DataDynamics.ActiveReports.WebViewer, which is a viewer control that only works on
Web Forms, and the other is DataDynamics.ActiveReports.Viewer, which is a viewer
control that works only on Windows Forms.
2. The correct form is not selected. If a Windows Form or Web Form is not selected in the
project, the viewer icon may be grayed out. Verify the correct viewer component is
selected for the project:
For the Windows Form Viewer - DataDynamics.ActiveReports.Viewer -
ActiveReports.Viewer(x.x.x.xxxx)
For the WebForm Viewer - DataDynamics.ActiveReports.Web -
ActiveReports.WebViewer(x.x.x.xxx)
o Requirements
o Installed Files
o Troubleshooting Installation
o Verifying Package Installation
Tip Close Visual Studio .NET before running the installation program to allow
the help files to be integrated into Visual Studios common help collection.
Software requirements
Installed Files
Folder/Files Description
<Common Files>\Data Dynamics\ActiveReports for .NET
ActiveReports.DLL Run-time engine assembly file
ActiveReports.Design.DLL Designer assembly file
ActiveReports.Interop.DLL Native functions assembly file
ActiveReports.Viewer.DLL Viewer assembly file
ActiveReports.Web.DLL Web assembly file
ActiveReports.Web.Design.DLL Web designer assembly file
ARVSPackage.DLL Visual Studio .NET Integration Package
ActiveReports.HtmlExport.DLL HTML Export DLL
ActiveReports.PdfExport.DLL PDF Export DLL
ARExportTIFF.DLL TIFF Export DLL
ARExportExcel.DLL Excel Export DLL
ARExportRTF.DLL RTF Export DLL
ARExportText.DLL Text Export DLL
ARCol.Hx* ActiveReports Help Integration Collection
ddARRef.HxS ActiveReports Help File--Class Library
ddARUG.HxS ActiveReports Help File--User Guide
License.rtf Data Dynamics ActiveReports License Agreement and
Limited Warranty
<Common Files>\Data Dynamics\ActiveReports for .NET\1033
ARVSPackageUI.DLL Visual Studio .NET integration DLL localized UI
<Common Files>\Data Dynamics\ActiveReports for .NET\Wizards
ARAccessWizard.DLL Access to ActiveReports wizard
ARDBWizard.DLL New Report Wizard Add-In
ARInstallExt.DLL ActiveReports installation auxiliary file
arinstallext.InstallState ActiveReports installation auxiliary file
DDAccessHelper.dll Access wizard auxiliary file
WebKey.exe Web.config key generator
ARTaskPane.DLL Report Wizards IDE Task Pane
<Application Folder>
Data\Nwind.mdb Samples database file
Data\streamSample.mdb Streaming sample database file
Deployment\ActiveReportsDistrib.msm ActiveReports merge module file
Deployment\arview2.cab ActiveX viewer cab file
Introduction\iddlogo.gif Readme image file
Introduction\itopimage1.gif Readme image file
Introduction\itopimage2.gif Readme image file
Introduction\assemblies.gif Readme image file
Introduction\readme.html ActiveReports Readme file
Samples\samples.txt Samples description text file
Samples\CSharp\*.* C# sample projects
Samples\VB\*.* Visual Basic sample projects
Troubleshooting Installation
Why can't other users access or use ActiveReports on my machine?
The installation for ActiveReports for .NET gives the user the option to install the program for
everyone or the current user. If it is installed only for the current user, other users on the same
machine will not be able to access it or use it.
I just installed ActiveReports for .NET. Why can't I see the help files?
If the installation was run while Visual Studio was open, the help files will not be integrated until
the user exits Visual Studio and reopens it.
Why do I get, "The installer was interrupted before Data Dynamics ActiveReports for
.NET... could be installed. You need to restart the installer to try again" when I run the
ActiveReports Setup?
The most likely cause for this error is a permissions issue. Either the folder the setup is pointing
to or the folder containing the setup files does not have the correct permissions. The user needs
to verify the system account for the local machine has permissions to the folder containing the
setup and verify the user installing the program has the appropriate permissions.
Data Dynamics attempted to keep to a minimum the number of changes to the report object
model from ActiveReports 2.0. Most of the changes are due to class refactoring and renaming of
objects and members to closely match the .NET Framework naming conventions. Listed below
are the significant changes in the object model.
Printing
A rewritten report viewer control to take full advantage of the .NET framework classes.
Complete revision of the Toolbar and Tools classes.
Separation of the Table of Contents tree control from the TOC collection (renamed to
BookmarksCollection).
No binding of the viewer control to an ActiveReport object. Instead, it binds to a
Document object.
o Events
o Layout Files
o Parameters
o Report and Page Settings
o Report Execution
o Report Structure
o Scripting
Events
In a report, regardless of the type or content of the various sections, there are three events for
each section: Format, BeforePrint and AfterPrint.
Because there are many possible report designs, the event-firing sequence must be dynamic in
order to accommodate individual report demands.
Out of the three events, the Format event generally is used the most often, followed by the
BeforePrint event and, in rare circumstances, the AfterPrint event.
Format event
This event fires after the data is loaded and bound to the controls contained in a section, but
before the section is rendered to a page.
The format event is the only event where the section's height may be changed. This section may
be used to set or change the properties of any controls or load subreport controls with subreports.
If the CanGrow or CanShrink property of any control contained with a section, or the section itself,
is set to true, all of the growing and shrinking of controls contained in this section, and the section
itself, takes place in the Format event. Because of this, information about a control or a section's
height cannot be obtained in this event.
BeforePrint event
The growing and shrinking of the section and all controls contained in a section have already
taken place by the time this event fires. Use this section to resize any controls if needed.
Since all controls and section growth have already taken place by the time this event fires, this
event may be used to get an accurate height of the section, or, if needed, any controls contained
in it. Any controls in the BeforePrint event may be resized but not the height of the section itself.
AfterPrint event
Although AfterPrint was an important event prior to ActiveReports Version 1 Service Pack 3, it is
rarely used in any of the newer builds of ActiveReports. When you place code in the section
events, you likely will place your code in either the Format event or the BeforePrint event. This
event is still useful for drawing on the page after text has already been rendered to the page.
Layout Files
Report layouts in ActiveReports are automatically saved as RPX files. This is an XML-formatted
file which contains the layout information and can contain the scripts of the report. RPX files using
scripting allow distributed reports to be changed and modified without having to recompile the
project. They also make it possible to use a database of report file names to set up a collection of
reports to run. An RPX file using scripting also can be used as a stand-alone file in a web project
or a stand-alone file for the HTTP handler.
Parameters
Parameters and Simple Reports
The Parameters dialog can be used to prompt the user for input when reports are generated. If
you add <%FieldName | PromptString | DefaultValue | Type%> to the reports SQL string, it will
cause the Parameters dialog to be displayed.
The Field name is the name of the field you wish to request (e.g. CustomerID or LastName). The
Prompt string is a string value indicating text that will appear in the dialog next to the control (e.g.
Enter Customer ID:). Setting the default value will automatically set a default value. For example,
if you have a report that generates based on a date, you can have the default for the field set to
the current date so users can just hit "Enter", unless they want to generate a report based on a
new date. Type indicates what type of data will be requested.
The values can be: nothing(string), S for string, D for date, B for Boolean. A string type will give a
textbox for input, a D type will give a calendar drop-down control for input and a B type will give a
checkbox for input.
Note For Strings: If you specify a default value that is enclosed in single or
double quotes, it will be recognized and will output the same quotes to SQL when
replacing. For Booleans : if you specify true/false for DefaultValue it will generate
true/false for SQL output. If you specify 0,1, it will output 0 or 1.
Example: "SELECT * FROM products INNER JOIN categories ON products.categoryid =
categories.categoryid WHERE products.supplierID =<%SupplierID|Enter supplierID|1000%> and
OrderDate=#<%Date|Order date:|1/1/2001|D%># and Discount=<%bool| Is this checked
?|true|B%>"
Note The FieldName is the only required parameter; the rest are optional.
Parameters can be used with subreports to connect the subreport to the parent report. By setting
a parameter for the field that links the parent report to the child subreport, the parent report can
pass the information to the child through the parameters. The main differences when working with
subreports and parameters are:
With ActiveReports, page setup in your report can be modified at design time, as well as at run
time. The Page Setup dialog can be accessed by selecting Report > Settings... from the toolbar
menu.
From the Page Setup dialog, changes can be made to the report margins (left, right, top and
bottom), a gutter can be specified and the Mirror margins option can be selected.
By setting a gutter and selecting Mirror margins, reports can be set up easily for publishing
purposes. When Mirror margins is selected, the inner margins in the report are set for opposite
pages to be the same width and the outside margins for opposite pages to be the same width.
Specifying a gutter gives extra space between the edge of the page and the margins. This allows
reports to be bound together.
With ActiveReports, printer settings can be modified at design time, as well as run time. The Print
Settings dialog (shown below) can be accessed by selecting Report > Settings... from the
toolbar menu and then selecting the Printer Settings option button from the Report Settings dialog
box.
From the Printer Settings dialog, changes can be made to the printer paper size and orientation.
A custom paper size can be set by selecting Custom paper size from the Paper size drop down
box. Once this option has been selected, the width and height options will allow a specific height
and width to be set.
The Printer Settings dialog also lets the user choose the type of collation to use, whether or not
the report should be duplexed and the location of the paper source.
With ActiveReports, style sheet settings can be created and/or applied. The Styles dialog (shown
below) can be accessed by selecting Report > Settings... from the toolbar menu and then
selecting the Styles option button from the Report Settings dialog box.
From the Styles dialog, changes can be made to the appearance of text associated with controls,
either by applying an existing style sheet, creating and applying a new style sheet or by modifying
and applying an existing style.
With ActiveReports, global report settings can be modified at design time. The Global Settings
dialog (shown below) can be accessed by selecting Report > Settings... from the toolbar menu
and then selecting the Global Settings option button from the Report Settings dialog box.
From the Global Settings dialog, changes can be made to the design surface, including showing
or hiding the grid, setting the controls to align to the grid, setting the number of column or rows on
the grid and changing the ruler units to inches or centimeters.
Report Execution
ActiveReports report execution begins by raising the ReportStart event. At this point, accessing
data source properties might cause DataInitialize to fire. The report validates any changes made
to the report structure in ReportStart.
If DataInitialize is not fired during the ReportStart event, it will be fired. The data source will be
opened. If there are any parameters in the data source with unset values and
"ShowParameterUI" is set to True, ActiveReports displays a parameters dialog and fires
"ParameterUIClosed" when the dialog is closed. If the report is a subreport and requires
parameters, ActiveReports binds the subreport parameters to any fields in the parent report.
Next, the FetchData event fires. If there is no data, the NoData event is raised.
Events are then fired for processing the report header, followed by page header, groups, detail
and page footer for each page in the report. The cancel flag is checked after each event.
The speed in processing and output generation of ActiveReports is attributed to its intelligent,
multi-threaded, single-pass processing. ActiveReports will process and render each page as soon
as the page is ready. If ActiveReports is not able to fully render a page because of unknown data
elements or because the layout is not final, it places the page in cache until the data is available.
Summary fields and KeepTogether constraints are two reasons that a page might not be
rendered completely. The summary field is not complete until all the data needed for calculation is
read from the data source. When a summary field such as a grand total is placed ahead of its
completion level, such as in the report header, the report header and all following sections will be
delayed until all of the data is read.
The KeepTogether property determines whether a section should print in its entirety on the same
page. When this property is set to True, the section will print on the same page without any page
breaks. A False setting allows the section to be split across two or more pages. If the
KeepTogether property is set to True, but the section is too large for the current page, or to fit
fully on the next page, the KeepTogether property will be ignored.
The GroupKeepTogether property determines whether group header and footer sections will print
as a single block on the same page. The property defaults to None which allows the group block
to be split across pages. When you set this property to All, ActiveReports attempts to print the
complete block on the same page without any page breaks. When a complete block does not fit
on a single page, it will be split across two or more pages. The third option, FirstDetail, prevents
any widowed group header sections. The group header will always print with at least one detail
section.
Report Structure
A report section contains a group of controls that are processed and printed at the same time as
a single unit. ActiveReports defines the following section types:
Report Header
A report can have one report header section that prints at the beginning of the report. This section
generally is used to print a report title, a summary table, a chart or any information that needs
only to appear once at the report's start.
Report Footer
A report can have one report footer section that prints at the end of the report. This section is
used to print a summary of the report, grand totals or any information that needs to print once at
the report's end.
Page Header
A report can have one page header section that prints at the top of each page. It is the first
section that prints on the page except when the page contains a report header section. The page
header section is used to print column headers, page numbers, a page title or any information
that needs to appear at the top of each page in the report.
Note It is not recommended to bind controls to a page header as results may be
unpredictable.
Page Footer
A report can have one page footer section that prints at the bottom of each page. It is used to
print page totals, page numbers or any other information that needs to appear at the bottom of
each page.
Group Header/Footer
A report can consist of single or multiple nested groups, with each group having its own header
and footer sections. The header section is inserted and printed immediately before the detail
section. The footer section is inserted and printed immediately after the detail section.
Detail
A report has one detail section. The detail section is the body of the report and one instance of
the section is created for each record in the report.
Scripting
ActiveReports allows you to use scripting to provide ease in reporting functionality. Scripting
permits reports saved to an RPX file to contain code. This characteristic allows the options of
stand-alone reporting and web reporting without requiring .vb or .cs files. By including scripting
when the report is saved as an RPX file, it can later by loaded, run and displayed directly to the
viewer control without using the designer. Scripting can also be used in conjunction with RPX files
to allow distributed reports to be updated without recompiling.
Scripting can be used by adding C# code to the script editor at design time or by using rpt.Script
at run time. The script is then saved to the RPX file.
The AddNamedItem and AddCode methods are used to add items to the reports script. By using
AddNamedItem or AddCode, code elements from inside the .NET project can be used inside the
scripts. By using AddNamedItem, scripts can become aware of functions in a class contained in
the .NET project. By using AddCode, actual code segments can be added to the script at run
time. Since the RPX file can be read with any text editor, AddCode or AddNamedItem can be
used to add secure information to a project, such as a connection string.
AddScriptReference can be used to add an assembly reference to the script. This will allow users
to add a reference in the script to access assemblies in their projects. AddScriptReference is only
needed if the script accesses assemblies that are not already initialized in the project. For
example, to access "System.Data.DataSet" inside the script, you would need to add a reference
by calling "rpt.AddScriptReference("System.Data.Dll")".
o ActiveReports Designer
o Adding ActiveReports Controls to the Visual Studio Toolbox
o Adding an ActiveReport to a Visual Studio .NET Project
o Binding Reports to a Data Source
o Grouping Data
o Licensing Applications
o Localizing the Viewer Control
o Manually Configuring Web Samples
o Metric Units
o Saving and Loading RDF Files
o Saving and Loading RPX Files
ActiveReports Designer
With its various tools and qualities, ActiveReports for .NET offers great flexibility in constructing
report projects. In this section, you will learn how to use the different features of the
ActiveReports Designer.
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
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Design Surface
The ActiveReports design surface leverages your current knowledge of Visual Studio .NET's
designer interface and provides full integration within the Visual Studio environment.
The default ActiveReports design surface is made up of the following base components:
PageHeader--This section can be used to print column headers, page numbers, page titles, or
any information that needs to be printed once at the top of each page.
Detail section--This section is the body of the report that prints once for each record in the data
source.
DataSource control icon--This control can be used to connect the report's data source settings to
an existing data source.
PageFooter--This section can be used to print page totals, page numbers or any other
information that needs to be printed once at the bottom of each page.
Report Menu
The report menu allows access to load report layouts, modify the report data source or modify
report settings.
Load Layout--the Load Layout option allows access to load an existing report layout into
the open ActiveReport.
Data Source--the Data Source option allows access to add Data Source parameters or
modify existing Data Source settings.
Settings--the Settings option allows access to change printer or page settings, style
sheets or global settings.
Toolbars
The toolbars in ActiveReports can be easily customized. ActiveReports' toolbars allow developers
to rearrange buttons and menu options, as well as hide, display, dock or float toolbars.
The context menu allows you to show or hide toolbars by selecting the toolbar name from the
menu. In addition, you can customize the toolbars or create a new toolbar from the customize
option on the menu.
The ActiveReports toolbar is made up of the following components:
Report Explorer--Shows or hides the report explorer tree and the fields list
Style Sheets--Sets the style sheet for a control
Font--Sets the typeface of the selected label, checkbox or textbox control
Size--Sets the font size of the selected label, checkbox or textbox control
View Grid--Turns the grid display on or off
Reorder Groups--Displays the groups order dialog
Edit Script--Starts ActiveReports Script Editor
Bold--Sets the bold typeface on or off
Italic--Sets the italic typeface on or off
Underline--Sets the underline typeface on or off
Align Left--Aligns the text left in the control area
Align Center--Aligns the text centered in the control area
Align Right--Aligns the text right in the control area
Justify--Justifies the text in the control area
Bullets--Adds bullets to the text in the RichText control area
Decrease Indent--Decreases the indent of the text in the RichText control area
Increase Indent--Increases the indent of the text in the RichText control area
Toolbox
The ActiveReports toolbox displays a variety of controls available for use in ActiveReports. The
items available from the toolbox change depending on the designer currently in use.
1. Right-click on the toolbox tab where you want to add ActiveReports controls.
2. Select Customize Toolbox.
3. Select .NET Framework Components tab.
4. Select the Designer, ReportExplorer, Viewer and WebViewer controls in
DataDynamics.ActiveReports namespaces in the components list view.
Visual Studio creates and displays the following ActiveReports designer document.
Binding Reports to a Data Source
ActiveReports allows much flexibility in binding reports to various kinds of data sources. In this
section, you will learn how to use various methods to bind reports to data sources.
Note DAO and RDO data controls are no longer supported in ActiveReports for
.NET. The ADO data control is converted to an ADO.NET data source. Data
controls are removed and replaced with a report data source dialog accessible
from the data source icon on the detail section of the report. The XML Data
control is converted into an XML data source.
o Using a Data Set
o Using a Data View
o Using the Data Source Icon
Data Set
In addition to being able to set the reports data source at design time, it is also possible to set the
reports data source at run time to a data set. This makes it easy to use data sets created with
Microsofts data controls in your reports. To use a data set, set the reports DataSource property to
the data set being used and the reports DataMember property to the table from which the reports
data is derived.
The following example shows what the code for the method looks like:
[Visual Basic]
Dim rpt As New rptDataView()
rpt.DataSource = Me.dataSet11
rpt.DataMember = "employees"
[C#]
Data View
In addition to using a data set, the reports data source can be set to a data view. This can be
useful for creating reports containing filtered information. To use the data view in the report, set
the reports DataSource property to the data view created from the filtered data set (see Using a
Data Set for more information).
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
DataView usView;
private void Form1_Load(object sender, System.EventArgs e)
{
string m_dbPath = getDatabasePath();
this.oleDbConnection1.ConnectionString = "Pro
Data Source=" + m_dbPath + "\\NWIND.MDB;Persist Secu
this.oleDbDataAdapter1.Fill(this.dataSet11);
usView = new DataView(this.dataSet11.Tables["employees"]);
usView.RowFilter = "Country ='USA'";
this.dataGrid2.DataSource = usView;
}
DataSource Icon
ActiveReports makes it easy to bind your report to a data source by using the yellow DataSource
icon located in the Detail section of the report design surface or by accessing the DataSource
dialog from the Report Settings menu.
Grouping Data
In ActiveReports, a report can consist of single or multiple nested groups, with each group having
its own header and footer sections. The header section is inserted and printed immediately before
the Detail section. The footer section is inserted and printed immediately after the Detail section.
Up to 32 nested groups are allowed in a single report.
Note ActiveReports does not order records for grouping. It assumes the data is
already sorted in the same grouping order. The data source needs to be ordered
by the field on which you want your data grouped to achieve the desired results.
1. Right-click in the Detail section of the report design surface, select Insert, and click on
Group Header/Footer.
2. This will insert a new group header/footer section into your report.
3. In the Properties window for the group header, change the DataField property to the field
on which you want your data grouped.
4. Change the name of the group header to reflect the field on which data is being
grouped. For example, "ghCategories" would be the name of the group header field with
the DataField property of "CategoryID".
Licensing Applications
Checking ActiveReports Windows Applications for Licensing
To check an existing ActiveReports Windows application for licensing
3. If the ActiveReports application is licensed, you will see a file called "licenses.licx".
4. If the "licenses.licx" file is not listed in your application's file list, you will need to manually
set up the application for licensing.
1. From the Start bar, click on All Programs > Microsoft Visual Studio.NET > Visual
Studio .NET Tools > Visual Studio .NET Command Prompt.
2. Change the prompt path to reflect the location of your localization.txt file.
3. Type "resgen localization.txt localization.resources" .
4. This creates a resources file in the same location as the text file.
1. Open your ActiveReports Windows application which includes a Windows Form with an
ActiveReports Windows Forms Viewer control.
2. In the Solution Explorer window, click on the icon to "Show All Files".
3. Right-click on the name of your project and click Add > Add Existing Item...
4. Select the appropriate file path to the localization.resources file and click Open.
5. This adds the resources file to your application.
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.
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.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Note If you are only configuring Standard Edition Web Samples, you do not
need to complete the following steps.
9. Click OK to add the mapping and return to the Application Configuration dialog.
To configure the compiled report handler (continuing from Step 9 in "To Configure the
HTTPHandler)
1. In the Application Configuration dialog, click Add to add a new Application Mapping.
2. In the Executable field, paste the value copied from Step 6 above.
3. Enter .ActiveReport in the Extension field.
4. Make sure the "Check that file exists" permission is unchecked.
5. Click OK to add the mapping and return to the Application Configuration dialog.
1. In the Application Configuration dialog, click Add to add a new Application Mapping.
2. In the Executable field, paste the value copied from Step 6 above.
3. Enter .ArCacheItem in the Extension field.
4. Make sure the "Check that file exists" permission is unchecked.
5. Click OK to add the mapping and return to the Application Configuration dialog.
6. Click OK on the remaining open dialogs to exit the IIS Administrative tool.
Metric Units
In ActiveReports, ruler measurements can be changed from inches to centimeters and
centimeters to inches from design time. Conversion values for centimeters to inches or inches to
centimeters can be called at run time as well.
Call the CmToInch method or InchToCm method whenever needed. For example, if you were
working in centimeters and needed to convert a label's position measurements from centimeters
to inches at run time, you would use the following code.
[Visual Basic]
Me.lblMyLabel.Left = ActiveReport.CmToInch(2)
Me.lblMyLabel.Top = ActiveReport.CmToInch(2)
[C#]
this.lblMyLabel.Left = ActiveReport.CmToInch(2);
this.lblMyLabel.Top = ActiveReport.CmToInch(2);
Right-click in any section of the Windows Form, and click on View Code to display the
code view for the Windows Form. Add the following code to create the saveRDF event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
To write the code to load the saved RDF into the ActiveReports viewer in Visual Basic
Right-click in any section of the Windows Form, and click on View Code to display the
code view for the Windows Form. Add the following code to create the loadRDF event.
To write the code to load the saved RDF into the ActiveReports viewer in C#
Double-click on the Windows Form to see the code view for the Windows form. Add the
following code to create the loadRDF event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the Windows Form, and click on View Code to display the
code view for the Windows Form. Add the following code to create the saveRPX event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
To write the code to load the saved RPX into the ActiveReports viewer in Visual Basic
Right-click in any section of the Windows Form, and click on View Code to display the
code view for the Windows Form. Add the following code to create the loadRPX event.
To write the code to load the saved RPX into the ActiveReports viewer in C#
Double-click on the Windows Form to see the code view for the Windows form. Add the
following code to create the loadRPX event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Note When saving to an RPX file, make sure you save the report before it runs.
Saving the layout after the report runs will result in unwanted data being saved in
the layout. If calling saveRPX inside the report, use the ReportStart event. Also,
when saving the report layout, the script code is the only code that is saved to
the file. The code in the reports .cs or .vb file will not be saved to the RPX file.
Getting Assistance
This topic will show you how to locate Readme information as well as how to obtain support for
ActiveReports for .NET.
o Readme File
o Product Support
Readme File
The file, Readme.html, will be located in the Introduction folder in the root ActiveReports for
.NET installation folder on your computer once the program is installed. Use your Internet
browser to open and view the file.
Product Support
This topic will explain how to register your ActiveReports for .NET purchase and obtain technical
support.
In this section
o Product Registration
o Technical Support
Product Registration
In order to receive telephone support, product news and upgrade announcements, you must
register your product purchase with Data Dynamics. We encourage you to register your purchase
as soon as you receive it using any of the following:
Fill out the enclosed registration card and mail it to Data Dynamics, 5870 Cleveland
Avenue, Columbus, Ohio 43231
Fax the registration card to Data Dynamics at (614) 899-2943
Complete the registration form on our website at
http://www.datadynamics.com/register/default.htm
Technical Support
Technical support is available for ActiveReports for .NET in a variety of media.
Telephone Support
Telephone support is available for registered users of ActiveReports for .NET for up to five
support incidents. Additional support requests should be directed to the appropriate newsgroup. If
desired, additional telephone support can be acquired by purchasing any of the support packages
available through Data Dynamics. Contact [email protected] for details.
When contacting Data Dynamics with support questions, be prepared to provide a serial number,
the full version number of ActiveReports, a complete description of the problem and hardware
and operating environment specifications.
E-mail Support
E-mail support is available for ActiveReports for .NET. Contact
[email protected].
Website
The Data Dynamics website offers the latest product news, white papers, tutorials, report
samples and product service packs. Please visit the website for the latest news about
ActiveReports for .NET before contacting technical support.
Product Upgrades
Minor upgrades and service packs will be made available for download from the Data Dynamics
website free of charge.
http://www.datadynamics.com/downloads.asp
Major upgrades will carry an upgrade price that is determined separately for each release. You
will be eligible for a free major upgrade if you purchased the product within 30 days of the
upgrade release date.
KnowledgeBase articles
The Data Dynamics KnowledgeBase contains hundreds of helpful articles for all Data Dynamics
products. You can search the entire KnowledgeBase for keywords or narrow down your search
first by choosing a specific product before submitting your search criteria.
http://www.datadynamics.com/kb
Newsgroups
The Data Dynamics news server can be used to read and post questions and answers about
issues you encounter with ActiveReports for .NET. Tips and tricks can be communicated with
other users and access to the Data Dynamics technical support team can be gained in an online
community forum. Data Dynamics' technical support engineers monitor the newsgroups
constantly and are available to answer questions and assist with any issues encountered using
the product.
In this section
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
You must also have access to Internet Information Services either from your computer or from the
server. You must also run the "Configure Web Sample" option from the Data Dynamics
ActiveReports for .NET program menu from your Windows Start button.
When you have completed this walkthrough, you will have a report that looks similar to the
following.
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 products order by categoryID".
7. Click OK to return to the report design surface.
1. Open Windows Explorer and browse to the folder in which ActiveReports for .NET is
installed.
2. Double-click the Deployment folder. Copy the file called "arview2.cab" by right-clicking on
the file and selecting Copy.
3. Browse to the folder in which your project is contained.
4. Paste the .cab file into your project's folder.
1. Open Windows Explorer and browse to the folder in which your project is contained.
2. On the File menu, click New, Folder.
3. Name the folder "ReportOutput".
4. Make sure that you have write permissions for this folder.
In the body of the HTML view of the Web Form, add the following code:
1. At the top of the HTML view of the Web Form, click on the drop-down arrow for "Client
Objects and Events" and select "window".
2. Click the drop-down arrow for the available events to the right of "window" and select
"onload."
3. This creates an event-handling method for the Web Form's window_onload event.
4. Add the following code to the window_onload event:
arv.datapath = "ReportOutput/axreport.rdf";
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Column Reports
ActiveReports supports newspaper column layout in both the Detail and Group sections. You can
render the columns either horizontally or vertically in the section with options to break the column
on Group section (i.e. start a new column on the change of a group).
Labels
ActiveReports can be used to print any label size by using the newspaper column layout.
ActiveReports allows you to skip labels on a label sheet using the LayoutAction property.
LayoutAction can be used to skip a section (i.e. do not print anything and move to the next
printable area). For each label you wish to skip, set the LayoutAction property to MoveLayout in
the Format event of the Detail section.
The section will be skipped without moving to the next record in the data source. See the
following code:
[Visual Basic]
[C#]
int iSkipLabels;
private void Detail_Format(object sender, System.EventArgs eArgs)
{
If (iSkipLabels > 0);
{
iSkipLabels = iSkipLabels - 1;
LayoutAction = MoveLayout;
}
}
Top N Reports
ActiveReports requires no special handling for Top N Records report styles. Such reports can be
easily implemented by setting the data source to a Top N filtered query. If the data source does
not support Top N queries, the query can be set to return records ordered by the Top N value
descending. Then the MaxRows property should be set to N.
For example, to list the top 10 customers by their sales numbers, you can create a query that
returns all customer sales ordered by the sales value descending. Then set the MaxRows
property of the data control to 10. ActiveReports will process only 10 records from the sorted
query results.
Summary Reports
Summary reports are implemented by setting the Visible property for the Detail section to False or
setting the Height to 0. The Detail section will be processed and the summary GroupHeader and
Footer sections will be printed without the Detail section.
Green-Bar Reports
Green-bar printouts can be created by alternating the shading or background color of the report's
Detail section in the Format event.
[Visual Basic]
Dim I As Integer
Private Sub Detail_Format(ByVal sender As Object, ByVal e _
As System.EventArgs)Handles Detail.Format
If (I Mod 2) = 0 Then
Detail.BackColor = System.Drawing.Color.DarkSeaGreen
Else
Detail.BackColor = System.Drawing.Color.Transparent
End If
I = I + 1
End Sub
[C#]
bool m_color;
private void Detail_Format(object sender, System.EventArgs eArgs)
{
if(m_color)
{
m_color =false;
this.Detail.BackColor =
}
else
{
this.Detail.BackColor =
m_color = true;
}
}
Charts
ActiveReports does not include a built-in chart control. However, it allows you to use any charting
control in your report. You can use the data in your report to set series and data points in the
chart as the report is being processed.
If you place the chart in the report header (i.e. before the data is processed), you will need to
place a summary field control in the same section. This allows ActiveReports to delay printing the
section until all the required data is processed and you will get a chance to load your chart data
correctly.
Another alternative is to place the chart control in a child report and link it to a Subreport control in
the main report. This allows you to fully process the data for the chart and then render it onto the
main report using the Subreport control. However, this would require going through more than
one set of records, one for the main report and another for the child report.
Bookmarks Walkthroughs
Setting up Bookmarks (formerly called Table of Contents) allows reports to be organized and
easily navigated. By default, no Bookmarks are created when a report is run. However, by adding
simple code to the desired section event, Bookmark entries can be set up as the report runs.
This walkthrough illustrates how to set up and use Bookmarks with grouping in a report.
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.
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.
Right-click in any section of the design window of rptGroupBM, and click on View Code
to display the code view for the report. At the top left of the code view for rptGroupBM,
click the drop-down arrow and select Detail. At the top right of the code window, click the
drop-down arrow and select Format. This creates an event-handling method for
rptGroupBM's Detail_Format event.
Click in the Detail section of rptGroupBM to select the section. Click on the events icon in
the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptGroupBM's Detail_Format event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in the GroupHeader section of the design window of rptGroupBM, and click on
View Code to display the code view for the report. At the top left of the code view for
rptGroupBM, click the drop-down arrow and select ghCustomers. At the top right of the
code window, click the drop-down arrow and select Format. This creates an event-
handling method for rptGroupBM's ghCustomers_Format event.
Click in the GroupHeader section of rptGroupBM to select the section. Click on the
events icon in the Properties window to display available events for the section. Double-
click Format. This creates an event-handling method for rptGroupBM's
ghCustomers_Format event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
This walkthrough illustrates how to set up and use Bookmarks in a simple report.
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.
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 categories inner join products on
categories.categoryid = products.categoryid order by categoryname, productname".
7. Click OK to return to the report design surface.
Adding controls to the report to contain data
To add controls to the report
Right-click in any section of the design window of rptBmarks, and click on View Code to
display the code view for the report. At the top left of the code view for rptBmarks, click
the drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for rptBmarks'
Detail_Format event. Add code to the handler to:
Set up Bookmarks
Click in the Detail section of rptBmarks to select the section. Click on the events icon in
the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptBmarks' Detail_Format event. Add code to
the handler to:
Set up Bookmarks
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
The following example shows what the code for the method looks like to set up leveled
Bookmarks:
[Visual Basic]
[C#]
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 two ActiveReports to a Visual Studio project
To add two ActiveReports to a Visual Studio project
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 categories".
7. Click OK to return to the report design surface.
Right-click in any section of the design window of rptMainBM, and click on View Code to
display the code view for the report. At the top left of the code view for rptMainBM, 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 FetchData. This creates an event-handling method
for rptMainBM's FetchData event. Add code to the handler to:
Save the current record's categoryID to use in the subreport's SQL query
Click in the gray area below rptMainBM to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click FetchData.
This creates an event-handling method for rptMainBM's FetchData event. Add code to
the handler to:
Save the current record's categoryID to use in the subreport's SQL query
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
string m_categoryID;
private void rptMainBM_FetchData(object sender,
DataDynamics.ActiveReports.ActiveReport.FetchEventArgs eArgs)
{
m_categoryID = Fields["CategoryID"].Value.ToString();
}
Right-click in any section of the design surface of rptMainBM, and click on View Code to
display the code view for the report. At the top left of the code view for rptMainBM, click
the drop-down arrow and select rptMainBM. At the top right of the code window, click the
drop-down arrow and select Detail_Format. This creates an event-handling method for
the report's Detail_Format event. Add code to the handler to:
Click in the Detail section of rptMainBM to select the section. Click on the events icon in
the Properties window to display available events for the Detail section. Double-click
Format. This creates an event-handling method for rptMainBM's Detail_Format event.
Add code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptSubBM, and click on View Code to
display the code view for the report. At the top left of the code view for rptSubBM, click
the drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for rptSubBM's
Detail_Format event.
Click in the Detail section of rptMainBM to select the section. Click on the events icon in
the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptMainBM's Detail_Format event.
Click in the Detail section of rptSubBM to select the section. Click on the events icon in
the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptSubBM's Detail_Format event.
The following example shows what the code for the method looks like for rptMainBM:
[Visual Basic]
[C#]
The following example shows what the code for the method looks like for rptSubBM:
[Visual Basic]
[C#]
Calculated Fields
ActiveReports allows you to use a textbox's DataField property to perform calculations based on
the value of specific data fields.
This walkthrough illustrates how to create a simple report using calculated fields.
To complete the walkthrough, you must have access to the NorthWind database (Nwind.mdb).
When you have finished 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
Conditional Formatting
ActiveReports allows you to modify or suppress the appearance of any control at run time based
on conditions in your data. This can be achieved by setting properties of the control in the
section's format event based on certain conditions.
This walkthrough illustrates how to create a report based on specific conditions that modify the
appearance of the report at run time.
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.
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 products ORDER BY productname".
7. Click OK to return to the report design surface.
Adding controls to the report to contain data
To add controls to the report
Right-click in any section of the design window of rptConFormat, and click on View Code
to display the code view for the report. At the top left of the code view for rptConFormat,
click the drop-down arrow and select Detail. At the top right of the code window, click the
drop-down arrow and select Format. This creates an event-handling method for
rptConFormat's Detail_Format event. Add code to the handler to:
Click in the Detail section of rptConFormat to select the section. Click on the events icon
in the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptConFormat's Detail_Format event. Add
code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
int m_uis;
int m_rl;
int m_uoo;
bool m_dis;
private void Detail_Format(object sender, System.EventArgs eArgs)
{
if(m_uis < m_rl)
{
if(m_uoo == 0)
{
txtWarning.Text= "Time To Reorder";
txtWarning.ForeColor = System.Drawing.Color.Red;
}
else
{
txtWarning.Text = "There are " + m_uoo.ToString()
txtWarning.ForeColor = System.Drawing.
Color.DarkGreen;
}
}
else
{
txtWarning.Text ="";
txtWarning.ForeColor = System.Drawing.Color.Black;
}
if(m_dis)
{
this.txtInStock.ForeColor = System.Drawing.
Color.LightGray;
this.txtProduct.ForeColor = System.Drawing.
Color.LightGray;
this.txtQuantityPerUnit.ForeColor = System.Drawing.
Color.LightGray;
this.txtUnitPrice.ForeColor = System.Drawing.
Color.LightGray;
this.txtWarning.ForeColor = System.Drawing.
Color.LightGray;
this.txtWarning.Text = "Discontinued";
}
else
{
this.txtInStock.ForeColor = System.Drawing.Color.Black;
this.txtProduct.ForeColor = System.Drawing.Color.Black;
this.txtQuantityPerUnit.ForeColor = System.Drawing.
Color.Black;
this.txtUnitPrice.ForeColor = System.Drawing.
Color.Black;
}
}
Right-click in any section of the design window of rptConFormat, and click on View Code
to display the code view for the report. At the top left of the code view for rptConFormat,
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 FetchData. This creates an event-handling
method for rptConFormat's FetchData event. Add code to the handler to:
Click in the gray area below rptConFormat to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click FetchData.
This creates an event-handling method for rptConFormat's FetchData event. Add code to
the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
HTML
ActiveReports provides custom components for several formats, including PDF, HTML, RTF,
Excel and plain text. Ultimate customizability is available by using any ASP.NET language.
This walkthrough illustrates how to create a simple Web application and set up custom exporting
in HTML format.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
You must also have access to Internet Information Services either from your computer or from the
server. You must also run the "Configure Web Sample" option from the Data Dynamics
ActiveReports for .NET program menu from your Windows Start button.
When you have completed this walkthrough, you will have a report that looks similar to the
following.
Adding an ActiveReport to an ASP.NET Web application
To add an ActiveReport to your project
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.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Add the following code between "Public Class MyCustomHtmlOutputter" and "End
Class".
The following example shows what the complete code for the method looks like:
[Visual Basic]
[C#]
1. Open Windows Explorer and browse to the folder in which your project is contained.
2. On the File menu, click New, Folder.
3. Name the folder "ReportOutput".
4. Make sure that you have write permissions for this folder.
PDF
ActiveReports provides custom components for several formats, including PDF, HTML, RTF,
Excel and plain text. Ultimate customizability is available by using any ASP.NET language.
This walkthrough illustrates how to create a simple Web application and set up custom exporting
in PDF format.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
You must also have access to Internet Information Services either from your computer or from the
server. You must also run the "Configure Web Sample" option from the Data Dynamics
ActiveReports for .NET program menu from your Windows Start button.
When you have completed this walkthrough, you will have a report that looks similar to the
following.
Adding an ActiveReport to an ASP.NET Web application
To add an ActiveReport to your project
1. Click on the yellow report DataSource 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 products order by categoryID".
7. Click OK to return to the report design surface.
The following example shows what the code for the method looks like:
[Visual Basic]
rpt.Run()
p.Export(rpt.Document, m_stream)
m_stream.Position = 0
Response.ContentType = "application/pdf"
Response.BinaryWrite(m_stream.ToArray())
Response.End()
End Sub
[C#]
This walkthrough illustrates how to add and customize the ActiveReports viewer control to your
report.
To complete the walkthrough, you must have the ActiveReports controls added to your Visual
Studio toolbox. For more information, see Adding ActiveReports Controls to the Visual Studio
Toolbox.
4. Place the control on your form and size it according to your needs.
5. Set the Dock property to Fill.
6. Add the following code to the Form1_Load event:
[Visual Basic]
[C#]
3. When the viewer is split into two sections, report layouts can be examined and report
pages can be compared easily.
[Visual Basic]
[C#]
[Visual Basic]
[C#]
To complete the walkthrough, you must have access to the NorthWind database (Nwind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
Creating a new Visual Studio project
To create a new Visual Studio project
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 products".
7. Click OK to return to the report design surface.
1. Drag the following fields from the Report Explorer window: ProductName,
QuantityPerUnit and UnitsInStock.
2. Drop these textboxes into the Detail section and arrange them horizontally in the above
order.
3. Resize the Detail section to remove extra white space.
This walkthrough illustrates how to create a deployment project in ActiveReports for a compiled
report.
Exporting Output
Included with ActiveReports are several specialized export filters (HTML, PDF, RTF, Excel, TIFF
and Text). With these export filters, reports easily can be made available to others in various
formats.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have completed this walkthrough, you will have created a PDF file which can be found
in the Bin subfolder of your project's folder.
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 employees".
7. Click OK to return to the report design surface.
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:
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:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
private void Form1_Load(object sender, System.EventArgs e)
{
DataDynamics.ActiveReports.Export.PDF.PdfExport pExp = new
DataDynamics.ActiveReports.Export.Pdf.PdfExport();
pExp.Export(viewer1.Document, Application.StartupPath +
"\\PDFExpt.PDF");
}
This walkthrough illustrates how to create a report based on conditions that will show specific
data from your data source at run time.
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. 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 products ORDER BY productname".
7. Click OK to return to the report design surface.
Right-click in any section of the design window of rptCondSH, and click on View Code to
display the code view for the report. At the top left of the code view for rptCondSH, click
the drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for rptCondSH's
Detail_Format event. Add code to the handler to:
Click in the Detail section of rptCondSH to select the section. Click on the events icon in
the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptCondSH's Detail_Format event. Add code
to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
int m_rl;
bool m_dis;
private void Detail_Format(object sender, System.EventArgs eArgs)
{
if(m_rl == 0 && m_dis == false)
{
this.Detail.Visible = true;
this.txtDiscontinued.Text = "";
this.txtReorderLevel.Text = "Need to Reorder";
this.txtReorderLevel.ForeColor = System.Drawing. _
Color.DarkRed;
}
else
{
this.Detail.Visible = false;
}
}
Right-click in any section of the design window of rptCondSH, and click on View Code to
display the code view for the report. At the top left of the code view for rptCondSH, 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 FetchData. This creates an event-handling method
for rptCondSH's FetchData event. Add code to the handler to:
Click in the gray area below rptCondSH to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click FetchData.
This creates an event-handling method for rptCondSH's FetchData event. Add code to
the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
This walkthrough illustrates the basics of setting up grouping on simple fields in a report.
To complete the walkthrough, you must have access to the NorthWind database (Nwind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
Adding an ActiveReport to your project
To add an ActiveReport to your project
1. Click on the yellow report DataSource icon in the Detail field. 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.
1. Add a GroupHeader/Footer section to your report (see Grouping Data for help).
2. Make the following changes to the group header:
o Change the name to ghOrderGroup
o Change the DataField property to Country
3. Add the following controls to the PageHeader section:
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.
Right-click in any section of the design window of rptUnboundGrp, and click on View
Code to display the code view for the report. At the top left of the code view for
rptUnboundGrp, 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 ReportStart. This creates
an event-handling method for rptUnboundGrp's ReportStart event. Add code to the
handler to:
Click in the gray area below rptUnboundGrp to select the report. Click on the events icon
in the Properties window to display available events for the report. Double-click
ReportStart. This creates an event-handling method for rptUnboundGrp's FetchData
event. Add code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptUnboundGrp, and click on View
Code to display the code view for the report. At the top left of the code view for
rptUnboundGrp, 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 DataInitialize. This creates
an event-handling method for rptUnboundGrp's DataInitialize event. Add code to the
handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptUnboundGrp, and click on View
Code to display the code view for the report. At the top left of the code view for
rptUnboundGrp, 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 FetchData. This creates
an event-handling method for rptUnboundGrp's FetchData event. Add code to the
handler to:
Click in the gray area below rptUnboundGrp to select the report. Click on the events icon
in the Properties window to display available events for the report. Double-click
FetchData. This creates an event-handling method for rptUnboundGrp's FetchData
event. Add code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
Private Sub rptUnboundGrp_FetchData(ByVal sender As Object, _
ByVal eArgs As DataDynamics.ActiveReports.ActiveReport. _
FetchEventArgs) Handles MyBase.FetchData
Try
m_reader.Read()
Me.Fields("CategoryID").Value = m_reader("categories.CategoryID")
Me.Fields("CategoryName").Value = m_reader("CategoryName")
Me.Fields("ProductName").Value = m_reader("ProductName")
Me.Fields("UnitsInStock").Value = m_reader("UnitsInStock")
Me.Fields("Description").Value = m_reader("Description")
Me.Fields("TotalLabel").Value = "Total Number of " + _
m_reader("CategoryName") + ":"
eArgs.EOF = False
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString())
eArgs.EOF = True
End Try
End Sub
[C#]
Keeptogether Options
ActiveReports allows you to set Keeptogether options for your reports so that group detail is kept
together on one page when printed.
This walkthrough illustrates how to set the Keeptogether and GroupKeepTogether options to
allow all group detail to print together on one page.
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.
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 DISTINCTROW Orders.*, [Order Details].*, Products.*
FROM Products INNER JOIN (Orders INNER JOIN [Order Details] ON Orders.OrderID =
[Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID order by
orderdate".
7. Click OK to return to the report design surface.
Hyperlinks Walkthroughs
ActiveReports allows hyperlinks to be added to reports. These reports can then be previewed,
displayed in the viewer control or exported. The hyperlink property can be set to any HTML-style
link, used to simulate drill-down reporting or set to items in the Table of Contents. By using the
hyperlink property, reports can have "clickable" controls which can be used for a variety of
different tasks, including running and displaying other reports. The following walkthroughs
demonstrate the different ways hyperlinking can be used in reports.
o Hyperlinks
o Hyperlinks and Bookmarks
o Hyperlinks and Simulated Drill-Down Reporting
Hyperlinks
ActiveReports allows you to add hyperlinks to reports. The hyperlink property can be set to any
HTML-style link such as http:// and mailto://.
This walkthrough illustrates how to add to add hyperlinks to a report in the PageFooter section.
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 a Visual Studio project
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 suppliers order by CompanyName".
7. Click OK to return to the report design surface.
This walkthrough illustrates how to add to add hyperlinks to a report which reference items in the
bookmarks collection and create a directory to match the items in the bookmarks collection.
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 two ActiveReports to a Visual Studio project
To add two ActiveReports to a Visual Studio project
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 suppliers order by CompanyName".
7. Click OK to return to the report design surface.
Adding controls to display the data
To add controls to the reports
Right-click in any section of the design window of rptMain, and click on View Code to
display the code view for the report. At the top left of the code view for rptMain, click the
drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for rptMain's
Detail_Format event.
Click on the Detail section of rptMain to select the section. Click on the events icon in the
Properties window to display available events for the report. Double-click Format. This
creates an event-handling method for rptMain's Detail_Format event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design surface of rptMain, and click on View Code to
display the code view for the report. At the top left of the code view for rptMain, 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 ReportEnd. This creates an event-handling method
for the rptMain's ReportEnd event.
Click in the gray area below rptMain to select the report. Click on the events icon in the
Properties window to display available events for the report. Double-click ReportEnd.
This creates an event-handling method for rptMain's ReportStart event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptBookmarks, and click on View Code
to display the code view for the report. At the top left of the code view for rptBookmarks,
click the drop-down arrow and select Detail. At the top right of the code window, click the
drop-down arrow and select Format. This creates an event-handling method for
rptBookmarks' Detail Format event.
Click on the Detail section of rptBookmarks to select the section. Click on the events icon
in the Properties window to display available events for the report. Double-click Format.
This creates an event-handling method for rptBookmarks' Detail_Format event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptBookmarks, and click on View Code
to display the code view for the report. At the top left of the code view for rptBookmarks,
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 FetchData. This creates an event-handling
method for rptBookmarks' FetchData event.
Click in the gray area below rptBookmarks to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click FetchData.
This creates an event-handling method for rptBookmarks' FetchData event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
int iEntry;
private void rptBookmarks_FetchData(object sender,
DataDynamics.ActiveReports.ActiveReport.FetchEventArgs eArgs)
{
if (iEntry > pBM.Count - 1)
{
eArgs.EOF = true;
}
else
{
eArgs.EOF = false;
iEntry += 1;
}
}
This walkthrough illustrates how to set up hyperlinks in a report to simulate drill-down reporting.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
Adding three ActiveReports to a Visual Studio project
To add three ActiveReports to a Visual Studio project
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 customerID".
7. Click OK to return to the report design surface.
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 orders where customerID = '<%customerID%>'
order by orderdate".
7. Click OK to return to the report design surface.
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 [order details] where orderID = <%orderID%> order
by productid".
7. Click OK to return to the report design surface.
Double-click at the top of frmViewMain to display the code view for the report. At the top
left of the code view for frmViewMain, click the drop-down arrow and select Viewer1. At
the top right of the code window, click the drop-down arrow and select Hyperlink. This
creates an event-handling method for frmViewMain's Viewer1_Hyperlink event.
Click in the Viewer section of frmViewMain to select the viewer. Click on the events icon
in the Properties window to display available events for the viewer. Double-click
Hyperlink. This creates an event-handling method for frmViewMain's Viewer1_Hyperlink
event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Click in the Viewer section of frmViewDrillDown1 to select the viewer. Click on the events
icon in the Properties window to display available events for the viewer. Double-click
Hyperlink. This creates an event-handling method for frmViewDrillDown's
Viewer1_Hyperlink event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptMain, and click on View Code to
display the code view for the report. At the top left of the code view for rptMain, click the
drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select BeforePrint. This creates an event-handling method for rptMain's
Detail_BeforePrint event.
Click in the Detail section of rptMain to select the section. Click on the events icon in the
Properties window to display available events for the section. Double-click BeforePrint.
This creates an event-handling method for rptMain's Detail_BeforePrint event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptDrillDown1, and click on View Code
to display the code view for the report. At the top left of the code view for rptDrillDown1,
click the drop-down arrow and select Detail. At the top right of the code window, click the
drop-down arrow and select BeforePrint. This creates an event-handling method for
rptDrillDown1's Detail_BeforePrint event.
Click in the Detail section of rptDrillDown1 to select the section. Click on the events icon
in the Properties window to display available events for the section. Double-click
BeforePrint. This creates an event-handling method for rptDrillDown1's
Detail_BeforePrint event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
This walkthrough illustrates how to create a Master Detail report using grouping to organize the
report.
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.
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 orders, [order details], products where
orders.OrderID = [order details].OrderID and products.productID = [order
details].productID order by OrderDate".
7. Click OK to return to the report design surface.
This walkthrough illustrates how to create a Master Detail report with subreports.
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 two ActiveReports to a Visual Studio project
To add two ActiveReports to your project
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 orders".
7. Click OK to return to the report design surface.
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 [order details] inner join products on [order
details].productid = products.productID where [order details].orderID = <%OrderID%>".
7. Click OK to return to the report design surface.
Right-click in any section of the design window of rptMaster, and click on View Code to
display the code view for the report. At the top left of the code view for rptMaster, click the
drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for rptMaster's
Detail_Format event. Add code to the handler to:
Click in the Detail section of rptMaster to select the section. Click on the events icon in
the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptMaster's Detail_Format event. Add code to
the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
End Sub
[C#]
This walkthrough illustrates how to create a Master Detail report using XML data and grouping.
To complete the walkthrough, you must have access to the XML Customer database
(Customer.xml).
When you have completed this walkthrough, you will have a report that looks similar to the
following.
1. Click on the yellow report DataSource icon in the Detail section. This brings up the report
DataSource dialog box.
2. Click on the Data Source drop-down arrow and select XML.
3. Click on the ellipsis beside File URL to browse for the access path to Customer.xml. Click
Open once you have selected the appropriate access path.
4. In the Recordset Pattern field, type "//ITEM".
5. Click OK to return to the report design surface.
o Adding Pages
o Applying Page Templates
o Merging Reports
Adding Pages
ActiveReports allows you to add pages to your report in Visual Studio for previewing in the viewer
control or printing. The document containing the inserted pages can also be saved to an RDF file
or exported.
This walkthrough illustrates how to create two reports and insert the second report as a cover
page for the first one.
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 two ActiveReports to a Visual Studio project
To add two ActiveReports to a Visual Studio project
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 products order by productname".
7. Click OK to return to the report design surface.
Right-click at the top of 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:
The following example shows what the code for the Insert method looks like:
[Visual Basic]
[C#]
The following example shows what the code for the InsertNew method looks like. This method
allows you to insert a new page at the location you specify:
[Visual Basic]
[C#]
This walkthrough illustrates how to overlay an ActiveReport with a "letterhead" page template.
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.
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.
Right-click at the top of 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:
Click at the top of Form1 to select the form. Click on the events icon in the Properties
window to display available events for the form. Double-click Load. This creates an
event-handling method for the Form1_Load event. Add code to the handler to:
The following example shows what the code for the Overlay method looks like:
[Visual Basic]
[C#]
Merging Reports
ActiveReports allows you to merge two or more reports in Visual Studio for previewing in the
viewer control or printing. The document containing the merged reports can also be saved to an
RDF file or exported.
This walkthrough illustrates how to create two ActiveReports and merge the reports into one
document.
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.
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 orders".
7. Click OK to return to the report design surface.
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 products".
7. Click OK to return to the report design surface.
Right-click at the top of 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:
Click at the top of Form1 to select the form. Click on the events icon in the Properties
window to display available events for the form. Double-click Load. This creates an
event-handling method for the Form1_Load event. Add code to the handler to:
The following example shows what the code for the AddRange method looks like:
[Visual Basic]
[C#]
The following example shows what the code for the Add method looks like:
[Visual Basic]
Dim i As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Dim rpt As New rptOne()
rpt.Run()
Dim rpt2 As New rptTwo()
rpt2.Run()
For i = 0 To rpt2.Document.Pages.Count - 1
rpt.Document.Pages.Add(rpt2.Document.Pages(i))
Next
Viewer1.Document = rpt.Document
End Sub
[C#]
int i;
private void Form1_Load(object sender, System.EventArgs e)
{
rptOne rpt1 = new rptOne();
rpt1.Run();
rptTwo rpt2 = new rptTwo();
rpt2.Run();
for(i = 0; i < rpt2.Document.Pages.Count; i++)
{
rpt1.Document.Pages.Add(rpt2.Document.Pages[i]);
}
viewer1.Document = rpt1.Document;
}
This walkthrough illustrates the basics of setting up page numbering for groups in the
GroupHeader section.
To complete the walkthrough, you must have access to the NorthWind database (Nwind.mdb).
When you have finished 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
To complete the walkthrough, you must have access to the NorthWind database (Nwind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
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 products order by categoryID".
7. Click OK to return to the report design surface.
Parameters Walkthroughs
With ActiveReports, parameters may be used with simple reports to prompt a user for input
before running the report or used with subreports to link a subreport to a parent report.
To complete the walkthrough, you must have access to the NorthWind database (Nwind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
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 orders INNER JOIN [order details] ON
orders.orderid = [order details].orderid WHERE orderdate =#<%Date|Order
date:|1/1/1994|D%>#".
7. Click OK to return to the report design surface.
This walkthrough illustrates how to setup a subreport using parameters to link the parent report to
the subreport.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
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 products INNER JOIN categories ON
products.categoryid = categories.categoryid WHERE products.supplierID
=<%SupplierID%>".
7. Click OK to return to the report design surface.
Right-click in any section of the design window of rptParent, and click on View Code to
display the code view for the report. At the top left of the code view for rptParent, click the
drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for rptParent's
Detail_Format event. Add code to the handler to:
Click on the Detail section of rptParent to select the section. Click on the events icon in
the Properties window to display available events for the report. Double-click Format.
This creates an event-handling method for rptParent's Detail_Format event. Add code to
the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design surface of rptChild, and click on View Code to
display the code view for the report. At the top left of the code view for rptChild, 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 ReportStart. This creates an event-handling method
for the rptChild's ReportStart event. Add code to the handler to:
Click in the gray area below rptChild to select the report. Click on the events icon in the
Properties window to display available events for the report. Double-click ReportStart.
This creates an event-handling method for rptChild's ReportStart event. Add code to the
handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Printing Walkthroughs
With ActiveReports, printer settings can be modified at design time as well as at run time. The
following walkthroughs will describe how to make such modifications in your report.
o Duplexing
o Multiple Copies
o Orientation
o Scaling Pages
Duplexing
This walkthrough illustrates how to set the type of duplex action to use when printing out double-
sided reports.
Printer default: the report will use the default setting on the selected printer.
Simplex: turns off duplex printing.
Horizontal: prints horizontally on both sides of the paper.
Vertical: prints vertically on both sides of the paper.
Right-click in any section of the design window of your report, and click on View Code to
display the code view for the report. At the top left of the code view for the report, 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 ReportStart. This creates an event-handling method
for the report's ReportStart event. Add code to the handler to:
Click in the gray section underneath the report to select the report. Click on the events
icon in the Properties window to display available events for the report. Double-click
ReportStart. This creates an event-handling method for the report's ReportStart event.
Add code to the handler to:
Set the type of duplexing needed in the report
The following example shows what the code for the method looks like for setting horizontal
duplexing:
[Visual Basic]
[C#]
Multiple Copies
This walkthrough illustrates how to set multiple copies for printing a report.
Setting multiple copies for printing a report from the print dialog at run time
Setting multiple copies in code for printing a report
Using code to set multiple copies for printing
Setting multiple copies for printing a report from the print dialog
at run time
To set multiple copies for printing a report from the print dialog at run time
Right-click in any section of the design window of your report, and click on View Code to
display the code view for the report. At the top left of the code view for the report, 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 ReportStart. This creates an event-handling method
for the report's ReportStart event. Add code to the handler to:
Click in the gray section underneath the report to select the report. Click on the events
icon in the Properties window to display available events for the report. Double-click
ReportStart. This creates an event-handling method for the report's ReportStart event.
Add code to the handler to:
The following example shows what the code for the method looks like for printing five copies:
[Visual Basic]
[C#]
Orientation
This walkthrough illustrates how to make simple modifications to the page orientation of your
report for printing.
Right-click in any section of the design window of your report, and click on View Code to
display the code view for the report. At the top left of the code view for the report, 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 ReportStart. This creates an event-handling method
for the report's ReportStart event. Add code to the handler to:
Click in the gray section underneath the report to select the report. Click on the events
icon in the Properties window to display available events for the report. Double-click
ReportStart. This creates an event-handling method for the report's ReportStart event.
Add code to the handler to:
[Visual Basic]
Scaling Pages
This walkthrough illustrates how to set scaling to print a report.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
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 categories INNER JOIN products ON
categories.categoryID = products.categoryID order by products.categoryid".
7. Click OK to return to the report design surface.
Adding controls to the report to contain data
To add controls to the report
Right-click in any section of the design window of Form1, and click on View Code to
display the code view for the form. Add code to the Form to set scaling.
Double-click at the top of Form1 to see the Code View for the form. Add code to the Form
to set scaling.
[Visual Basic]
Dim i As Integer
Dim rpt As New rptScale()
Dim m_myARPrinter As New DataDynamics.ActiveReports._
Interop.SystemPrinter()
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Viewer1.Document = rpt.Document
rpt.Run()
arScale()
End Sub
Private Sub arScale()
m_myARPrinter.StartJob("Test Printer")
xOffSet = m_myARPrinter.PhysicalOffsetX / _
m_myARPrinter.Graphics.DpiX
yOffSet = m_myARPrinter.PhysicalOffsetY / _
m_myARPrinter.Graphics.DpiY
adjustedWidth = (aPage.Width / 3) - (xOffSet / 2)
xPos = 0
Dim nCount As Integer
nCount = rpt.Document.Pages.Count
m_myARPrinter.StartPage()
For i = 0 To nCount - 1
aPage = rpt.Document.Pages(i)
m_myARPrinter.Graphics.PageUnit = GraphicsUnit.Pixel
rec = System.Drawing.RectangleF.FromLTRB(xOffSet + _
xPos, yOffSet, (xOffSet + xPos) + _
adjustedWidth, yOffSet + adjustedWidth)
xPos = adjustedWidth + xPos
aPage.Draw(m_myARPrinter.Graphics, rec)
Next
m_myARPrinter.EndPage()
m_myARPrinter.EndJob()
End Sub
[C#]
ActiveReport1 rpt;
DataDynamics.ActiveReports.Document.Page aPage;
private void arScale()
{
aPage = new DataDynamics.ActiveReports.Document.Page();
DataDynamics.ActiveReports.Interop.SystemPrinter m_myARPrinter =
new DataDynamics.ActiveReports.Interop.SystemPrinter();
m_myARPrinter.StartJob("Test Printer");
System.Drawing.RectangleF rec;
float xOffSet = m_myARPrinter.PhysicalOffsetX/
m_myARPrinter.Graphics.DpiX;
float yOffSet = m_myARPrinter.PhysicalOffsetY/
m_myARPrinter.Graphics.DpiY;
float adjustedWidth = (aPage.Width/3)-(xOffSet*2);
float xPos = 0;
int nCount = rpt.Document.Pages.Count;
m_myARPrinter.StartPage();
for(int i=0; i < nCount; i++)
{
aPage = rpt.Document.Pages[i];
m_myARPrinter.Graphics.PageUnit = System.
Drawing.GraphicsUnit.Pixel;
rec = System.Drawing.RectangleF.FromLTRB
(xOffSet+xPos, yOffSet,(xOffSet+xPos)+
adjustedWidth,yOffSet+adjustedWidth);
xPos = adjustedWidth + xPos;
aPage.Draw(m_myARPrinter.Graphics,rec);
}
m_myARPrinter.EndPage();
m_myARPrinter.EndJob();
}
This walkthrough illustrates how to create a mail-merge report using the RichText control.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you complete this walkthrough, you will have a report that looks similar to the following.
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
Customers.CustomerID, Customers.CompanyName,
Customers.ContactName, Customers.Address,
Customers.City, Customers.Region, Customers.Country, Customers.PostalCode,
Orders.OrderID, Orders.OrderDate, [Order Subtotals].Subtotal
FROM Customers INNER JOIN ([Order Subtotals] INNER JOIN Orders ON [Order
Subtotals].OrderID = Orders.OrderID) ON Customers.CustomerID = Orders.CustomerID".
7. Click OK to return to the report design surface.
Right-click in any section of the design window of rptLetter, and click on View Code to
display the code view for the report. At the top left of the code view for rptLetter, 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 FetchData. This creates an event-handling method
for rptLetter's FetchData event. Add code to the handler to:
Click in the gray area below rptLetter to select the report. Click on the events icon in the
Properties window to display available events for the report. Double-click FetchData.
This creates an event-handling method for rptLetter's FetchData event. Add code to the
handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
string m_companyName;
string m_contactName;
string m_addressLine;
string m_city;
string m_region;
string m_country;
string m_postalCode;
private void rptLetter_FetchData(object sender,
DataDynamics.ActiveReports.ActiveReport.FetchEventArgs eArgs)
{
m_companyName = Fields["CompanyName"].Value.ToString();
m_contactName = Fields["ContactName"].Value.ToString();
m_addressLine = Fields["Address"].Value.ToString();
m_city = Fields["City"].Value.ToString();
if(Fields["Region"].Value is System.DBNull)
m_region = "";
else
m_region = Fields["Region"].Value.ToString();
m_country = Fields["Country"].Value.ToString();
m_postalCode = Fields["PostalCode"].Value.ToString();
}
Adding code to update the field values in the Rich Text control
To write the code in Visual Basic
Right-click in any section of the design window of rptLetter, and click on View Code to
display the code view for the report. At the top left of the code view for rptLetter, click the
drop-down arrow and select ghCustomerID. At the top right of the code window, click the
drop-down arrow and select Format. This creates an event-handling method for
rptLetter's ghCustomerID_Format event. Add code to the handler to:
Click in the GroupHeader section of rptLetter to select it. Click on the events icon in the
Properties window for ghCustomerID to display available events for the section. Double-
click Format. This creates an event-handling method for rptLetter's
ghCustomerID_Format event. Add code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptLetter, and click on View Code to
display the code view for the report. At the top left of the code view for rptLetter, click the
drop-down arrow and select ghCustomerID. At the top right of the code window, click the
drop-down arrow and select BeforePrint. This creates an event-handling method for
rptLetter's ghCustomerID_BeforePrint event.
Click in the GroupHeader section of rptLetter to select it. Click on the events icon in the
Properties window for ghCustomerID to display available events for the section. Double-
click BeforePrint. This creates an event-handling method for rptLetter's
ghCustomerID_BeforePrint event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have completed this walkthrough, you will have output that looks similar to the
following.
Adding an ActiveReport to your project
To add an ActiveReport to your project
1. Click on the yellow report DataSource icon in the Detail field. 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 products".
7. Click OK to return to the report design surface.
[Visual Basic]
CType(Me.Sections("GroupHeader1"), GroupHeader)._
DataField = "CategoryID"
Me.Sections("GroupHeader1").BackColor _
= System.Drawing.Color.SlateBlue
Me.Sections("GroupHeader1").CanGrow = True
Me.Sections("GroupHeader1").CanShrink = True
CType(Me.Sections("GroupHeader1"), _
GroupHeader).RepeatStyle = _
RepeatStyle.OnPageIncludeNoDetail
Me.Sections("GroupHeader1").Height = 0
[C#]
if(m_useGroups)
{
this.Sections.InsertGroupHF();
((GroupHeader)this.Sections["GroupHeader1"]).
DataField = "CategoryID";
this.Sections["GroupHeader1"].BackColor =
System.Drawing.Color.SlateBlue;
this.Sections["GroupHeader1"].CanGrow = true;
this.Sections["GroupHeader1"].CanShrink = true;
((GroupHeader)this.Sections["GroupHeader1"]).
RepeatStyle = RepeatStyle.
OnPageIncludeNoDetail;
this.Sections["GroupFooter1"].Height = 0;
[Visual Basic]
[C#]
Right-click in any section of the design window of rptFieldsRT, and click on View Code to
display the code view for the report. At the top left of the code view for rptFieldsRT, click
the drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for rptFieldsRT's
Detail_Format event.
Click in the Detail section of rptFieldsRT to select the section. Click on the events icon in
the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptFieldsRT's Detail_Format event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
int m_count;
private void Detail_Format(object sender, System.EventArgs eArgs)
{
if(m_count % 2 ==0)
{
this.Detail.BackColor = System.Drawing.Color.SlateGray;
}
else
{
this.Detail.BackColor = System.Drawing.
Color.DarkSeaGreen;
}
m_count++;
}
Right-click in any section of the design window of rptFieldsRT, and click on View Code to
display the code view for the report. At the top left of the code view for rptFieldsRT, 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 ReportStart. This creates an event-handling method
for rptFieldsRT's ReportStart event.
To write the code in C#
Click in the gray area below rptFieldsRT to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click
ReportStart. This creates an event-handling method for rptFieldsRT's ReportStart event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the Windows Form, and click on View Code to display the
code view for the Windows Form. At the top left of the code view for the form, click the
drop-down arrow and select clbFields. At the top right of the code window, click the drop-
down arrow and select SelectedIndexChanged. This creates an event-handling method
for the Form1_SelectedIndexChanged event.
Click in the designer window of the Windows Form to select it. Click on the events icon in
the Properties window to display available events for the section. Double-click
SelectedIndexChanged. This creates an event-handling method for the
Form1_SelectedIndexChanged event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
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:
The following example shows what the code for the method looks like:
[Visual Basic]
Dim i As Integer
Dim c As Integer
Dim m_arrayField As New ArrayList()
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs)Handles MyBase.Load
Try
Me.OleDbConnection1.ConnectionString _
= "Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=C:\Program Files\Data _
Dynamics\ActiveReports.NET\Data\NWIND._
MDB;Persist Security Info=False"
Me.OleDbDataAdapter1.Fill(Me.DataSet11)
fillCheckBox()
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(Me, _
"Error in Form_Load: " + ex.Message, _
"Project Error", MessageBoxButtons.OK,_
MessageBoxIcon.Error)
End Try
End Sub
[C#]
This walkthrough illustrates how to set up a report to set a report's data source at run time.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
1. Click on the yellow report DataSource icon in the Detail field. 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 products".
7. Click OK to return to the report design surface.
Right-click in any section of the design window of rptModifyDS, and click on View Code
to display the code view for the report. Beneath "ActiveReports Designer Generated
Code", type the following: "Private Function getDatabasePath() As String" and hit "Enter."
This creates a function for getDatabasePath.
Click in the gray area below rptModifyDS and click on View Code to display the code
view for the report. Beneath "ActiveReports Designer Generated Code", type the
following: "private string getDatabasePath()". This creates a function for
getDatabasePath.
The following example shows what the code for the function looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptModifyDS, and click on View Code
to display the code view for the report. At the top left of the code view for rptModifyDS,
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 ReportStart. This creates an event-
handling method for rptModifyDS's ReportStart event. Add code to the handler to:
Click in the gray area below rptModifyDS to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click
ReportStart. This creates an event-handling method for rptModifyDS's ReportStart event.
Add code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
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. 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. 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.
Right-click in any section of Form1, and click on View Code to display the code view for
the Windows 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:
Click at the top of Form1 to select the Windows Form. Click on the events icon in the
Properties window to display available events for the section. Double-click Load. This
creates an event-handling method for the Form1_Load event. Add code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
rpt.Run()
rpt.Document.Save(strm)
Dim theBytes(strm.Length) As Byte
strm.Read(theBytes, 0, Int(strm.Length))
strm.Position = 0
Viewer1.Document.Load(strm)
End Sub
[C#]
strm.Position =0;
viewer1.Document.Load(strm);
}
Scripting Walkthroughs
ActiveReports allows you to use scripting to provide ease in reporting functionality. Scripting
permits reports saved to an RPX file to contain code. This characteristic allows the options of
stand-alone reporting and web reporting without requiring .vb or .cs files. By including scripting
when the report is saved as an RPX file, it can later by loaded, run and displayed directly to the
viewer control without using the designer. Scripting can also be used in conjunction with RPX files
to allow distributed reports to be updated without recompiling.
When you have completed this walkthrough, you will have a report that looks similar to the
following.
The following example shows what the scripting code looks like:
[C#]
regKey = regKey.CreateSubKey("SOFTWARE\\Data
Dynamics\\ActiveReports.NET\\SampleDB");
return (string)regKey.GetValue("");
}
public void ActiveReport_ReportStart()
{
string m_dbPath = getDatabasePath();
string m_cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + m_dbPath + "\\NWind.MDB";
string sqlString = "SELECT * FROM categories INNER JOIN products
ON categories.categoryid =
products.categoryid ORDER BY products.categoryid,
products.productid";
m_cnn = new System.Data.OleDb.OleDbConnection(m_cnnString);
System.Data.OleDb.OleDbCommand m_Cmd = new
System.Data.OleDb.OleDbCommand(sqlString,m_cnn);
if(m_cnn.State == System.Data.ConnectionState.Closed)
{
m_cnn.Open();
}
m_reader = m_Cmd.ExecuteReader();
}
return eof;
}
bool m_color;
public void Detail_Format()
{
if(m_color)
{
m_color =false;
rpt.Sections["Detail"].BackColor =
System.Drawing.Color.DarkSeaGreen;
}
else
{
rpt.Sections["Detail"].BackColor =
System.Drawing.Color.Transparent;
m_color = true;
}
}
3. Click OK to continue.
Scripting and Subreports
ActiveReports allows you to use scripting to permit reports saved to an XML file to contain code.
By including scripting when the RPX files are saved into XML, the reports later can be loaded, run
and displayed directly to the viewer control without needing to use the designer.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
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 [order details] inner join products on [order
details].productid = products.productid where [order details].orderid = <%orderID%>".
7. Click OK to return to the report design surface.
The following example shows what the scripting code looks like:
[C#]
The following example shows what the scripting code looks like:
[C#]
int cnt;
public void Detail_Format()
{
cnt++;
if(cnt % 2 == 0)
{
rpt.Sections["Detail"].BackColor =
System.Drawing.Color.White;
}
else
{
rpt.Sections["Detail"].BackColor =
System.Drawing.Color.BlanchedAlmond;
}
}
3. Click OK to continue.
Style Sheets
ActiveReports adds style class names to allow controls to be formatted easily. With the use of
style sheets, groups of controls can be set to a single style with just a few clicks. ClassName and
the different control's style property can also be used to create specialized styles in code and
through scripting.
This walkthrough illustrates how to create and use style sheets in a report.
Right-click in any section of the design window of your report, and click on View Code to
display the code view for the report. At the top left of the code view for the report, click
the drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for the report's
Detail_Format event. Add code to the handler to:
Click in the Detail section of your report to select it. Click on the events icon in the
Properties window to display available events for the section. Double-click Format. This
creates an event-handling method for the report's Detail_Format event. Add code to the
handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Subreports Walkthroughs
With ActiveReports, reports may contain any number of child reports by using the Subreport
control. Child reports, or subreports, are executed each time the parent section (i.e. the section in
which the Subreport control is placed) is printed.
o Hierarchical Subreports
o Nested Subreports
o Simple Subreports
Hierarchical Subreports
ActiveReports allows reports to contain any number of child reports by using the Subreport
control. Child reports, or subreports, are executed each time the parent section (i.e. the section in
which the Subreport control is placed) is printed.
This walkthrough illustrates how to set up a bound subreport by setting the Subreport control's
Report property to the child report and how to modify the subreport record source from the data in
the parent report to retrieve the correct information.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
Adding two ActiveReports to a Visual Studio project
To add two ActiveReports to a Visual Studio project
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 "SHAPE {SELECT CustomerID, CompanyName, Address FROM
Customers} APPEND ({SELECT CustomerID, OrderID, Freight, OrderDate, EmployeeID
FROM Orders} AS CustomerOrders RELATE CustomerID TO CustomerID)".
7. Click OK to return to the report design surface.
Right-click in any section of the design window of rptCustomers, and click on View Code
to display the code view for the report. At the top left of the code view for rptCustomers,
click the drop-down arrow and select Detail. At the top right of the code window, click the
drop-down arrow and select Format. This creates an event-handling method for
rptCustomers' Detail_Format event. Add code to the handler to:
Click in the Detail section of rptCustomers to select the section. Click on the events icon
in the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptCustomers' Detail_Format event. Add code
to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Nested Subreports
When setting up embedded subreports in ActiveReports, the principles are the same as when
setting up simple subreports but are applied to the child-grandchild reports.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
Adding three ActiveReports to a Visual Studio project
To add three ActiveReports to a Visual Studio project
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 employees".
7. Click OK to return to the report design surface.
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 orders inner join [order details] on orders.orderID =
[order details].orderID where orders.employeeID = <%employeeID%>".
7. Click OK to return to the report design surface.
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 where customerID = '<%CustomerID%>'
".
7. Click OK to return to the report design surface.
4. Add the following controls to the Detail section of rptOrders, naming them as indicated:
5. Add the following controls to the Detail section of rptCustomers, naming them as
indicated:
Right-click in any section of the design window of rptEmployees, and click on View Code
to display the code view for the report. At the top left of the code view for rptEmployees,
click the drop-down arrow and select Detail. At the top right of the code window, click the
drop-down arrow and select Format. This creates an event-handling method for
rptEmployees' Detail_Format event. Add code to the handler to:
Click in the Detail section of rptEmployees to select the section. Click on the events icon
in the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptEmployees' Detail_Format event. Add code
to the handler to:
Set subOrders equal to rptOrders
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptOrders, and click on View Code to
display the code view for the report. At the top left of the code view for rptOrders, click the
drop-down arrow and select Detail. At the top right of the code window, click the drop-
down arrow and select Format. This creates an event-handling method for rptOrders'
Detail_Format event. Add code to the handler to:
Click in the Detail section of rptOrders to select the section. Click on the events icon in
the Properties window to display available events for the section. Double-click Format.
This creates an event-handling method for rptOrders' Detail_Format event. Add code to
the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
This walkthrough illustrates how to set up a bound subreport by setting the Subreport control's
Report property to the child report and how to modify the subreport record source from the data in
the parent report to retrieve the correct information.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have finished this walkthrough, you will have a report that looks similar to the following.
Adding two ActiveReports to a Visual Studio project
To add two ActiveReports to a Visual Studio project
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 categories".
7. Click OK to return to the report design surface.
1. Add the following controls to the Detail section of rptMain, naming them as indicated:
2. Add the following controls to the Detail section of rptSub, naming them as indicated:
Right-click in any section of the design window of rptMain, and click on View Code to
display the code view for the report. At the top left of the code view for rptMain, 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 FetchData. This creates an event-handling method
for rptMain's FetchData event. Add code to the handler to:
Save the current record's categoryID to use in the subreport's SQL query
Click in the gray area below rptMain to select the report. Click on the events icon in the
Properties window to display available events for the report. Double-click FetchData.
This creates an event-handling method for rptMain's FetchData event. Add code to the
handler to:
Save the current record's categoryID to use in the subreport's SQL query
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
string m_categoryID;
Private Void rptMain_FetchData(object sender,
DataDynamics.ActiveReports.ActiveReport.
FetchEventArgs eArgs)
{
m_categoryID = Fields["CategoryID"].Value.ToString();
}
Right-click in any section of the design surface of rptMain, and click on View Code to
display the code view for the report. At the top left of the code view for rptMain, click the
drop-down arrow and select rptMain. At the top right of the code window, click the drop-
down arrow and select Detail_Format. This creates an event-handling method for the
report's Detail_Format event. Add code to the handler to:
Click in the Detail section of rptMain to select the section. Click on the events icon in the
Properties window to display available events for the Detail section. Double-click
Format. This creates an event-handling method for rptMain's Detail_Format event. Add
code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Summary Fields
In ActiveReports, summary fields can be added to any section to calculate totals, counts,
averages and other aggregations. The summary field's placement dictates when the section
containing the field, and sections after it, will be printed. A section with a summary field will be
delayed until all the calculations are completed. This allows summary fields to be placed ahead of
the corresponding detail.
Summary fields are calculated according to the textbox's Summary properties. A summary
textbox is updated with each new detail record. When a field is placed ahead of the Detail section
(i.e. in the ReportHeader, PageHeader or GroupHeader sections), the Detail section is formatted
with each record and the summary field is updated. When all records for the summary level are
read, the header section is printed followed by the delayed sections.
This walkthrough illustrates how to create a report with a summary field in the GroupFooter
section.
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. 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 DISTINCTROW Orders.*, [Order Details].*, Products.*
FROM Products INNER JOIN (Orders INNER JOIN [Order Details] ON Orders.OrderID =
[Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID order by
orderdate".
7. Click OK to return to the report design surface.
Note Distinct summarization can be used in a situation when the field's value
repeats in several detail records and the summary function needs to include a
single value from all repeating values. To do this, you would need to set the
DistinctField property of the summary field to the appropriate value and set the
SummaryFunc property to the appropriate distinct summary function.
Unbound Reports
ActiveReports gives you complete control to bind reports to any type of data source, including
arrays, through its programmable object model. You can create a report without setting the
report's data source then load the data from your data source into the report's control at run time.
The Fields property allows data binding between the control and the run-time fields. It also allows
the control's DataField property to be set to any of the run-time defined names. The DataInitialize
and FetchData events are used to define the run-time fields and feed the data values of these
fields so they can be used with unbound controls.
This walkthrough illustrates the fundamentals of using the DataInitialize and FetchData events to
set up an unbound report.
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
Right-click in any section of the design window of rptUnbound, and click on View Code to
display the code view for the report. At the top left of the code view for rptUnbound, 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 ReportStart. This creates an event-handling method
for rptUnbound's ReportStart event. Add code to the handler to:
Click in the gray area below rptUnbound to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click
ReportStart. This creates an event-handling method for rptUnbound's ReportStart event.
Add code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
m_cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data _
Source=C:\Program Files\Data _
Dynamics\ActiveReports.NET\Data\NWIND.MDB;_
Persist Security Info=False"
sqlString = "SELECT * FROM categories INNER JOIN products _
ON categories.categoryid = products.categoryid _
ORDER BY products.categoryid, products.productid"
m_cnn = New OleDb.OleDbConnection(m_cnnString)
Dim m_Cmd As New OleDb.OleDbCommand(sqlString, m_cnn)
If m_cnn.State = ConnectionState.Closed Then
m_cnn.Open()
End If
m_reader = m_Cmd.ExecuteReader()
End Sub
[C#]
Right-click in any section of the design window of rptUnbound, and click on View Code to
display the code view for the report. At the top left of the code view for rptUnbound, 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 DataInitialize. This creates an event-handling
method for rptUnbound's DataInitialize event. Add code to the handler to:
Click in the gray area below rptUnbound to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click
DataInitialize. This creates an event-handling method for rptUnbound's DataInitialize
event. Add code to the handler to:
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of the design window of rptUnbound, and click on View Code to
display the code view for the report. At the top left of the code view for rptUnbound, 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 FetchData. This creates an event-handling method
for rptUnbound's FetchData event. Add code to the handler to:
Click in the gray area below rptUnbound to select the report. Click on the events icon in
the Properties window to display available events for the report. Double-click FetchData.
This creates an event-handling method for rptUnbound's FetchData event. Add code to
the handler to:
[Visual Basic]
[C#]
In this section
When you have completed this walkthrough, you will have a basic layout which looks similar to
the following.
Adding a Windows Form to a Visual Studio project
To add a Windows Form to a Visual Studio project
1. Add a panel to the form and set the Dock property to Top.
2. Add a second panel to the form and set the Dock property to Left.
3. Add a third panel to the form and set the Dock property to Right.
4. Add a splitter to the form and set the Dock property to Right.
5. In the right panel, add a panel and set the Dock property to Bottom.
6. Add a splitter to the right panel and set the Dock property to Bottom.
7. Add a panel to the right panel and set the Dock property to Fill.
Adding the ActiveReports End-User Report Designer control to
the form
To add the control
1. Right-click on the toolbox where you wish to add the Property Grid control.
2. Click on Customize Toolbox...
3. Select the .NET Framework Components tab.
4. Select PropertyGrid from the list and click OK.
5. Click on the bottom right panel to select it.
6. Click on the Property Grid icon and drag it onto the panel.
7. Set the Dock property to Fill.
1. Click on the top panel to select it and add a toolbar to the panel.
2. Change the name of the toolbar to tlbLayout.
3. Click on the left panel to select it and add a toolbar to the panel.
4. Set the Dock property to Fill.
5. Change the name of the toolbar to tlbARToolbox.
6. Add three combo boxes to the top panel underneath tlbLayout.
7. Set the Dock property to Left for all three combo boxes and change the names to:
cmbClassName, cmbFonts and cmbFontSize.
8. Add a toolbar to the top panel underneath tlbLayout.
9. Set the Dock property to Fill.
10. Change the name of the toolbar to tlbReport.
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code just below the "Windows Form
Designer generated code" region.
To write the code in C#
Double-click anywhere on frmDesigner to show the code view for the Windows Form.
Add the following code just below the "Windows Form Designer generated code" region.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. At the top left of the code view for frmDesigner, 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 frmDesigner_Load event.
Click at the top of frmDesigner to select the Windows Form. Click on the events icon in
the Properties window to display available events for the section. Double-click Load.
This creates an event-handling method for the frmDesigner_Load event.
The following example shows what the code for the method looks like:
[Visual Basic]
Dim i As Integer
Dim cnt As Integer
Dim ctl As String
Private Sub frmDesigner_Load(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
Me.fillClassName()
Me.fillFonts()
Me.fillFontSizes()
Me.setModes(toolbarModes.noControls)
Me.Designer1.Focus()
End Sub
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. At the top left of the code view for frmDesigner, click the
drop-down arrow and select designer1. At the top right of the code window, click the
drop-down arrow and select SelectionChanged. This creates an event-handling method
for the Designer1_SelectionChanged event.
Click in the designer window of frmDesigner to select Designer1. Click on the events icon
in the Properties window to display available events for the section. Double-click
SelectionChanged. This creates an event-handling method for the
Designer1_SelectionChanged event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
On the Main Menu, double-click the entry for Print Preview. This creates an event-
handling method for mnuPrintPreview's Click event. Add the following code to the
mnuPrintPreview_Click event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
On the Main Menu, double-click the entry for Load Layout. This creates an event-
handling method for mnuLoadLayout's Click event. Add the following code to the
mnuLoadLayout_Click event.
On the Main Menu, double-click the entry for Load Layout. This creates an event-
handling method for mnuLoadLayout's Click event. Add the following code to the
mnuLoadLayout_Click event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
On the Main Menu, double-click the entry for Save Layout. This creates an event-
handling method for mnuSaveLayout's Click event. Add the following code to the
mnuSaveLayout_Click event.
On the Main Menu, double-click the entry for Save Layout. This creates an event-
handling method for mnuSaveLayout's Click event. Add the following code to the
mnuSaveLayout_Click event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
On the Main Menu, double-click the entry for Page Setup. This creates an event-handling
method for mnuPageSetup's Click event. Add the following code to the
mnuPageSetup_Click event.
On the Main Menu, double-click the entry for Page Setup. This creates an event-handling
method for mnuPageSetup's Click event. Add the following code to the
mnuPageSetup_Click event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
On the Main Menu, double-click the entry for Exit. This creates an event-handling method
for mnuExit's Click event. Add the following code to the mnuExit_Click event.
On the Main Menu, double-click the entry for Exit. This creates an event-handling method
for mnuExit's Click event. Add the following code to the mnuExit_Click event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Adding code for the SelectionChanged event for the property grid
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the selChangePropGrid event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
When you have completed this walkthrough, your layout for the End-User Report Designer will
look similar to the following.
4. Click OK to continue.
5. Set the Appearance property for tlbARToolbox to Flat.
6. Change the TextAlign property for tlbARToolbox to Right.
7. Resize Panel2 to fit one button on each line.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
4. Click OK to continue.
5. Set the Appearance property for tlbLayout to Flat.
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the
selChangeLayoutToolbar event.
To write the code in C#
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the selChangeLayoutToolbar event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the setModes event.
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the setModes event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the executeLayoutAction
event.
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the executeLayoutAction event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
When you have completed this walkthrough your layout for End-User Report Designer will look
similar to the following.
4. Click OK to continue.
4. Click OK to continue.
5. Set the Appearance property for tlbReport to Flat.
6. Resize Panel1.
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the ComboBox operations
events.
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the ComboBox operations events.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the events to adjust text in
the ComboBoxes.
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the events to adjust text in the ComboBoxes.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. At the top left of the code view for frmDesigner, click the
drop-down arrow and select cmbFonts. At the top right of the code window, click the
drop-down arrow and select SelectIndexChanged. This creates an event-handling
method for the cmbFonts_SelectIndexChanged event.
Click on the fonts ComboBox cmbFonts. Click on the events icon in the Properties
window to display available events for the control. Double-click SelectIndexChanged.
This creates an event-handling method for the cmbFonts_SelectIndexChanged event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. At the top left of the code view for frmDesigner, click the
drop-down arrow and select cmbFontSize. At the top right of the code window, click the
drop-down arrow and select SelectIndexChanged. This creates an event-handling
method for the cmbFontSize_SelectIndexChanged event.
Click on the font size ComboBox cmbFontSize. Click on the events icon in the
Properties window to display available events for the control. Double-click
SelectIndexChanged. This creates an event-handling method for the
cmbFontSize_SelectIndexChanged event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. At the top left of the code view for frmDesigner, click the
drop-down arrow and select cmbClassName. At the top right of the code window, click
the drop-down arrow and select SelectIndexChanged. This creates an event-handling
method for the cmbClassName_SelectIndexChanged event.
To write the code in C#
Click on the fonts ComboBox cmbClassName. Click on the events icon in the Properties
window to display available events for the control. Double-click SelectIndexChanged.
This creates an event-handling method for the cmbClassName_SelectIndexChanged
event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the
selChangeReportToolbar event.
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the selChangeReportToolbar event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the getActionFromString function.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
private DataDynamics.ActiveReports.Design.DesignerAction
getActionFromString(string action)
{
switch(action)
{
case "Bold":
result =DataDynamics.ActiveReports.Design.
DesignerAction.FormatFontBold;
break;
case "Italic":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatFontItalic;
break;
case "Underline":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatFontUnderline;
break;
case "Bullets":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatRTFBullets;
break;
case "IncreaseIndent":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatRTFIndent;
break;
case "DecreaseIndent":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatRTFOutdent;
break;
case "EditScript":
result =DataDynamics.ActiveReports.Design.
DesignerAction.EditScript;
break;
case "ReorderGroups":
result = DataDynamics.ActiveReports.Design.
DesignerAction.ReorderGroups;
break;
case "ViewGrid":
result=DataDynamics.ActiveReports.Design.DesignerAction.
ViewGrid;
break;
case "AlignLeft":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatTextAlignLeft;
break;
case "Center":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatTextAlignCenter;
break;
case "AlignRight":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatTextAlignRight;
break;
case "Justify":
result = DataDynamics.ActiveReports.Design.
DesignerAction.FormatTextAlignJustify;
break;
}
return result;
}
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the setStatus event.
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the setStatus event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. At the top left of the code view for frmDesigner, click the
drop-down arrow and select designer1. At the top right of the code window, click the
drop-down arrow and select StatusChanged. This creates an event-handling method for
the Designer1_StatusChanged event.
Click inside of the designer to select Designer1. Click on the events icon in the
Properties window to display available events for the section. Double-click
StatusChanged. This creates an event-handling method for the
Designer1_StatusChanged event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the executeReportAction
event.
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the executeReportAction event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the SetReport event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click in any section of frmDesigner, and click on View Code to display the code
view for the Windows Form. Add the following code to create the showReport event.
Double-click on frmDesigner to see the code view for the Windows form. Add the
following code to create the showReport event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
Right-click on frmPrintPreview, and click on View Code to display the code view for the
form. At the top left of the code view for frmPrintPreview, 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
frmPrintPreview_Load event.
Click on the blue section at the top of frmPrintPreview to select the form. Click on the
events icon in the Properties window to display available events for frmPrintPreview.
Double-click Load. This creates an event-handling method for the frmPrintPreview_Load
event.
The following example shows what the code for the method looks like:
[Visual Basic]
[C#]
This walkthrough illustrates how to create a deployment project in ActiveReports for a web
application.
HTTP Handlers
ActiveReports provides HTTPHandler components that, upon configuration, allow ASP.NET to
automatically process reports that have been placed into an ASP.NET web site folder.
ActiveReports HTTPHandler components enable easily deployable reports in both HTML and
PDF file formats. ActiveReports includes a simple configuration utility to properly register the
HTTPHandler components with IIS and ASP.NET.
This walkthrough illustrates how to create a simple Web application and set the HTTPHandler to
output report information in PDF format.
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
You must also have access to Internet Information Services either from your computer or from the
server. You must also run the "Configure Web Sample" option from the Data Dynamics
ActiveReports for .NET program menu from your Windows Start button.
When you have completed this walkthrough, you will have a report that looks similar to the
following.
Adding an ActiveReport to an ASP.NET Web application
To add an ActiveReport to your project
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 products ORDER BY categoryID, productname".
7. Click OK to return to the report design surface.
Note The version number will need to be updated to reflect the current version
of ActiveReports installed on your computer.
<a href="rptHTTPHandlers.rpx?OutputFormat=pdf">WebApp.<span
style="COLOR:red">rpx</span>/
<span style="COLOR: green">
</span>OutputFormat=pdf<span style="COLOR:red"></span></a>
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
You must also have access to Internet Information Services either from your computer or from the
server. You must also run the "Configure Web Sample" option from the Data Dynamics
ActiveReports for .NET program menu from your Windows Start button.
When you have completed this walkthrough, you will have a report that looks similar to the
following.
Adding an ActiveReport to an ASP.NET Web application
To add an ActiveReport to your project
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 products ORDER BY categoryID, productname".
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. Click on the ActiveReportViewer control in the appropriate toolbox and drag it onto
WebForm1.
2. Adjust the size according to your needs.
3. Change the Report property to rptWebView.
4. Make sure the ViewerType property is set to HtmlViewer.
Note To view the report in PDF format, change the ViewerType property to
AcrobatReader. To use the ActiveX Viewer, change the ViewerType property to
ActiveXViewer and paste the ActiveX viewer .cab file in your project folder (for
help with this, see "Using ActiveX Viewer Control on the Web").