Professional Documents
Culture Documents
AR6 User Guide
AR6 User Guide
Table of Contents
ActiveReports User Guide Introducing ActiveReports 6 What's New ActiveReports Editions GrapeCity Copyright Notice ActiveReports License Agreement Installation Requirements Installed Files Installation Troubleshooting Service Packs and Hot Fixes ActiveReports for .NET 2.0 Side-by-Side Installation License Your ActiveReports Upgrading Reports Changes from Previous Versions Upgrading from Previous Versions Migrating from ActiveReports 2 Converting MS Access Reports Getting Started Adding ActiveReports Controls Adding an ActiveReport to a Project ActiveReports Templates ActiveReports Designer Design View Report Explorer ActiveReports Toolbox Controls Text Input for TextBox and Label Controls Cross Section Controls Toolbar Designer Tabs Snap Lines 1 2 3-8 9-10 11 12-13 14 15 16-17 18 19 20 21-23 24 25 26-28 29 30 31 32 33 34 35 36 37-39 40-41 42-43 44 45 46 47
DataSource Icon Properties Window Viewing Reports Windows Form Viewer Hot Keys And Shortcuts ActiveReports and the Web Getting Started with the Web Viewer (Pro Edition) Flash Viewer Options Flash Viewer Hot Keys and Shortcuts Concepts Report Structure Report and Page Settings KeepTogether Options Date, Time, and Number Formatting Parameters Layout Files Scripting Export Filters HTML PDF Digital Signatures (Pro Edition) RTF Text TIFF Excel Charts Chart Elements Chart Series Chart and Series-Specific Properties Chart Wizard Chart Types Common Charts 3D Charts
48 49 50 51 52 53-55 56-57 58 59-60 61-62 63-64 65 66 67-68 69 70 71 72-73 74-75 76-77 78 79 80 81 82 83-84 85-86 87-93 94 95 96-101 102-110
XY Charts Financial Charts Chart Appearance Chart Effects Chart Control Items Chart Axes and Walls Chart Data RichText Grouping Data Multiple Groupings Subreports Report Events Section Events Sequence of Events Unbound Reporting Optimizing ActiveReports CacheToDisk and Resource Storage Section 508 Compliance Localization Designer Control (Pro Edition) How To Work with Data Bind Reports to a Data Source Group Data Modify Data Sources at Run Time Work with Fields Add Field Expressions Create Summary Fields Create Calculated Fields Create Common Reports Create Top N Reports Create Summary Reports Create Green Bar Reports
111-113 114-120 121 122-124 125-131 132-135 136-140 141-142 143 144-145 146 147-148 149 150-151 152-154 155-156 157 158-161 162 163 164-165 166 167-170 171 172-173 174 175-176 177 178 179 180 181 182-183
Change Ruler Measurements Display Page Numbers and Report Dates Format BarCodes Add Hyperlinks Add Annotations Export Reports Create a Digital Signature for a PDF Export Print Multiple Copies, Duplex, and Landscape Conditionally Show or Hide Details Use External Style Sheets Add Bookmarks Insert or Add Pages Create Charts Access the Chart Wizard and Data Source Load a File into a RichText Control Use Custom Controls on Reports (TreeView) Create Report Templates (Inheritance) Add Parameters Embed Subreports in a Report Pass Parameters to a Subreport Save and Load Report Files (RDF) Save and Load Report Layout Files (RPX) Add Code to Layouts Using Script Provide No-Touch Printing in the WebViewer (Pro Edition) Add Designer ToolStrips (Pro Edition) Add Report Links to Web Forms (Pro Edition) Customize, Localize and Deploy Customize the Viewer Control Localize the Viewer Control Cultures Localize Active Reports Resources Deploy Windows Applications
184-185 186 187-190 191-193 194-196 197 198-201 202-204 205-206 207-209 210-212 213-215 216-218 219-220 221-223 224-225 226-227 228-231 232 233-234 235-236 237-238 239-243 244 245-246 247 248 249-250 251 252-255 256 257-258
Deploy Web Applications (Std Edition) Localize the End User Report Designer Deploy the End User Report Designer (Pro Edition) Customize the FlashViewer Toolbar (Pro Edition) Localize the Flash Viewer Deploy Web Applications (Pro Edition) Customize End User Designer Help (Pro Edition) Deploy End User Designer Help (Pro Edition) Configure HTTPHandlers (Pro Edition) Configure Handler Mappings in IIS 7.0 Samples and Walkthroughs Samples NEW Flash Web Viewer Sample NEW Cross Section Control Sample NEW Style Sheets Sample Annual Report Sample Bound Data Sample Category Selection Sample Charting Sample Cross Tab Report Sample Custom Preview Sample Hyperlinks and Drill Down Sample Rdf Viewer Sample SubReports Sample Walkthroughs Basic Data Bound Reports Basic XML-Based Reports (RPX) Address Labels Columnar Reports Overlaying Reports (Letterhead) Chart Walkthroughs Bar Chart 3D Pie Chart
259 260 261 262-265 266 267-268 269-270 271 272-273 274 275 276-277 278-279 280-282 283-284 285-286 287-288 289-290 291-292 293-294 295-296 297-298 299 300-301 302 303-304 305-307 308-310 311-312 313-316 317 318-320 321-323
Financial Chart Unbound Chart Basic Spreadsheet with SpreadBuilder Group On Unbound Fields Subreport Walkthroughs Subreports with Run-Time Data Sources Nested Subreports Subreports with XML Data Hyperlinks for Simulated Drill-Down Reporting Mail Merge with RichText Run Time or Ad Hoc Reporting Run Time Layouts Run Time Data Sources Web Walkthroughs (Standard Edition) Custom Web Exporting (Std Edition) Custom HTML Outputter Web Services DataSet Web Service DataSet Windows Application Document Web Service Document Windows Application Layout Files with Embedded Script Script for Simple Reports Script for Subreports Creating a Basic End User Report Designer (Pro Edition) Web Viewer (Pro Edition) Flash Viewer Troubleshooting Export Troubleshooting
324-327 328-331 332-334 335-339 340 341-344 345-349 350-352 353-360 361-365 366 367-375 376-378 379 380-383 384-389 390 391-392 393-394 395-397 398-399 400 401-404 405-410 411-416 417-419 420-421 422-427 428-431
In This Documentation
Introducing ActiveReports 6 Find out what's new in ActiveReports 6, learn which features are freed from the evaluation banner with the Standard and Professional Edition licenses, and find copyright and license information. Installation View requirements for installation of ActiveReports 6, learn what files are installed and how to verify your installation, and find installation troubleshooting tips. License Your ActiveReports This topic walks you through how to license your machine and how to add licensing to any projects created during your evaluation. Upgrading Reports Use this section to guide you through the upgrade path from previous ActiveReports versions, and to learn to convert Microsoft Access reports to ActiveReports. Getting Started This section serves as a guide to help you to get started, with topics on adding controls to Visual Studio, adding reports to projects, and understanding the designer interface. You will also find topics on the report viewer and on using ActiveReports on the Web. Concepts This section explains important concepts to help you to understand what to expect from ActiveReports and how it works. How To Here you will find topics that guide you through specific tasks that you may want to perform with ActiveReports. Samples and Walkthroughs Find out how to use various features of ActiveReports using included sample projects and step-by -step guides to create new projects. Troubleshooting Browse frequently asked questions, learn how to resolve some common issues with ActiveReports, and find information on technical support options.
Introducing ActiveReports 6
ActiveReports leverages the latest technologies including XML, scripting and CSS along with open architecture to provide you with a fully-integrated and user-friendly report designer. This version now supports Visual Studio 2008, as well as Visual Studio 2005.
What's New
ActiveReports 6 contains many new features that enhance the reporting capabilities already praised by developers in previous versions of ActiveReports.
For more information, see Flash Viewer, Flash Viewer Options, and the NEW Flash Web Viewer Sample.
For a demonstration, see the NEW Cross Section Control Sample topic.
New SnapLines
SnapLines let you glide controls freely around your report instead of snapping to a grid, and display blue horizontal and vertical alignment lines and slowed dragging when your control comes into alignment with other controls or section edges. Visual placement of controls has never been easier.
For a demonstration, see the NEW Cross Section Control Sample topic. Note: The RepeatToFill property cannot be used if the PageBreak or SubReport control is used in the Detail section, or if the NewPage or NewColumn property is set to any value other than None.
New Professional Edition Digital Signature and TimeStamp Features on the PDF Export
The new Signature feature includes sixteen properties such as Certificate to prove that you created the document, and CertificationLevel to control users' access to your documents. And if you need to prove that data such as contracts or medical records existed before a certain point, set the new TimeStamp property on your PDF exports. To use the feature, provide the URL of a trusted third party acting as a time stamping authority (TSA). The digital signature and time stamp are concatenated with a one-way hash calculated from the report data.
See the NEW Style Sheets Sample and the Use External Style Sheets topic for more information.
New ToolStrips
The End User Designer no longer relies on clunky old toolbars or CommandBarManager. It has all been replaced with the Visual Studio ToolStrip component. See the refurbished EndUserDesigner Sample for a demonstration, or see the Add Designer ToolStrips topic for more information.
New Direct Text Input for TextBox, Label, and CheckBox Controls
Double-click inside the control or select it and press the F2 key to edit text directly in the control instead of using the Properties window. If you do use the Properties window, the Text property now supports multi-line text input.
Note: The Justify alignment option is not supported in edit mode for the TextBox and Label controls. For more information, see Text Input for TextBox and Label Controls.
Reduced Space Symbology (RSS) encodes Composite Component (CC) extended EAN and UPC information in less space. Here are the six variations included, and their usages:
RSS14 14-digit EAN.UCC item identification for use with omnidirectional point-of-sale scanners. RSS14Truncated 14-digit EAN.UCC item identification plus Indicator digits for use on small items, not for point-of-sale scanners. RSS14Stacked (pictured above) Same as RSS14Truncated, but stacked in two rows when RSS14Truncated is too wide. RSS14StackedOmnidirectional Same as RSS14, but stacked in two rows when RSS14 is too wide. RSSExpanded 14-digit EAN.UCC item identification plus AI element strings (expiration date, weight, etc.) for use with omnidirectional point-of-sale scanners. RSSExpandedStacked Same as RSSExpanded, but stacked in two rows when RSSExpanded is too wide.
For more information, see Customize End User Designer Help or Deploy End User Designer Help.
New Licensing
The SetLicense method has been deprecated. See License Your ActiveReports for information on using the new licensing.
ActiveReports Editions
ActiveReports 6 is an enhancement of the popular ActiveReports engine and report viewer. It includes the same power and flexibility of ActiveReports and the same integration with the Visual Studio .NET 2005 Environment, and adds several new features including integration with the Visual Studio .NET 2008 Environment. Available in two editions, ActiveReports 6 delivers outstanding reporting capabilities. Drop down the sections below to see the features packed with each edition of ActiveReports. Standard Edition Features
Designer
Full integration with the .NET environment Familiar user interface NEW SnapLines to help you visually align controls C# and VB.NET support The ability to compile reports into the application for speed and security or to keep them separate for ease of updating Designer hosting of .NET and user controls
Report Controls
ReportInfo Label Line PageBreak OleObject Subreport Shape Picture RichTextBox with HTML tag support ChartControl with separate data source Textbox Barcode with standard styles plus NEW RSS and UPC styles Checkbox NEW CrossSectionBox extends from a header section to the related footer section NEW CrossSectionLine extends from a header section to the related footer section
Reporting Engine
Managed code Binding to ADO.NET, XML, iList, and custom data sources NEW Document DLL as a separate assembly All of the features of previous versions of ActiveReports
Report Viewer
Managed C# code Very small deployment assembly, suitable for use on the Internet Table of Contents and Bookmarks Thumbnail View
Export Filters
ActiveReports includes export filters to generate output into Rich Text Format (RTF) for word-processing, Portable Document Format (PDF) for printing, 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. Professional Edition Features ActiveReports 6 Professional Edition includes all of the features of the Standard Edition and supports the following additional features:
ASP.NET Integration
The 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 AcrobatReader ViewerType enumeration. NEW Flash ViewerType enumeration supports multiple browsers and allows you to avoid asking users to install an ActiveX control.
HTTP Handlers
The RPX HTTPHandler allows the developer to hyperlink ActiveReports on a web page to return HTML format or PDF format reports for viewing and/or printing. The Compiled Report HTTPHandler allows the developer to hyperlink ActiveReports compiled in an assembly on a web page to return HTML format or PDF format reports for viewing and/or printing.
The PdfSignature class allows you to provide PDF document digital signatures and certification. The PdfStamp class allows you to draw the digital signatures and certification onto the documents. The TimeStamp class allows you to add a TSA (Time Stamping Authority) stamp to your digital signatures.
LICENSE:
The Product is licensed per software application developer (developer). Licensee is defined as the person or entity that pays consideration for the license to use the Product. GrapeCity, inc. hereby grants the Licensee a nonexclusive License authorizing one, and only one, developer at a time to use the Product for development purposes. The Licensee is also permitted to distribute applications containing the files designated below on a royalty-free basis. The use of this License does not create any kind of partnership or joint ownership interest in the Licensees proprietary applications. Please contact GrapeCity, inc. if you require additional Licenses. Licensee may incorporate the sample code into Licensees applications. Use of this product by more than one developer at a time terminates, without notification, this License and the right to use the Product.
RESTRICTIONS:
Licensee may use the Product in Licensee's business application for sale or distribution as long as: 1. The application that Licensee produces and/or distributes is NOT a software development application that is sold primarily to software developers or system integrators or a development environment of any kind. Please contact GrapeCity, inc. for special commercial licensing provisions in these circumstances. The software serial number and Licensee must be registered with GrapeCity, inc. in order to receive support or distribution rights. Licensee may not remove any proprietary notices, labels, or trademarks on the Product or documentation. Licensee may copy documentation content for distribution with their end user designer application so long as GrapeCity, inc. is given credit within the distributed documentation. Licensee may not modify, de-compile, disassemble, reverse engineer or translate the Product or any component thereof.
2. 3. 4. 5.
TERM:
Licensee may terminate its License and this Agreement at any time by destroying all copies of the Product and Product Documentation. This License and this Agreement will also terminate automatically if Licensee fails to comply with any term or condition in this Agreement.
LIMITED WARRANTY
This Product and Product documentation are licensed "as is" without any warranty as to their performance, merchantability or fitness for any particular purpose. Licensee assumes the entire risk as to the quality and performance of the Product. GrapeCity, inc. 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 GrapeCity, inc. or anyone else who has been involved in the creation, development, production, or delivery of the Product 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.
Installation
This section will help you to understand the installation process.
Requirements
To install and use ActiveReports 6, you need compatible hardware and software.
Processor: Pentium II-class processor 450 MHz (Pentium III 600 MHz recommended) RAM: 200 MB Hard drive space: 50 MB available
Software requirements
Operating System: Windows 2000, Windows XP, Windows NT 4.0, or Windows Vista Microsoft .NET Framework Version: 2.0 or higher Microsoft Visual Studio: 2005 or 2008. Note: The Express Editions of Visual Studio 2005 do not work with ActiveReports, as they do not support packages. For Web deployment: IIS 5.1 or 6.0 and ASP.NET (version to match the .NET Framework version)
Installed Files
To verify package installation
1. 2. 3. Open Visual Studio. If the package installed successfully, the ActiveReports logo is on the splash screen. From the Help menu, select About and verify that ActiveReports appears in the installed products list.
When you install ActiveReports and use all of the default settings, files are installed in the following folders: C:\Documents and Settings\YourAccountName\Start Menu\Programs\GrapeCity\ActiveReports 6 File (or Folder) Samples ActiveReports 6 Documentation for Visual Studio .NET 2005 ActiveReports 6 Documentation for Visual Studio .NET 2008 Introduction Uninstall ActiveReports 6 Description Start menu shortcuts to included sample projects. Shortcut to the integrated help file. Shortcut to the integrated help file. Shortcut to the readme.hta file. Shortcut to the installer application.
C:\Documents and Settings\YourAccountName\My Documents\GrapeCity\ActiveReports 6 File (or Folder) Description Samples Included sample projects. C:\Program Files\GrapeCity\ActiveReports 6 File (or Folder) Data Deployment Introduction Localization Description Sample XML and MDB data files. Flash viewer file, Flash viewer localization resources and themes for redistribution. Readme.hta and associated image files. Resource and DOS batch files for localizing ActiveReports components. For more information, see Localize Active Reports Resources.
C:\Program Files\Common Files\GrapeCity\ActiveReports 6 File (or Folder) Description 1033 Folder for default U.S. English locale. 1041 Folder for Japanese locale. ActiveReports6.dll Run-time engine assembly file. ActiveReports.Chart.dll Chart control assembly file. ActiveReports.CodeDomSerializer.dll Helper file for Visual Studio integration. ActiveReports.Design6.dll Designer assembly file. ActiveReports.Document.dll Document assembly file. ActiveReports.HtmlExport.dll HTML Export assembly file. ActiveReports.Interop.dll Native functions assembly file. ActiveReports.Interop64.dll Native functions assembly for 64-bit machines. ActiveReports.PdfExport.dll PDF Export assembly file. ActiveReports.RtfExport.dll RTF Export assembly file. ActiveReports.TextExport.dll Text Export assembly file. ActiveReports.TiffExport.dll TIFF Export assembly file. ActiveReports.Viewer6.dll Viewer assembly file. ActiveReports.Web.Design.dll Web designer assembly file. ActiveReports.Web.dll Web assembly file. ActiveReports.XlsExport.dll Microsoft Excel Export assembly file. AR6Col_A.HxK ActiveReports help integration index. ARVSPackage.dll Visual Studio integration package.
Installation Troubleshooting
Symptoms: Other users cannot access or use ActiveReports on my machine. Cause: The installation for ActiveReports 6 gives you the option to install the program for everyone or the current user. If it is installed only for the current user, other users cannot access it or use it. Solution: Reinstall ActiveReports and select Everyone.
Symptoms: I just installed ActiveReports 6. Why can't I see the help files? Cause: If the installation was run while Visual Studio was open, the help files cannot be integrated. Solution: Close Visual Studio and reopen it.
Symptoms: When I run the ActiveReports Setup, I get the message "The installer was interrupted before GrapeCity ActiveReports 6 could be installed. You need to restart the installer to try again." Cause: You do not have permissions to install on the machine, or to the folder containing the setup files. Solution: Verify that the system account for the local machine has permissions to the folder containing the setup and log in as Administrator on the machine.
Hot Fixes
These are interim releases that have fixes for specific issues found either internally or reported by users. Hot Fixes are tested, but not as rigorously as Service Packs. We recommend that you install a Hot Fix only if you are affected by an issue that is fixed in it and cannot wait for a Service Pack.
Service Packs
These are interim releases that include all fixes incorporated in the Hot Fixes up to that point in time, plus we add a few minor features to each one. Service Packs undergo the same rigorous testing as product releases.
********** ActiveReports HttpHandler Configuration ********** --> <add verb="*" path="*.rpx" type="DataDynamics.ActiveReports.Web.Handlers.RpxHandler, ActiveRe <add verb="*" path="*.ActiveReport" type="DataDynamics.ActiveReports.Web.Handlers.CompiledRep <add verb="*" path="*.ArCacheItem" type="DataDynamics.ActiveReports.Web.Handlers.WebCacheAcce </httpHandlers> 2. Open the ASPX page and look in the Source view for a line that looks similar to the following and update the version number:
<%@ Register TagPrefix="ActiveReportsWeb" Namespace="DataDynamics.ActiveReports.Web" Assembly="ActiveReports.Web, Version=6.0.1661.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff 3. Save and rebuild your project.
User Name: Enter your name or company name here. You can use any characters in this field except the semicolon. Email: Enter your e-mail address in this field. Serial: Enter the serial number exactly as you received it from GrapeCity, including any dashes or capital letters.
2.
Click the Next button and then the Finish button to complete the installation. The Licensing result message box informs you that licensing was successful.
3.
The machine is now licensed, and no nag screens or evaluation banners appear when you use the product or create new solutions with it. To license a trial version of ActiveReports without reinstalling
1. 2. 3. 4. 5.
From the Start menu, open the Control Panel. Select Add or Remove Programs. From the list of currently installed programs, select ActiveReports 6. Click the Change button. Select License ActiveReports 6 and click the Next button.
6.
User Name: Enter your name or company name here. You can use any characters in this field except the semicolon. Email: Enter your e-mail address in this field. Serial: Enter the serial number exactly as you received it from GrapeCity, including any dashes or capital letters.
If you have already created any Visual Studio projects using ActiveReports components, see the appropriate section on licensing Windows or Web applications below. To check an existing ActiveReports Windows application for licensing Caution: If the application containing ActiveReports is not an executable, licensing must be embedded in the calling application, or root level executable, to take effect.
3. 4.
Expand the My Project node. If there is a file called licenses.licx in the file list, the ActiveReports application is licensed. If the licenses.licx file does not appear in your file list, follow the instructions under To license Windows Forms projects below. To license Windows Forms projects made with the trial version
1. 2. 3. 4.
Ensure that ActiveReports is licensed on the machine by following the steps above for licensing either during installation of ActiveReports or later if using a trial version. Open the project in Microsoft Visual Studio. Open the Visual Studio Build menu and select Rebuild Solution. The executable application is now licensed, and no nag screens or evaluation banners appear when you run it. You can distribute the application to un-licensed machines and no nag screens or evaluation banners appear. To license Web Forms projects made with the trial version
1. 2. 3.
Ensure that ActiveReports is licensed on the machine by following the steps above for licensing either during installation of ActiveReports or later if using a trial version. Open the project in Microsoft Visual Studio. Open the Visual Studio Build menu and select Rebuild Solution. Note: For licensing Web Site applications, open the Visual Studio Build menu and select Build Runtime Licenses to create the App_Licenses.dll file. The web application is now licensed, no evaluation banners appear when you run it. You can distribute the Web application to unlicensed machines and no evaluation banners appear. Note: When using the PDF export filter in your project, you should open the licenses.licx file and make sure that it contains a proper reference to the PDF Export Assembly. Important: The SetLicense() Method has been deprecated and can no longer be used for licensing ActiveReports. To learn how to license your ActiveReports, please refer to the sections located above.
4.
To license ActiveReports on the machine without internet connection, please contact our support team: activereports.support@grapecity.us.com.
Upgrading Reports
ActiveReports allows you to upgrade your reports from other versions of ActiveReports and other reporting programs.
The ActiveReports 6 Report Converter converts and updates previous versions of ActiveReports to ActiveReports 6 format. Save back-ups of your reports before running it.
Note: We recommend that you check the Active Reports for NET 2.0 or Active Reports for NET 3.0 project before running the ActiveReports 6.0 Report Converter and make sure that the project has valid ActiveReports references. The SetLicense method for run-time reporting and end user designer licensing has been marked as obsolete and raises a compile error. We have updated our licensing models and we sincerely hope to provide an easy and seamless licensing and deployment experience with this release. See License Your ActiveReports (mshelp://dd.ActiveReports6.1033/ddAR6/arHOWLicensingActiveReports.html) for more information. The Report.Show method has been removed. This removes the viewer dependency for a leaner package. Instead, you can use the Preview tab at design time or the Viewer control at run time.
3. 4. 5. 6.
Expand the References folder, and make note of which ActiveReports references you use in your project. Right-click each of the ActiveReports3 references, and select Remove. Right-click the References folder and select Add Reference. In the Add Reference window that appears, select Version 6.x.xxx.x of the ActiveReports references. Note: You also need to add the new GrapeCity ActiveReports Document reference to the project, as some of the code has moved. Click the OK button to add the references and close the window. Many errors appear in the Visual Studio Error List window. To correct the errors
7.
1. 2. 3. 4. 5. 6.
If the Visual Studio Error List window is not showing, drop down the View menu and select Error List. In the Error List window, double-click the warning that states that ActiveReports3 could not be defined. In the report code, ActiveReports3 is highlighted. Change ActiveReport3 to ActiveReport. This resolves most of the errors in the list. In the Error List window, double-click the warning that states that ActiveReports3.FetchEventArgs could not be defined. In the report code, change ActiveReport3 to ActiveReport. Close and reopen the design view of the report.
3.
Click OK to convert the files. The reports appear in the Solution Explorer as C# or Visual Basic files and all references to earlier versions of ActiveReports are updated. Note: We recommend that you check the Active Reports for NET 2.0 or Active Reports for NET 3.0 project before running the ActiveReports 6.0 Report Converter and make sure that the project has valid ActiveReports references.
4.
If the old project used the rpt.Show method, an error appears in the Error List window. To correct the error, replace the code with rpt.Run, then add a Viewer control to the form and set the viewer.Document = rpt.Document. For details, see Viewing Reports.
4.
In the ActiveReports Microsoft Access Import Wizard that appears, click the ellipsis button button to browse for the Access Database that contains the report or reports you want to convert and click the Open button..
5. 6.
If you receive a security warning, click Open to proceed. Select the reports from the database that you want to import and click Next.
7. 8. 9.
Click Finish to begin the conversion process. Click Open to proceed through any security warnings. Click Finish when the conversion process has finished. The converted reports appear in the Solution Explorer.
Getting Started
Quickly begin using ActiveReports by reviewing some of the most commonly used features.
2.
In the Choose Toolbox Items window that appears, in the Filter textbox, enter DataDynamics.ActiveReports. Tip: Include the dot at the end of DataDynamics.ActiveReports. to eliminate the controls you use on the reports themselves and display only the controls that you can use with Windows Forms or Web Forms.
3.
Select the check boxes next to any of the controls that you want to add to your toolbox:
Designer HtmlExport PdfExport ReportExplorer RtfExport TextExport TiffExport Toolbox Viewer WebViewer XlsExport
4.
3.
Click Add to add the report to your project and open it in design view.
ActiveReports Templates
To create a report, an end-user must select a template containing the report layout. In ActiveReports 6, there are two types of such templates the XML-based report template , ActiveReports 6 (xml-based) File , and the code-based report template, ActiveReports 6 (code -based) File . It is possible to use both types of report templates within one project. A report layout based on the code-based template is saved as a C# or Visual Basic for .NET file, whereas a report layout based on the xml-based template is saved as an RPX file. The RPX file is an XML-formatted file which contains the layout information and any scripts added to the report. RPX files with scripting allow to change and modify distributed reports without recompiling the project. They also make it possible to use a database of report file names to set up a collection of reports to run. You can use an RPX file using scripting as a stand-alone file in a web project. Note: An RPX file in ActiveReports for .NET 2.0 has an associated .cs or .vb file containing code added to the report, whereas an RPX file in ActiveReports 6 does not require any associated code file. For additional information, see ActiveReports for .NET 2.0 Side-by-Side Installation.
Once a template is selected, the process of designing a report is similar for both types of report templates see Basic Data Bound Reports, Basic XML-Based Reports (RPX). With the xml-based report template, a user cannot use regular code. Instead, a user is able to access the controls and sections in script editor by using "this"(c#) or "Me"(vb) in addition to the current way of using "rpt" (see Scripting for more details). Note: Since the RPX file can be read with any text editor, the AddCode or AddNamedItem method (refer to the Class Library section of this User Guide for information on how to use these methods) should be used to add secure information, such as a connection string, to a project.
ActiveReports Designer
With its various tools and properties, ActiveReports 6 offers great flexibility in constructing report projects. Click one of the red-outlined areas to view a topic with more information on that section.
Design View
When you first add an ActiveReport to a Visual Studio project, the design view of the report displays by default. To reopen one that you have closed, double-click the report in the Solution Explorer. Select any section or the report itself to view available properties in the Properties window. (Click in the grey area below the report to select the report.)
Use the ruler to determine how your report will look on paper. If you drag the right edge of the report, or drop controls near the right edge, you can see by the ruler how much the PrintWidth of the report has grown. Keep in mind that you have to add the right and left margin widths to the PrintWidth to determine whether your report will fit on the selected paper size. By default, a report has three sections: a page header, a detail section, and a page footer. Drag controls from the toolbox onto these sections to display your data. Right-click the report and select Insert to add other types of header and footer section pairs. For more information, see Report Structure, Section Events and Grouping Data. In walkthroughs and how-to topics, you may be told to double-click the grey area below the report to create the ReportStart event. You can also click in this area to select the report. The preview tab allows you to check out your report without running the project and displaying it in the Viewer control. The script tab is where you can add VB.NET or C# script for use with RPX portable layout files. For more information, see Layout Files. Use section grab handles to drag a section's height up or down. Click the data source icon to open the Report Data Source window, from which you can bind your report to any OLE DB, SQL, or XML data source. For more information, see DataSource Icon. Click a section collapse icon to close a section that you have finished working on so you don't accidentally move or change any of your controls.
Report Explorer
In ActiveReports, the Report Explorer gives you a visual overview of the elements that make up the report in the form of a tree view with nodes for:
The Report
Fields
Bound Calculated
In the Report Explorer, you can remove individual controls, add parameters and calculated fields, drag bound data fields onto the report as textbox controls, and change report settings. You can also select a section, control, or the report itself to display in the Properties window, where you can modify its properties. If you do not see the Report Explorer in Visual Studio: 1. 2. Right-click the Visual Studio toolbar and select ActiveReports 6 to display the designer toolbar. On the designer toolbar, click the View Report Explorer button.
Or from the View menu, select Other Windows, then Report Explorer. When you open the Report Explorer in Visual Studio, it appears every time you create a new Windows Application. You can close it any time. The Report Explorer lays out all of the elements contained in your report in one place.
The following demonstrates how you can quickly modify a report using the Report Explorer.
To add parameters
1. 2. 3. 4. In the Report Explorer, right-click the Parameters node and select Add. The new parameter is displayed in the Report Explorer and in the Properties window. In the Properties window, set the Prompt property to a string value to ask users for data. Leave the PromptUser property set to True. When you run the report, a dialog displays the Prompt to the user. Drag the parameter from the Report Explorer onto the design surface of your report to create a textbox that is bound to the parameter. When you run the report, the value that the user supplies in the prompt dialog displays in the bound textbox on the report.
Tip: If you do not see the Visual Studio toolbox, from the View menu, select Toolbox.
Control Pointer
Description (Important properties are in bold.) Selected by default, the pointer allows you to select, move, and resize controls, and resize sections. After you drop or draw a control onto your report, the pointer is automatically selected. A text box with preset FormatString options, the report info control allows you to quickly display page numbers, page counts, and report dates. For more information, see Display Page Numbers and Report Dates.
ReportInfo
Label
The label allows you to display static text to describe the data you display in text boxes. Use the Text property to set the label text. Set the Angle property to 900 for vertical text. Now supports direct text input. Use the line to visually separate or call out areas of your report. You can drag it to the size and location you want, or use the X1, X2, Y1, and Y2 properties. The AnchorBottom property lets the line grow along with the section. Use the page break to have the report stop inside a section and resume printing on a new page. You may also wish to use the PageBreakBefore or PageBreakAfter properties available on the sections themselves. You can add an OLE object, bound to a database or unbound, directly to your report. When you drop or draw the control onto your report, the Insert Object dialog allows you to create
Line
PageBreak
SubReport
Shape Picture
RichTextBox
TextBox
Barcode
CheckBox
Drag the cross section box onto a header section and it spans any intervening sections to CrossSectionBox end in the related footer section. Set the Radius property to round the edges of the box. See Cross Section Controls for more information. Drag the cross section line onto a header section and it spans any intervening sections to end in the related footer section. This line control is strictly vertical. If you want a horizontal CrossSectionLine or diagonal line, use the Line control, which does not span sections. See Cross Section Controls for more information.
The text in the control is formatted in edit mode by means of the ActiveReports toolbar, or by modifying properties in the Properties window. The formatting commands are applied to the entire text in the selected control. Note: Text formatting changes in the Properties window are immediately applied to the text in the selected control, and changes made by means of the toolbar are immediately reflected in the Properties window. Note: The Justify alignment option is not supported in edit mode for the TextBox and Label controls. To apply this alignment option, a user should exit edit mode, select the TextBox or Label control by clicking on it and then set the alignment to Justify in the Toolbar or in the Properties window. If the TextBox or Label control with the Justify alignment is put into edit mode, the alignment value automatically changes to the default one - Left. However, after exiting edit mode, the alignment value of the TextBox or Label control automatically changes back to Justify. It is also possible to use key commands when working with a textbox or label control in edit mode. Key Combination Enter New line. Shift + Enter New line. Action
In the End User Designer, you can disable this feature using the EditModeEntering and EditModeExit events.
CrossSectionLine
The CrossSectionLine control is a vertical line that begins in the GroupHeader and ends in the corresponding section footer. At run time, the line stretches across the detail section. You can control the appearance of the line with properties such as:
LineColor allows you to select a color for the line. LineStyle allows you to select from various styles of dashes, dots, or solid. LineWeight allows you to set the width of the line in pixels.
CrossSectionBox
The CrossSectionBox control draws a rectangle that begins in a section header and ends in the corresponding section footer. You can control the appearance of the rectangle with the properties above, plus:
Radius allows you to set a value in pixels to round the corners of the box, where 0 is a rectangle and 200 is a circle.
Toolbar
You can rearrange buttons and menu options, as well as hide, display, dock or float the ActiveReports toolbar in Visual Studio.
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 text in the RichText control, or all text in any other control. Size Sets the font size of the selected text in the RichText control, or all text in any other control. View Grid Indicates whether the grid display is on or off. If the grid is on, snap lines are turned off. Reorder Groups Opens the Group Order dialog, where you can drag and drop groups to rearrange them. Enabled when you have multiple groups. Zoom Out Reduces the magnification level of the design surface. Zoom In Increases the magnification level of the design surface. Zoom Sets the magnification level of the design surface between 100 and 800%. Bold Sets or removes text emphasis. Applies to selected text in the RichText control, or all text in any other control. Italic Sets or removes text slant. Applies to selected text in the RichText control, or all text in any other control. Underline Sets or removes text underlining. Applies to selected text in the RichText control, or all text in any other control. Align Left Aligns the text left in the control area. Align Center Centers the text in the control area. Align Right Aligns the text right in the control area. Justify Fully justifies the text in the control area. Bullets Adds bullets to selected text in the RichText control area. Decrease Indent Decreases the indent of selected text in the RichText control area. Increase Indent Increases the indent of selected text in the RichText control area.
Designer Tabs
The designer tabs located at the bottom of the ActiveReports design surface allow you to quickly access three aspects of ActiveReports: the Designer, the Script, and the Preview.
Designer
The designer tab is selected by default when you create or open an ActiveReport in Visual Studio. On this tab, you can drag controls from the toolbox to create a layout, add, remove, and resize sections, set properties on sections and controls, bind the report to a data source, and create event-handling methods.
With ActiveReports Professional Edition, you can create a similar designer for end users with the Designer Control.
Script
Select the Script tab to open the script editor, where you can add portable code to reports that you want to save as RPX layouts. For more information, see Layout Files. The script editor contains two drop-down boxes that allow you to select any section of the ActiveReport and any events associated with that section, or the report itself and related events. When you select an event, the script editor generates a method stub for the event.
Preview
The Preview tab allows you to quickly view your report at run time without the need to actually run your project. This makes it easy to quickly see the run-time impact of changes you make in the designer or the code.
Snap Lines
By default, ActiveReports now uses snap lines instead of a grid on the design surface. You can use snap lines in the ActiveReport design view within Visual Studio, and your end users can use them in the compiled End User Designer. Snap lines are dynamic horizontal and vertical layout guidelines used to make it easier to position controls on your reports, and are similar to the ones found in Visual Studio 2005 and later. If you prefer to use a grid, you can change this setting in the Report Settings window on the Global Settings tab.
When you drag a control around on the report, blue snap lines appear and the control slows down when the control aligns with another control or a section edge, similar to a magnet pulling the control into alignment. Snap lines even show you when your control is aligned with controls in other sections. Unlike using a grid, the control moves freely around the report and you can place it anywhere.
Tip: If you plan to export a report to Excel format, use snap lines to ensure that your controls are aligned in columns and rows to avoid empty cells in the spreadsheet.
DataSource Icon
Use the DataSource icon to bind your report to a data source at design time.
When you click the icon, the Report Data Source window appears. You can connect the report to OLE DB, SQL, or XML data, and supply a query to retrieve the data you want. You can also add parameters to the report by using parameter syntax in the SQL query. For more information, see Add Parameters.
Select the OLE DB, SQL, or XML tab to see the options you have for each type of data source. For more information, see Bind Reports to a Data Source .
Properties Window
The Visual Studio Properties window is an important tool when you are designing an ActiveReports layout. Select any control, section, or the report itself to gain access to its properties in the Properties window. Select a property to reveal a description in the bottom section of the window. Just above the description is a commands section that contains verbs, links to windows that give you access to further properties for the item. Only the chart control and the report itself have associated verbs. If you cannot see the Description or Command section, right-click anywhere on the Properties window and ensure that both are selected, or try resizing the sections.
For more information on some of the important properties for ActiveReports controls, see ActiveReports Toolbox Controls.
Viewing Reports
Previewing Reports at Design Time
ActiveReports makes it easy for you to preview your report while you are still creating it. Just click the Preview tab at the bottom of the ActiveReport designer. In this way you can see and work with the report without the need to run the project.
The following examples show what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form Load event. Dim rpt As New rptMain() rpt.Run() Viewer1.Document = rpt.Document To write the code in C# C# code. Paste INSIDE the Form Load event. rptMain rpt = new rptMain(); rpt.Run(); this.viewer1.Document = rpt.Document; Note: To enable the viewer's Copy button, add references to the RtfExport and TextExport DLLs.
Standard Edition
The Standard Edition license does not have a Web viewer, but you can export reports for use on the Web or use Web Services to distribute documents or data sources. For more information, see Web Walkthroughs (Standard Edition).
Description PageNumber Allows you to specify the page to display initially. PrintOptions Allows you to specify how the viewer handles page orientation and scaling. ResourceLocale Allows you to specify the culture for localization. Separate multiple values with commas. ShowSplitter Allows you to specify whether to display the splitter, which allows the user to compare report pages in the viewer. ShowThumbnails Allows you to specify whether to display a pane with thumbnail views of pages. ShowToc Allows you to specify whether to display the table of contents pane. StartPrint Allows you to specify whether to print the report after loading for no-touch printing. If you set the WebViewer's Height and Width properties to 0, you can have the report print without displaying it. ThemeUrl Allows you to specify the relative URL of a skin to use on the FlashViewer. The following skins are included:
New FlashViewerOptions These options apply only when you select the FlashViewer ViewerType.
Zoom Allows you to specify the zoom level, between 10% and 800%, at which to display the report. BookmarkStyle Allows you to specify whether to use HTML bookmarks. CharacterSet Allows you to select from 15 character sets to use for the report.
CreateFramesetPage Allows you to specify whether to use Frameset or Body tags in the generated HTML report. IncludeHtmlHeader Allows you to specify whether to include a header section in the generated HTML report. IncludePageMargins Allows you to specify whether to keep page margins with reports in the generated HTML. MultiPage OutputType Allows you to specify whether to use DHTML or HTML for the output. RemoveVerticalSpace Allows you to specify whether to keep white space, for example, space at the end of a page not filled with data before a page break.
HtmlExportOptions These options apply only when you select the HtmlViewer ViewerType.
MaxReportRunTime
Title Allows you to specify the text to display in the title bar of the Web browser. The maximum number of seconds that a request for a report's output waits for the report to finish executing. The default value is 10 seconds. If a report takes longer to run than the value of this property, the control makes subsequent requests at 5 second intervals for the report to see when it is finished executing.
Application Allows you to set the value to display in the Application field in the Document Properties dialog of the Acrobat Reader. Author Allows you to set the value to display in the Author field in the Document Properties dialog of the Acrobat Reader. CenterWindow Allows you to specify whether to position the document's window in the center of the screen in the initial view when the document is opened in the Acrobat Reader. ConvertMetaToPng Allows you to specify whether to convert meta files (WMF or EMF) into PNG files in the PDF. DisplayMode Allows you to specify how to display the document: in outlines, thumbnails, full screen, or none to use the Acrobat Reader's default display mode. DisplayTitle Allows you to specify whether to display the document title from the Title property. Encrypt Allows you to specify whether to encrypt the document. ExportBookmarks Allows you to specify whether to create PDF bookmarks from any bookmarks that may be in the report. FitWindow Allows you to specify whether to resize the document's window to fit the size of the first displayed page. HideMenuBar Allows you to specify whether to hide the viewer application's menu bar when the document is active. HideToolbar Allows you to specify whether to hide the viewer application's tool bars when the document is active. HideWindowUI Allows you to specify whether to hide user interface elements in the documents window (such as scroll bars and navigation controls), leaving only the documents contents displayed. ImageQuality Allows you to specify whether to render image metafiles (WMF or EMF) in the document at lowest, medium, or highest quality. ImageResolution Allows you to specify the image resolution for metafiles (WMF or EMF). Typical values are 75-2400 dpi. 75 dpi at low resolution would be used to save space, 150 dpi is used for normal screen viewing and 300 dpi and higher is used for print quality.
PdfExportOptions These options apply only when you select the AcrobatReader ViewerType.
Keywords Allows you to set the value to display in the Keywords field in the Document Properties dialog of the Acrobat Reader. These are
NeverEmbedFonts Allows you to specify a semicolon-delimited string of values indicating which fonts are not embedded in the PDF document. Not embedding any of the fonts used in your documents can reduce the PDF file size dramatically if you use many fonts. OwnerPassword Allows you to specify the password to enter in the reader to permit full access to the document regardless of the specified user permissions. Permissions Allows you to specify the user permissions for the document. You can combine Permissions by using commas between values. Subject Allows you to specify the value to display in the Subject field in the Document Properties dialog of the Acrobat Reader. Title Allows you to specify a title to display when the DisplayTitle property is set to True. Use128Bit Allows you to specify whether to use 128 bit encryption with full permissions capability. Set to True to enable the AllowFillIn, AllowAccessibleReaders, and AllowAssembly permissions to function. Set to False to use 40 bit encryption with limited permissions. UserPassword Allows you to specify the password to enter to allow a user to open the document in the reader. If this value is left empty, the user is not prompted for a password, but is restricted by the specified permissions.
Version Allows you to specify whether to use Pdf11 (v1.1), Pdf12 (v1.2), or Pdf13 (v1.3 or Acrobat 4.0). This new property replaces the old Report property. The new property is a string instead of an ActiveReport object, and specifies the report to display in the viewer. Inherited from System.Web.UI.WebControls.WebControl The interval in seconds between the time the report was last retrieved and the time the report is removed from the ASP.NET WebCache.
HtmlViewer Provides a scrollable view of a single page of the report at a time. Downloads only HTML and javascript to the client browser. Not recommended for printable output. RawHtml Shows all pages in the report document as one continuous HTML page. Provides a static view of the entire report document, and generally printable output, although under some circumstances pagination is not preserved. AcrobatReader Returns output as a PDF document viewable in Acrobat Reader. Client requirements: Adobe Acrobat Reader.
ViewerType
FlashViewer Provides an interactive viewing experience and no-touch printing using the widely-adopted Flash Player. Client Requirements: Adobe Flash Player.
For more information on properties inherited from the system, see the Class Library and Visual Studio help.
Property PageNumber PrintOptions AdjustPaperOrientation PrintOptions ScalePages PrintOptions StartPrint ResourceLocale ShowSplitter ShowThumbnails ShowToc
Description Allows you to specify the page to display initially. Select from None, Auto, or AllowScaleUp.
Select from None, Auto, or AdjustByFirstPage. Allows you to specify whether to print the report after loading for no-touch printing. If you set the WebViewer's Height and Width properties to 0, you can have the report print without displaying it. Allows you to specify the culture for localization. Separate multiple values with commas. Allows you to specify whether to display the splitter, which allows the user to compare report pages in the viewer. Allows you to specify whether to display a pane with thumbnail views of pages. Allows you to specify whether to display the table of contents pane. Allows you to specify the relative URL of a skin to use on the FlashViewer. The following skins are included:
ThemeUrl
WindowMode
Zoom
Concepts
This section introduces you to the basic structure and concepts behind ActiveReports 6 to enable you to efficiently create reports.
Report Structure
ActiveReports are based on banded sections. By default, an ActiveReport has three sections: a PageHeader, a Detail section, and a PageFooter. You can right-click on the report and select Insert, then select the type of section pair you would like to add: ReportHeader and Footer, or GroupHeader and Footer. Except for the Detail section, sections always come in pairs. A report section contains a group of controls that are processed and printed at the same time as a single unit. All sections except the detail section come in pairs, above and below the detail section. You can hide any section that you are not using by setting the Visible property of the section to False. 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 only needs to appear once at the report's start. This section has a NewPage property that you can use to cause the report to break to a new page after it renders.
Page Header
A report can have one page header section that prints at the top of each page. Unless the page contains a report header section, the page header is the first section that prints on the page. 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.
GroupHeader
A report can consist of single or nested groups, with each group having its own header and footer sections. The header section is inserted and printed immediately before the detail section. For more information on grouping, see Grouping Data. The GroupHeader section is the only section type on which you can drop the new CrossSectionBox and CrossSectionLine controls, which then span any intervening sections to the corresponding GroupFooter section. For Columnar Reports, you can have the GroupHeader section follow the ColumnLayout or not, use ColumnGroupKeepTogether, and select whether to start a NewColumn before or after a group. You can also specify whether to print a NewPage before or after the section, and have the section print on every page until the group details complete with the RepeatStyle property. The UnderlayNext property allows you to show group header information inside the group details, so long as you keep the BackColor property of the Detail section set to Transparent.
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. You can set the CanShrink property to True to eliminate white space after controls, and you can set up Columnar Reports using ColumnCount, ColumnDirection, ColumnSpacing and NewColumn properties. The KeepTogether property attempts to keep the section together on a single page, and the new RepeatToFill property allows you to fill each page with the same number of formatted rows, regardless of whether there is enough data to fill them. This is especially useful for reports such as invoices in which you want consistent formatting like lines or green bars or back colors to fill each page down to the Footer section at the bottom. Note: The RepeatToFill property cannot be used if the PageBreak or SubReport control is used in the Detail section, or if the NewPage or NewColumn property is set to any value other than None.
GroupFooter
A report can consist of single or 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.
Page Footer
Report Footer
A report can have one report footer section that prints at the end of the report. Use this section to print a summary of the report, grand totals, or any information that needs to print once at the report's end.
Alternatively, you can right-click the Settings node in the Report Explorer and select Show.
Page Setup
On the Page Setup page, you can make changes to the report margins (left, right, top, and bottom), specify a gutter, and select the Mirror margins option. By setting a gutter and selecting Mirror margins, you can easily set up reports for publishing purposes. When you select Mirror margins, 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.
Printer Settings
On the Printer Settings page, you can make changes to the printer paper size and orientation. You can set a custom paper size by dropping down the Paper Size list and selecting Custom Size . Once you select this
Styles
On the Styles page, you can change the appearance of text associated with controls, either by creating a new style sheet, or by modifying and applying an existing style. See Use External Style Sheets for more information.
Global Settings
On the Global Settings page, you can change the design layout of your report. You can use SnapLines, show or hide the grid, set the controls to align to the grid, have a warning appear when you try to delete a parameter or calculated field from the Report Explorer, set the number of columns or rows on the grid, and change the ruler units to inches or centimeters. Also, you can set the number of Pages that display in the Preview tab of the ActiveReports Designer. The minimum value is 1 and the maximum value is 10000. By default, the Preview tab displays 10 pages. This is generally enough to allow you to see all of your report sections without taking the time to generate the entire report.
KeepTogether Options
ActiveReports provides several KeepTogether options for your reports so that you can keep sections together when you print them.
GroupKeepTogether ColumnGroupKeepTogether
KeepTogether
The KeepTogether property, when set to True, attempts to print the section on a single page with no page breaks. If the section is too large for the current page and too large to fit fully on the next page, the KeepTogether property is ignored. Setting the property to False allows the section to split across two or more pages.
GroupKeepTogether
The GroupKeepTogether property, which can be set on a group header section, has three enumerated values:
None is the default setting. The group header does not attempt to stay with its related sections, so the group block is allowed to split across pages. FirstDetail keeps the group header and at least the first detail together on the same page to prevent widowed group header sections. If there is no room on the current page for the first detail, the group header moves to the next page along with the detail. All attempts to keep the section, related details, and group footer as a single block on the same page. If the group block does not fit on a single page, the property is ignored.
ColumnGroupKeepTogether
The ColumnGroupKeepTogether property only takes effect when the GroupHeader's GroupKeepTogether property is set to All, and the Detail section's Columns property is set to a value greater than 1. When set to true, it keeps newspaper-style column layouts in both the Detail and Group sections together. It attempts to prevent a group block from splitting across columns. If a group cannot fit in the current column, it tries the next. If the group is too large for a single column, the property is ignored. Setting the property to False allows the group block to split across two or more columns. For more information on columnar reports, see the Columnar Reports walkthrough.
The first section provides the format for positive numbers. The second section provides the format for negative numbers. The third section provides the format for Zero values. The fourth section provides the format for Null or System.DBNull values.
Times:
hh:mm tt = 09:00 AM HH:mm = 21:00 (twenty-four hour clock) HH = hours in 24 hour clock hh = hours in 12 hour clock mm = minutes ss = seconds tt = AM or PM
Dates:
dddd, MMMM d, yyyy = Saturday, December 25, 2004 dd/MM/yyyy = 25/12/2004 d or dd = day in number format ddd = day in short string format (for example, Sat for Saturday) dddd = day in string format (for example, Saturday) MM = month in number format MMM = month in short string format (for example, Dec for December) MMMM = month in string format (for example, December) y or yy = year in two digit format (for example, 04 for 2004) yyyy or yyyy = year in four digit format (for example, 2004)
$0.00 = $6.25 $#,#00.00 = $06.25 0 = digit or zero # = digit or nothing % = percent-multiplies the string expression by 100
Parameters
You can use the ActiveReports Parameters collection to pass values directly into a textbox or a chart on a report, or to choose what subset of data from your data source to display in a particular instance of a report, or to pass values from a main report into a subreport. There are several ways in which you can collect values for parameters:
You can prompt the user for parameter values. You can get parameter values from the main report and pass them into a subreport. You can collect parameter values from a control in a Web form or a Windows form.
There are also several ways in which you can set up parameters for a report:
You can enter syntax like the following into your SQL query: <%Name | PromptString | DefaultValue | DataType | PromptUser%> You can add parameters to the Report Explorer. You can add parameters to the code behind the report, in the ReportStart event.
At least one parameter exists in the Parameters collection of the report. The PromptUser property for at least one parameter is set to True. On the report object, the ShowParameterUI property must be set to True.
When there are parameters in the collection and the ShowParameterUI property is True, the user prompt automatically displays when the report is run. When the user enters the requested values and clicks the OK button, the report displays using the specified values. Tip: Within the same report, you can prompt users for some parameters and not for others by setting the PromptUser property to True on some and False on others. However, if the report object's ShowParameterUI property is set to False, the user prompt does not display for any parameters regardless of its PromptUser setting. In order to collect parameters from a main report to pass into a subreport, all of the following must be in place:
The SQL queries for both reports must contain the same field. The subreport's ShowParameterUI property must be set to False. The subreport's SQL query must contain the parameter syntax with the Name value set to the name of the field that is common to both reports.
To collect parameter values from a Windows form or a Web form, use code to collect the values into variables, and then pass them into the report's ReportStart event. See sample code in the Add Parameters topic. In this case, the report's ShowParameterUI property must be set to False .
There are five values in the parameter syntax, separated by the pipe character: | Only the first value (Name) is required, but if you do not specify the third value (DefaultValue), the field list is not populated at design time. You can provide only the Name value and no pipes, or if you wish to provide some, but not all of the values, simply provide pipes with no space between them for the missing values. For example, <%ProductID||||False%>
Name This is the unique name of the parameter, and corresponds to the Key property in parameters entered via code. PromptString This string is displayed in the user prompt to let the user know what sort of value to enter. DefaultValue Providing a default value to use for the parameter allows ActiveReports to populate the bound fields list while you are designing your report, enabling you to drag fields onto the report. It also populates the user prompt so that the user can simply click the OK button to accept the default value. Type This value, which defaults to S for string, tells ActiveReports what type of data the parameter represents. It also dictates the type of control used in the user prompt. The type can be one of three values.
S (string) provides a textbox into which the user can enter the string. Note: Depending on your data source, you may need to put apostrophes (single quotes) or quotation marks around the parameter syntax for string values. For example, '<%MyStringParameter%>' Also, if you provide a default value for a string parameter that is enclosed in apostrophes or quotation marks, ActiveReports sends the apostrophes or quotation marks along with the string to SQL. For example, <%MyStringParameter||"DefaultValue"|S|False%>
D (date) provides a drop-down calendar control from which the user can select a date. Note: Depending on your data source, you may need to put number signs around the parameter syntax. For example, #<%MyDateParameter%># B (Boolean) provides a checkbox which the user can select or clear. Note: If you provide a default value of True or False, or 0 or 1 for a Boolean parameter, ActiveReports sends it to SQL in that format.
PromptUser This Boolean allows you to tell ActiveReports whether to prompt the user for a value. This can be set to True for some parameters and False for others. If you set the report's ShowParameterUI property to False, users are not prompted for any parameters, regardless of the PromptUser value set for any parameter in the report.
For a date parameter, you can use a SQL query like the following to allow users to select a beginning and ending date. SQL Query. SELECT * FROM Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID WHERE OrderDate BETWEEN #<%StartDate|Start date|1/1/1994|D|True%># AND #<%EndDate|End date|12/31/1994|D|True%>#
Layout Files
Report layouts in ActiveReports are automatically saved as C# or Visual Basic for .NET files within the project in which they are created. Each report is composed of three files:
In this way, layout information models the behavior of Windows Forms in the .NET framework. However, you can also save report layouts as stand-alone Report XML (RPX) files. RPX files are the same report layouts used in previous editions of ActiveReports for .NET. This makes ActiveReports 6 truly backward compatible. Older layout files can easily be brought into the newest applications while new layout files can be saved to an older format. When you save a layout that contains a dataset, the data adapter and data connection are saved, but the dataset itself is lost. When you load the saved layout into another report, you must generate the dataset again. The RPX format cannot contain Visual Basic.NET or C# code. In order to port logic along with the layout, you can add VB.NET or C# script in the Script view of the report.
For more information on using script with a layout file, see Scripting.
Scripting
ActiveReports allows you to use VB.NET or C# script to port your custom logic to report layouts. This permits layouts saved to report XML (RPX) files to serve as stand-alone reports. By including scripting before you save the report layout as an RPX file, you can later load, run, and display the report directly to the viewer control without using the designer. In conjunction with RPX files, scripting allows you to update distributed reports without recompiling your project. ActiveReports loads RPX files, including any scripting, in the InitializeComponent() method. You can add C# or VB.NET code to the script editor at design time or by using the rpt.Script property at run time. The script is then saved to the RPX file along with layout information. To access the script editor, click the script tab below the report design surface.
Since the RPX file can be read with any text editor, use the AddCode or AddNamedItem method to add secure information such as a connection string. Note: The ActiveReports script editor supports IntelliSense that helps the writing of code by making the access to the language elements fast and easy.
Keep the report class public. If the report class is private, the script cannot recognize the items in your report. The report class is public by default. Set the Modifiers property of any control referenced in script to Public. If the control's Modifiers property is not set to Public, the control cannot be referenced in script and an error occurs when the report is run. The Modifiers property has a default value of Private , so you must set this property in the designer. Use "this" (as in C# code-behind) or "Me" (as in VB code-behind) to reference the report. Using "rpt" to reference the report is also possible but it is recommended to use the "this" and "Me" keywords. Use error handling. When working with script, use error handling around the .Run() call. When errors are raised, the returned error points to the section of script causing the error.
Export Filters
ActiveReports provides custom components for exporting reports into six formats. Each export format has special features, however, not all formats support all of the features that you can use in your reports. Here are the unique usage possibilities of each format, along with any limitations inherent in each.
For information on using these export filters, see the Export Reports or Custom Web Exporting (Std Edition) topics.
HTML
HTML, or hypertext markup language, is a format that opens in a Web browser. The HTML export filter has a number of useful properties that allow you to control your output. You can set the properties either in code using the export object, or by selecting the object in the component tray below the form and using the Properties window. Table of HTML Export Properties Property BookmarkStyle Valid Values Html (default) or None Description Set to Html to generate a page of bookmarks from the bookmarks in the report. If the report has no bookmarks, this setting is ignored.
Big5, EucJp, HzGb2312, Ibm850, Iso2022Jp, Iso2022Kr, Iso8859_1, Select the IANA character set that you want to use Iso8859_2, Iso8859_5, in the meta tag in the header section of the HTML CharacterSet Iso8859_6, Koi8r, Ksc5601, output. This property only takes effect if the ShiftJis, UnicodeUtf16, UnicodeUtf8 IncludeHtmlHeader property is set to True. (default) Set to True to generate a set of frames that display a page of bookmarks (if available) in the left frame CreateFramesetPage True or False (default) and the report document in the right frame. The HTML output uses the specified filename with the extension .frame.html. Set to False if you want to embed the HTML output in another HTML document. Otherwise, the HTML IncludeHtmlHeader True (default) or False output includes the usual HTML, HEAD, and BODY elements. Set to True to include the report's margins in the IncludePageMargins True or False (default) HTML output. Set to True to create a separate HTML page for MultiPage True or False (default) each page of the report. Otherwise, the HTML output is a single page. Set to LegacyHtml to use tables for positioning and DynamicHtml (default) or avoid the use of cascading style sheets (CSS). OutputType LegacyHtml Otherwise, positioning of controls is handled in the CSS. Set to True if the OutputType property is set to LegacyHtml and you plan to print the output from a RemoveVerticalSpace True or False (default) browser. This removes white space from the report to help improve pagination. Otherwise, vertical white space is kept intact. Enter the text to use in the header section's title. Title Any String This is displayed in the title bar of the browser.
Create Web reports with Cascading Style Sheets (CSS) Open in Web browsers
Usage:
Line control Control borders Shapes (other than filled rectangles) CrossSectionBox and CrossSectionLine controls Overlapping controls
PDF
PDF, or portable document format, opens in the Adobe Acrobat Reader. The PDF export filter has a number of useful properties that allow you to control your output. You can set the properties either in code using the export object, or by selecting the object in the component tray below the form and using the Properties window. Table of PDF Export Properties Description Set to True to change any Windows metafile images to PNG format to True or False ConvertMetaToPng keep the file size down. If the report has no metafiles, this setting is (default) ignored. Set to True to generate bookmarks from the bookmarks in the report. If True (default) or the report has no bookmarks, this setting is ignored. To control how the ExportBookmarks False exported bookmarks are displayed, use Options.DisplayMode detailed below. Set to Highest in combination with a high value in the ImageResolution Lowest, Medium property to yield the best printing results when converting Windows ImageQuality (default), or metafiles (.wmf and .emf). Set to Lowest to keep the file size down. If Highest the report has no metafiles, this setting is ignored. Set to 75 dpi to save space, 150 dpi for normal screen viewing, and 300 dpi or higher for print quality. Use this property in combination with ImageResolution 75 - 2400 dpi ImageQuality (highest) to yield the best results when the report contains metafiles or the Page.DrawPicture API is used. Neither property has any effect on other image types. A semicolonList all of the fonts that you do not want to embed in the PDF file to NeverEmbedFonts delimited string keep the file size down. This can make a big difference if you use a lot of font names of fonts in your reports. Expand this property to see a group of subproperties. These settings Options See below control how the Adobe Acrobat Reader displays the output PDF file when it is first opened. See the table below for details. Expand this property to see a group of subproperties. These settings Security See below control encryption and permissions on the output PDF file. See the table below for details. A valid This must be set up in code. For more information, see Digital Signature PdfSignature Signatures (Pro Edition) and Create a Digital Signature for a PDF object. Export. The default value is PDF specification 1.3, which is the native file format Pdf11, Pdf12, or Version of Acrobat 4.0, or you can set it to an earlier version. Any version opens Pdf13 (default) in newer Acrobat Readers. Property Valid Values
Create printable reports whose formats do not change from machine to machine Open in Adobe Acrobat Reader
DisplayMode
None (default) bookmarks are not displayed until opened by the user. Outlines shows bookmarks in outline format. Thumbs shows bookmarks as thumbnails.
True or False (default) True or False (default) True or False (default) True or False (default)
FullScreen shows the document in full screen, and bookmarks are not displayed. Set to True to use the Title string entered in the Title property below. Otherwise, the file name is used. Set to True to expand the window to fit the size of the first displayed page. Set to True to hide the menu in the Acrobat Reader when the document is first opened. Set to True to hide the toolbars in the Acrobat Reader when the document is first opened. Set to True to hide the scrollbars and navigation controls in the Acrobat Reader when the document is first opened, displaying only the document. Enter keywords to display in the Acrobat Document Properties dialog, Description tab, Keywords field. Enter a subject to display in the Acrobat Document Properties dialog, Description tab, Subject field. Enter a title to display in the Acrobat Document Properties dialog, Description tab, Title field. Set DisplayTitle to True to display this text in the title bar of the Acrobat Reader when the document is opened.
Title
String
Table of PDF Security Properties Property Encrypt Valid Values True or False (default) Description Set to True to change any Windows metafile images to PNG format to keep the file size down. If the report has no metafiles, this setting is ignored. Enter the string to use as a password that unlocks the document regardless of specified permissions. Combine multiple values by dropping down the selector and selecting the check boxes of any permissions you want to grant. By default, all of the permissions are granted. Set to False to use 40 bit encryption with limited permissions. (Disables AllowFillIn, AllowAccessibleReaders, and AllowAssembly permissions.) Enter the string to use as a password that unlocks the document using the specified permissions. Leave this value blank to allow anyone to open the document using the specified permissions.
OwnerPassword String None, AllowPrint, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowAccessibleReaders, or AllowAssembly True (default) or False
Permissions
Use128Bit
UserPassword
String
export.Signature.VisibilityType
export.Signature.TimeStamp
export.Signature.Stamp.Bounds
export.Signature.Stamp.Image
Specify the area where an image or text will be placed inside the export.Signature.Stamp.TextRectangle signature rectangle (e.g. = New RectangleF(0, 0.135, 3, 1)). The property uses the upper-left corner as a start point and or is specified in coordinates, relative to the signature rectangle. If export.Signature.Stamp.ImageRectangle this property is not specified, the entire signature rectangle will be used for placing an image or text. Specifies whether the text in the signature is left-aligned, rightaligned, or centered. (e.g. = Alignment.Left).The alignment is export.Signature.Stamp.TextAlignment performed inside the text rectangle that is included into the signature rectangle. export.Signature.Stamp.ImageAlignment Specifies the alignment of an image inside the image rectangle that is included into the signature rectangle.(e.g. =
Sets the level of other users access to the document (e.g. = CertificationLevel.FormFilling). Note: Be careful when changing fonts of exports using localization. If a selected font does not support the language, then the localized labels are not shown in the signature.
RTF
RTF, or RichText format, opens in Microsoft Word, and is native to WordPad. This export does not render reports exactly as they appear in the Viewer due to inherent differences in the formats. The RTF export filter has one property, EnableShapes, that allows you to control your output. You can set the property either in code using the export object, or by selecting the object in the component tray below the form and using the Properties window. Usage:
Only supported when EnableShapes property is True: If you set the EnableShapes property to True, the resulting RTF file displays correctly only in Web Layout View in Microsoft Word.
Text
Plain Text is a format that opens in Notepad or Microsoft Excel depending on the file extension you use in the filePath parameter of the Export method. Use the extension .txt for files to open in Notepad, or use .csv for comma separated value files to open in Excel. The Text export filter has a number of useful properties that allow you to control your output. You can set the properties either in code using the export object, or by selecting the object in the component tray below the form and using the Properties window. Table of Text Export Properties Property Encoding Valid Values System.Text.ASCIIEncoding (default), System.Text.UnicodeEncoding, System.Text.UTF7Encoding, or System.Text.UTF8Encoding String Description This property can only be set in code. Enter an enumerated system encoding value to use for character encoding. Enter a character or sequence of characters to mark the end of each page. Set to False if you want to keep empty lines in the exported text file. Otherwise, white space is removed. Enter a character or sequence of characters to mark the end of each text field. This is mainly for use with CSV files that you open in Excel.
PageDelimiter
TextDelimiter
String
Text
Usage:
Create plain text files Create comma (or other character) delimited text files Feed raw data to spreadsheets or databases Open in Notepad or Excel (comma delimited)
Supports plain text only with no formatting other than simple delimiters Supports encoding for foreign language support
TIFF
TIFF, or tag image file format, opens in the Windows Picture and Fax Viewer or any TIFF viewer. This export looks very much like the report as it displays in the viewer, but it is a multi-page image, so the text cannot be edited. The TIFF export filter has a couple of useful properties that allow you to control your output. You can set the properties either in code using the export object, or by selecting the object in the component tray below the form and using the Properties window. Table of TIFF Export Properties Property Valid Values Description Select an enumerated value to use for color output control:
None delivers color output with no compression. Rle (run-length encoding) is for 1, 4, and 8 bit color depths. Ccitt3 is for 1 color depth, and is used in old standard faxes.
Dither
Lzw (based on Unisys patent) is for 1, 4, and 8 bit color depths with lossless compresssion. Set to True to dither the image when you save it to a black and white format (Ccitt3 or Rle). This property has no effect if the CompressionScheme is set to Lzw or None.
Usage:
Create optical archive reports Send reports via fax machines Open in image viewers
Excel
XLS is a format that opens in Microsoft Excel as a spreadsheet. This export does not render reports exactly as they appear in the Viewer due to inherent differences in the formats. The XLS export filter has a number of useful properties that allow you to control your output. You can set the properties either in code using the export object, or by selecting the object in the component tray below the form and using the Properties window. Table of XLS Export Properties Property Valid Values True or False (default) True (default) or False Xls97Plus (default) or Xls95 Description Set to True to have Excel set the height of rows based on the contents. Otherwise XlsExport calculates the height of rows. In some cases this may make the output look better inside Excel. However, a value of True may adversely affect pagination when printing, as it may stretch the height of the page. Set to False to hide grid lines in Excel. Set to Xls95 to use Microsoft Excel 95 format. Otherwise, a format optimized for Excel 97 and newer is used. Set the number of inches that is the smallest width for a column in the exported spreadsheet.
AutoRowHeight
DisplayGridLines FileFormat
MinColumnWidth
Single (VB) or float Tip: Larger values reduce the number of empty columns in a (C#) sheet. Set this value to 1 inch or more to get rid of small empty columns.
Set the number of inches that is the smallest height for a row in the exported spreadsheet. MinRowHeight Single (VB) or float Tip: Larger values force the export to place more controls on a (C#) single line by reducing the number of rows added to match blank space. Set this value to .25 inches or more to get rid of small empty rows. Set to True to export each page of your report to a separate sheet within the Excel file. This can increase performance and output quality at the cost of memory consumption for reports with complex pages and a lot of deviation between page layouts. In general, use False for reports with more than 30 pages. True or False RemoveVerticalSpace (default) UseCellMerging Usage:
MultiSheet
Set to True to remove vertical empty spaces from the spreadsheet. This may improve pagination for printing. Set to True to merge cells where applicable.
Line control Shapes (other than filled rectangles) CrossSectionBox and CrossSectionLine controls Overlapping controls Borders on controls with angled text Angled text
Charts
Follow the links below for information about concepts essential to the use of the Chart control. Chart Elements See an overview of the different pieces that make up an ActiveReports Chart. Chart Series Explains what a series is and how it comprises the data that is seen on a chart. Chart- and Series-Specific Properties Learn which series properties apply to each of the Chart Types. Chart Wizard Shows how to access the Chart Wizard. Chart Types Shows examples of Common Charts, 3D Charts, XY Charts, and Financial Charts. Chart Appearance Covers Chart Effects, Chart Control Items, and Chart Axes and Walls. Chart Data Discusses ways of connecting a chart to data.
Chart Elements
You can use the ActiveReports Chart control to display data visually and help readers to easily analyze and interpret numerical and relational data. The elements that make up an ActiveReports chart bring meaning to the visual information. You have the following major elements at your disposal:
The following image illustrates the elements that make up the ActiveReports Chart control.
Chart Elements
Axis Label A label along an axis that lets you label the units being shown. Axis Title
Chart Series
A chart series is the key to showing data in a chart. All data is plotted in a chart as a series and all charts contain at least one series. The bars in the image below depict two series in a simple bar chart.
Each series is made up of a set of data points consisting of an X value that determines where on the X axis the data is plotted, and one or more Y values. Most charts use one Y value but a few charts such as the Bubble, BubbleXY, and the financial charts take multiple Y values. When you bind data to a series, the X value is bound using the ValueMembersX property on the Series object, and the Y value is bound using the ValueMembersY property. The Series object also contains properties for each individual series, including chart type, custom chart properties, annotations, containing chart area, and more. Each chart type in the ActiveReports Chart control contains series-specific properties that apply to it. You can set the chart type and these series-specific properties in the Series Collection Editor dialog, which opens when you click the ellipsis button next to the Series (Collection) property in the Visual Studio Properties window.
You can manipulate each data point in the DataPoint Collection dialog box. You can access the dialog from the Series Collection Editor by clicking the ellipsis button next to the Points (Collection) property.
When you set a property on the Series object, it is applied to all data point objects in the series unless a different value for the property is set on a specific data point. In that case, the data point property setting overrides the series property setting for that particular data point. Note that for charts bound to a data source, you do not have access to the DataPoint collection in the dialog. If you specify the value for any of the custom properties, this value is not cleared when you change the ChartType. Although this will show properties that do not apply to certain ChartTypes, it has the advantage of keeping your settings in case you accidentally change the ChartType.
Backdrop: Gets or sets the backdrop information for the series. Does not apply to Bezier, Line, LineXY, Line3D, PlotXY, or Scatter charts. BorderLine: Gets or sets the line information used to draw the border of the series. Does not apply to Bezier, Line, LineXY, PlotXY, or Scatter charts. Line: Gets or sets the line information for the series. Only applies to Bezier, Line, and LineXY charts. Marker: Gets or sets the ToolTip settings for the series. ToolTip: Gets or sets the ToolTip information for the series.
LineBackdrop Gets or sets the backdrop information for the 3D line. Thickness Gets or sets the thickness of the 3D line. Width Gets or sets the width of the 3D line.
Gap Gets or sets the space between the bars of each X axis value.
BarTopPercent Gets or sets the percentage of the top of the bar that is shown for Cone or Custom BarTypes. BarType Gets or sets the type of bars that are displayed. Values are Bar, Cylinder, Cone, Pyramid, and Custom. Gap Gets or sets the space between the bars of each X axis value. PointBarDepth Gets or sets the thickness of the 3D bar. RotationAngle Gets or sets the starting horizontal angle for custom 3D bar shapes. Can only be used with the Custom BarType. VertexNumber Gets or sets the number of vertices for the data point, used to create custom 3D bar shapes. Can only be used with the Custom BarType. Bars must contain 3 or more vertices.
Tension Gets or sets the tension of the curved lines. Values must be less than or equal to 1. Default is null.
Tension Gets or sets the tension of the curved lines. Values must be less than or equal to 1. Default is null. Width Gets or sets the width of the 3D line.
Bubble
MaxSizeFactor Gets or sets the maximum size of the bubble radius. Values must be less than or equal to 1. Default is .25. MaxValue Gets or sets the bubble size that is used as the maximum. MinValue Gets or sets the bubble size that is used as the minimum. Shape Gets or sets the shape of the bubbles. Uses or returns a valid MarkerStyle enumeration value.
BodyDownswingBackdrop Gets or sets the backdrop information used to fill the downswing rectangle. BodyUpswingBackdrop Gets or sets the backdrop information used to fill the upswing rectangle. BodyWidth Gets or sets the width of the rectangle used to show upswing or downswing. Wickline Gets or sets the line information for the wick line.
BarTopPercent Gets or sets the percentage of the top of the bar that is shown for Cone or Custom BarTypes. BarType Gets or sets the type of bars that are displayed. Values are Bar, Cylinder, Cone, Pyramid, and Custom. Gap Gets or sets the space between the bars of each X axis value. RotationAngle Gets or sets the starting horizontal angle for custom 3D bar shapes. Can only be used with the Custom BarType. VertexNumber Gets or sets the number of vertices for the data point, used to create custom 3D bar shapes. Can only be used with the Custom BarType. Bars must contain 3 or more vertices.
Clockwise Gets or sets a value indicating whether to display the data in clockwise order. By default, the data is displayed counterclockwise beginning at 12 o'clock. ExplodeFactor Gets or sets the amount of separation between data point values. The value must be less than or equal to 1. To explode one section of the doughnut chart, set ExplodeFactor on the data point instead of on the series. HoleSize Gets or sets the inner radius of the chart. If set to 0, the chart looks like a pie chart. The value must be less than or equal to 1. OutsideLabels Gets or sets a value indicating whether the data point labels appear outside the chart. Radius Gets or sets the size of the doughnut within the chart area. StartAngle Gets or sets the horizontal start angle for the series.
Clockwise Gets or sets a value indicating whether to display the data in clockwise order. By default, the data is displayed counterclockwise beginning at 12 o'clock. ExplodeFactor Gets or sets the amount of separation between data point values. The value must be less than or equal to 1. To explode one section of the doughnut chart, set ExplodeFactor on the data point instead of on the series. HoleSize Gets or sets the inner radius of the chart. If set to 0, the chart looks like a pie chart. The value must be less than or equal to 1. OutsideLabels Gets or sets a value indicating whether the data point labels appear outside the chart. Radius Gets or sets the size of the doughnut within the chart area. StartAngle Gets or sets the horizontal start angle for the series data points.
Funnel
CalloutLine Gets or sets the style for a line connecting the marker label to its corresponding funnel section. The default value is a black one-point line. FunnelStyle Gets or sets the Y value for the series points to the width or height of the funnel. The default value is YIsHeight. MinPointHeight Gets or sets the minimum height allowed for a data point in the funnel chart. The height is measured in relative coordinates. NeckHeight Gets or sets the neck height for the funnel chart. This property can only be used with the FunnelStyle property set to YIsHeight. The default value is 5. NeckWidth Gets or sets the neck width for the funnel chart. This property can only be used with the FunnelStyle property set to YIsHeight. The default value is 5. OutsideLabels Gets or sets a value indicating whether the labels are placed outside of the funnel chart. The default value is True. OutsideLabelsPlacement Gets or sets a value indicating whether the data point labels appear on the left or right side of the funnel. This property can only be used with the OutsideLabels property set to True. PointGapPct Gets or sets the amount of space between the data points of the funnel chart. The PointGapPct is measured in relative coordinates. The default value is 0, and valid values range from 0 to 100.
BaseStyle Gets or sets a circular or square base drawing style for the 3D funnel chart. This property only takes effect if the Projection property is set to Orthogonal. CalloutLine Gets or sets the style for a line connecting the marker label to its corresponding funnel section. The default value is a black one-point line. FunnelStyle Gets or sets the Y value for the series points to the width or height of the funnel. The default value is YIsHeight. MinPointHeight Gets or sets the minimum height allowed for a data point in the funnel chart. The height is measured in relative coordinates. NeckHeight Gets or sets the neck height for the funnel chart. This property can only be used with the FunnelStyle property set to YIsHeight. The default value is 5. NeckWidth Gets or sets the neck width for the funnel chart. This property can only be used with the FunnelStyle property set to YIsHeight. The default value is 5. OutsideLabels Gets or sets a value indicating whether the labels are placed outside of the funnel chart. The default value is True. OutsideLabelsPlacement Gets or sets a value indicating whether the data point labels appear on the left or right side of the funnel. This property can only be used with the OutsideLabels property set to True. PointGapPct Gets or sets the amount of space between the data points of the funnel chart. The PointGapPct is measured in relative coordinates. The default value is 0, and valid values range from 0 to 100. RotationAngle Gets or sets the left-to-right rotation angle of the funnel. The valid values range from 180 to 180 degrees. This property is only effective with the Projection property set to Orthogonal and the BaseStyle property set to SquareBase.
Gap Gets or sets the space between the bars of each X axis value.
BarTopPercent Gets or sets the percentage of the top of the bar that is shown for Cone or Custom BarTypes. BarType Gets or sets the type of bars that are displayed. Values are Bar, Cylinder, Cone, Pyramid, and Custom.
Gap Gets or sets the space between the bars of each X axis value. PointBarDepth Gets or sets the thickness of the 3D bar. RotationAngle Gets or sets the starting horizontal angle for custom 3D bar shapes. Can only be used with the Custom BarType. VertexNumber Gets or sets the number of vertices for the data point, used to create custom 3D bar shapes. Can only be used with the Custom BarType. Bars must contain 3 or more vertices.
HiLoLine Gets or sets the line information for the hi-lo line.
CloseLine Gets or sets the line information for the close line. HiLoLine Gets or sets the line information for the hi-lo line. OpenLine Gets or sets the line information for the open line. TickLen Gets or sets the length of the tick for the open and close lines.
Gap Gets or sets the space between the bars of each X axis value.
BarTopPercent Gets or sets the percentage of the top of the bar that is shown for Cone or Custom BarTypes. BarType Gets or sets the type of bars that are displayed. Values are Bar, Cylinder, Cone, Pyramid, and Custom. Gap Gets or sets the space between the bars of each X axis value. PointBarDepth Gets or sets the thickness of the 3D bar. RotationAngle Gets or sets the starting horizontal angle for custom 3D bar shapes. Can only be used with the Custom BarType. VertexNumber Gets or sets the number of vertices for the data point, used to create custom 3D bar shapes. Can only be used with the Custom BarType. Bars must contain 3 or more vertices.
DownswingLine Gets or sets the style and color settings to use for a Kagi line which charts a price decrease. ReversalAmount Gets or sets the amount that a price must shift in order for the Kagi line to change direction. UpswingLine Gets or sets the style and color settings to use for a Kagi line which charts a price increase.
BodyDownswingBackdrop Gets or sets the style and color settings for the three-dimensional side view of downswing Kagi lines. This property is only effective when the Width property is set to a value higher than 25. BodyUpswingBackdrop Gets or sets the style and color settings for the three-dimensional side view of upswing Kagi lines. This property is only effective when the Width property is set to a value higher than 25. DownswingLine Gets or sets the style and color settings to use for a Kagi line which charts a price decrease. ReversalAmount Gets or sets the amount that a price must shift in order for the Kagi line to change direction.
UpswingLine Gets or sets the style and color settings to use for a Kagi line which charts a price increase. Width Gets or sets the width of the three-dimensional side view of the Kagi lines.This property must be set higher than its default value of 1 in order to display body downswing and upswing backdrops.
LineJoin Gets or sets the type of join to draw when two lines connect. Valid values include Miter, Bevel, Round, and MiterClipped.
LineBackdrop Gets or sets the backdrop information for the 3D line. Thickness Gets or sets the thickness of the 3D line. Width Gets or sets the width of the 3D line.
BoxSize Gets or sets the amount a price must change in order to create another X or O. DownswingLine Gets or sets the style and color settings for the downswing Os. ReversalAmount Gets or sets the amount that a price must shift in order for a new column to be added. UpswingLine Gets or sets the style and color settings for the upswing Xs.
CalloutLine Gets or sets the style for a line connecting the marker label to its corresponding pyramid section. The default value is a black one-point line. MinPointHeight Gets or sets the minimum height allowed for a data point in the pyramid chart. The height is measured in relative coordinates. OutsideLabels Gets or sets a value indicating whether the labels are placed outside of the pyramid chart. The default value is True. OutsideLabelsPlacement Gets or sets a value indicating whether the data point labels appear on the left or right side of the pyramid. This property can only be used with the OutsideLabels property set to True. PointGapPct Gets or sets the amount of space between the data points of the pyramid chart. The PointGapPct is measured in relative coordinates. The default value is 0, and valid values range from 0 to 100.
BaseStyle Gets or sets a circular or square base drawing style for the 3D pyramid chart. This property only takes effect with the Projection property set to Orthogonal. CalloutLine Gets or sets the style for a line connecting the marker label to its corresponding pyramid section. The default value is a black one-point line. MinPointHeight Gets or sets the minimum height allowed for a data point in the pyramid chart. The height is measured in relative coordinates. OutsideLabels Gets or sets a value indicating whether the labels are placed outside of the pyramid chart. The default value is True. OutsideLabelsPlacement Gets or sets a value indicating whether the data point labels appear on the left or right side of the pyramid. This property can only be used with the OutsideLabels property set to True. PointGapPct Gets or sets the amount of space between the data points of the pyramid chart. The PointGapPct is measured in relative coordinates. The default value is 0, and valid values range from 0 to 100. RotationAngle Gets or sets the left-to-right rotation angle of the pyramid. The valid values range from 180 to 180 degrees. This property is only effective with the Projection property set to Orthogonal and the
BodyDownswingBackdrop Gets or sets the style and color settings for the downswing bricks. BodyUpswingBackdrop Gets or sets the style and color settings for the upswing bricks. BoxSize Gets or sets the amount a price must change in order to create another brick.
BodyDownswingBackdrop Gets or sets the style and color settings for the downswing bricks. BodyUpswingBackdrop Gets or sets the style and color settings for the upswing bricks. BoxSize Gets or sets the amount a price must change in order to create another brick.
Gap Gets or sets the space between the bars of each X axis value.
BarTopPercent Gets or sets the percentage of the top of the bar that is shown for Cone or Custom BarTypes. BarType Gets or sets the type of bars that are displayed. Values are Bar, Cylinder, Cone, Pyramid, and Custom. Gap Gets or sets the space between the bars of each X axis value. VertexNumber Gets or sets the number of vertices for the data point, used to create custom 3D bar shapes. Can only be used with the Custom BarType. Bars must contain 3 or more vertices.
Gap Gets or sets the space between the bars of each X axis value.
BarTopPercent Gets or sets the percentage of the top of the bar that is shown for Cone or Custom BarTypes. BarType Gets or sets the type of bars that are displayed. Values are Bar, Cylinder, Cone, Pyramid, and Custom. Gap Gets or sets the space between the bars of each X axis value. VertexNumber Gets or sets the number of vertices for the data point, used to create custom 3D bar shapes. Can only be used with the Custom BarType. Bars must contain 3 or more vertices.
BodyDownswingBackdrop Gets or sets the style and color settings for the downswing boxes. BodyUpswingBackdrop Gets or sets the style and color settings for the upswing boxes. NewLineBreak Gets or sets the number of previous boxes/lines that must be compared before a new box/line is drawn. The default value is 3.
BodyDownswingBackdrop Gets or sets the style and color settings for the downswing boxes. BodyUpswingBackdrop Gets or sets the style and color settings for the upswing boxes. NewLineBreak Gets or sets the number of previous boxes/lines that must be compared before a new box/line is drawn. The default value is 3.
Chart Wizard
The chart control features an easy-to-use wizard. The chart wizard automatically runs when you first add a chart control to a report. If you prefer not to have the wizard run automatically, clear the Auto Run Wizard checkbox at the bottom of the wizard.
You can also access the wizard through the Wizard verb that appears below the Properties window when the chart is selected on the report.
If the verb does not appear in the Properties window, see Access the Chart Wizard and Data Source.
Chart Types
These topics introduce you to the different Chart Types you can create with the Chart control.
Common Charts Area, Bar2D, Bezier, Doughnut/Pie, Line, Scatter, StackedArea, StackedBar, StackedArea100Pct, and StackedBar100Pct 3D Charts Area3D, Bar3D, ClusteredBar, Line3D, Doughnut3D/Pie, StackedBar3D, and StackedBar3D100Pct XY Charts Bubble, BubbleXY, LineXY, and PlotXY Financial Charts Candle, HiLo, and HiLoOpenClose
Common Charts
The ActiveReports Chart control can draw a number of 2D chart types:
Area, Bar 2D, Bezier Doughnut and Pie, Gantt Horizontal Bar, Line Scatter, Stacked Area, Stacked Area 100 Percent Stacked Bar, Stacked Bar 100 Percent
Area Chart
Use an area chart to compare trends over a period of time or across categories.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties None
Bar 2D Chart
Use a bar chart to compare values of items across categories.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Gap gets or sets the space between the bars of each Custom Properties X axis value Below is an example of how to set the custom chart properties at run time for a bar chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("Gap") = 50.0F To write the code in C#
Bezier Chart
Use a Bezier or spline chart to compare trends over a period of time or across categories. It is a line chart that plots curves through the data points in a series.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties None
Doughnut Chart
A doughnut chart shows how the percentage of each data item contributes to the total.
Chart Information Chart Information Number of Y values per data point Number of Series Marker Support 1 1 Series or Data Point ExplodeFactor gets or sets the amount of separation between data point values. HoleSize gets or sets the inner radius of the chart. OutsideLabels gets or sets a value indicating whether the data point labels appear outside the chart. StartAngle gets or sets the horizontal start angle for the series.
Custom Properties
In order to show each section of the pie in a different color, the Background property for each data point must be set. Below is an example of how to set custom chart properties at run time for a doughnut chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("ExplodeFactor") = 0.0F Me.ChartControl1.Series(0).Properties("HoleSize") = 0.25F Me.ChartControl1.Series(0).Properties("OutsideLabels") = False Me.ChartControl1.Series(0).Properties("StartAngle") = 0.0F To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["ExplodeFactor"] = 0f;
Gantt Chart
The Gantt chart is a project management tool used to chart the progress of individual project tasks. The chart compares project task completion to the task schedule. In a Gantt chart the X and Y axes are reversed. AxisX is vertical and AxisY is horizontal.
Chart Information Chart Information Number of Y values per data point 2 Number of Series 1 or more Marker Support Series or Data Point Custom Properties Gap gets or sets the space between the bars of each X axis value. Below is an example of how to set the custom chart properties at run time for a Gantt chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("Gap") = 50.0F To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["Gap"] = 50f;
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties Gap gets or sets the space between the bars of each X axis value. Below is an example of how to set the custom chart properties at run time for a horizontal bar chart as shown above. To write the code in Visual Basic.NET
Line Chart
Use a line chart to compare trends over a period of time or across categories.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties None
Scatter Chart
Use a scatter chart to compare values across categories.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties None
Chart Information
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties Gap gets or sets the space between the bars of each X axis value Below is an example of how to set the custom chart properties at run time for a StackedBar chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("Gap") = 100.0F To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["Gap"] = 100f;
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties None
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties Gap gets or sets the space between the bars of each X axis value Below is an example of how to set the custom chart properties at run time for a StackedBar100Pct chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("Gap") = 100.0F To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["Gap"] = 100f;
3D Charts
The ActiveReports Chart control can draw a number of 3D chart types:
Area 3D, Bar 3D, Clustered Bar Doughnut 3D, Funnel 3D, Pyramid 3D Horizontal Bar 3D, Line 3D Stacked Bar 3D, Stacked Bar 3D 100 Percent
See below for details on each of the 3D chart types. Note: To see a chart in three dimensions, set the ProjectionType to Orthogonal. The ProjectionType is found in the ChartArea Collection dialog in the Projection section.
Area 3D Chart
Use a 3D area chart to compare trends in two or more data series over a period of time or in specific categories, so that data can be viewed side by side.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point LineBackdrop gets or sets the backdrop information for the 3D line. Custom Properties Thickness gets or sets the thickness of the 3D line. Width gets or sets the width of the 3D line. Below is an example of how to set the custom chart properties at run time for a 3D area chart as shown for the first series in the image above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the report class. Imports DataDynamics.ActiveReports.Chart.Graphics Visual Basic.NET code. Paste INSIDE the section Format event.
Me.ChartControl1.Series(0).Properties("LineBackdrop") = New Chart.Graphics.Backdrop(Color.Red, CType(150 Me.ChartControl1.Series(0).Properties("Thickness") = 5.0F Me.ChartControl1.Series(0).Properties("Width") = 30.0F To write the code in C# C# code. Paste ABOVE the report class. using DataDynamics.ActiveReports.Chart.Graphics C# code. Paste INSIDE the section Format event.
Bar 3D Chart
Use a 3D bar chart to compare values of items across categories, allowing the data to be viewed conveniently in a 3D format.
Chart Information Chart Information Number of Y values 1 per data point Number of Series 1 or more Marker Support Series or Data Point BarTopPercent gets or sets the percentage of the top of the bar that is shown for Cone or Custom BarTypes. BarType gets or sets the type of bars that is displayed. Gap gets or sets the space between the bars of each X axis value. Custom Properties RotationAngle gets or sets the starting horizontal angle for custom 3D bar shapes. Can only be used with the Custom BarType. VertexNumber gets or sets the number of vertices for the data point, used to create custom 3D bar shapes. Can only be used with the Custom BarType. Bars must contain 3 or more vertices. Below is an example of how to set the custom chart properties at run time for a 3D bar chart as shown above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("BarTopPercent") = 80.0F Me.ChartControl1.Series(0).Properties("BarType") = BarType.Custom Me.ChartControl1.Series(0).Properties("Gap") = 65.0F Me.ChartControl1.Series(0).Properties("RotationAngle") = 0.0F Me.ChartControl1.Series(0).Properties("VertexNumber") = 6 To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["BarTopPercent"] = 80f; this.chartControl1.Series[0].Properties["BarType"] = BarType.Custom; this.chartControl1.Series[0].Properties["Gap"] = 65f; this.chartControl1.Series[0].Properties["RotationAngle"] = 0f; this.chartControl1.Series[0].Properties["VertexNumber"] = 6;
Chart Information Chart Information Number of Y values 1 per data point Number of Series 1 or more
Doughnut 3D Chart
A 3D doughnut chart shows how the percentage of each data item contributes to a total percentage, allowing the data to be viewed in a 3D format.
Chart Information
Funnel 3D Chart
A 3D funnel chart shows how the percentage of each data item contributes to the whole, allowing the data to be viewed in a three dimensional format.
Chart Information Chart Information Number of Y values per data 1 points Number of Series 1 Marker Support Series or Data Point BaseStyle Gets or sets a circular or square base drawing style for the 3D funnel chart. CalloutLine Gets or sets the style for a line connecting the marker label to its corresponding funnel section. The default value is a black one-point line. FunnelStyle Gets or sets the Y value for the series points to the width or height of the funnel. The default value is YIsHeight. MinPointHeight Gets or sets the minimum height allowed for a data point in the funnel chart. The height is measured in relative coordinates. NeckHeight Gets or sets the neck height for the funnel chart. This property can only be
Custom Properties
Below is an example of how to set the custom chart properties at run time for a 3D funnel chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the report class. Imports DataDynamics.ActiveReports.Chart Imports DataDynamics.ActiveReports.Chart.Graphics Visual Basic.NET code. Paste INSIDE the section Format event. With Me.ChartControl1.Series(0) .Properties("BaseStyle") = BaseStyle.SquareBase .Properties("CalloutLine") = New Line(Color.Black, 2, LineStyle.Dot) .Properties("FunnelStyle") = FunnelStyle.YIsWidth .Properties("MinPointHeight") = 10.0F .Properties("NeckWidth") = 20.0F .Properties("NeckHeight") = 5.0F .Properties("OutsideLabels") = True .Properties("OutsideLabelsPlacement") = LabelsPlacement.Right .Properties("PointGapPct") = 3.0F .Properties("RotationAngle") = 3.0F End With To write the code in Visual Basic.NET C# code. Paste ABOVE the report class. using DataDynamics.ActiveReports.Chart; using DataDynamics.ActiveReports.Chart.Graphics; C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["BaseStyle"] = BaseStyle.SquareBase; this.chartControl1.Series[0].Properties["CalloutLine"] = new Line(Color.Black, 2, LineStyle.Dot); this.chartControl1.Series[0].Properties["FunnelStyle"] = FunnelStyle.YIsWidth; this.chartControl1.Series[0].Properties["MinPointHeight"] = 10f; this.chartControl1.Series[0].Properties["NeckWidth"] = 20f; this.chartControl1.Series[0].Properties["NeckHeight"] = 5f; this.chartControl1.Series[0].Properties["OutsideLabels"] = true; this.chartControl1.Series[0].Properties["OutsideLabelsPlacement"] = LabelsPlacement.Right; this.chartControl1.Series[0].Properties["PointGapPct"] = 3f; this.chartControl1.Series[0].Properties["RotationAngle"] = 3f;
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Gap gets or sets the space between the bars of each X axis value. Custom Properties PointBarDepth Gets or sets the thickness of the 3D bar. Below is an example of how to set the custom chart properties at run time for a 3D bar chart as shown above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("Gap") = 65.0F Me.ChartControl1.Series(0).Properties("PointBarDepth") = 100 To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["Gap"] = 65f; this.chartControl1.Series[0].Properties["PointBarDepth"] = 100;
Line 3D Chart
Use a 3D line chart to compare trends over a period of time or in certain categories in a 3D format.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point LineBackdrop gets or sets the backdrop information for the 3D line. Custom Properties Thickness gets or sets the thickness of the 3D line. Width gets or sets the width of the 3D line. Below is an example of how to set the custom chart properties at run time for a 3D line chart as shown for the first series in the image above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("LineBackdrop") = New Backdrop(Color.GreenYellow) Me.ChartControl1.Series(0).Properties("Thickness") = 8.0F Me.ChartControl1.Series(0).Properties("Width") = 40.0F To write the code in C#
Pyramid 3D Chart
A 3D Pyramid chart shows how the percentage of each data item contributes to the whole, allowing the data to be viewed in a three dimensional format.
Chart Information Chart Information Number of Y values per data 1 point Number of 1 Series Marker Support Series or Data Points BaseStyle Gets or sets a circular or square base drawing style for the 3D pyramid chart. CalloutLine Gets or sets the style for a line connecting the marker label to its corresponding pyramid section. The default value is a black one-point line. MinPointHeight Gets or sets the minimum height allowed for a data point in the pyramid chart. The height is measured in relative coordinates. OutsideLabels Gets or sets a value indicating whether the labels are placed outside of the pyramid chart. The default value is True. Custom OutsideLabelsPlacement Gets or sets a value indicating whether the data point labels Properties appear on the left or right side of the pyramid. This property can only be used with the OutsideLabels property set to True. PointGapPct Gets or sets the amount of space between the data points of the pyramid chart. The PointGapPct is measured in relative coordinates. The default value is 0, and valid values range from 0 to 100. RotationAngle Gets or sets the left-to-right rotation angle of the pyramid. The valid values range from -180 to 180 degrees. This property is only effective with the Projection property set to Orthogonal and the BaseStyle property set to SquareBase. Below is an example of how to set the custom chart properties at run time for a Pyramid chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the report class. Imports DataDynamics.ActiveReports.Chart Imports DataDynamics.ActiveReports.Chart.Graphics Visual Basic.NET code. Paste INSIDE the section Format event. With Me.ChartControl1.Series(0) .Properties("BaseStyle") = BaseStyle.SquareBase .Properties("MinPointHeight") = 10.0F .Properties("OutsideLabels") = True .Properties("OutsideLabelsPlacement") = LabelsPlacement.Right .Properties("PointGapPct") = 3.0F .Properties("RotationAngle") = 3.0F End With To write the code in C# C# code. Paste ABOVE the report class.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties Gap gets or sets the space between the bars of each X axis value Below is an example of how to set the custom chart properties at run time for a StackedBar3D chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("Gap") = 100.0F To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["Gap"] = 100f;
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more
Below is an example of how to set the custom chart properties at run time for a StackedBar3D100Pct chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("Gap") = 100.0F To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["Gap"] = 100f;
XY Charts
The ActiveReports Chart control can draw a number of XY chart types:
Bubble Chart
The Bubble chart is an XY chart in which bubbles represent data points. The first Y value is used to plot the bubble along the Y axis, and the second Y value is used to set the size of the bubble. The bubble shape can be changed using the series Shape property.
Chart Information Chart Information Number of Y values per 2 data point Number of Series 1 or more Marker Support Series or Data Point. Marker labels use the second Y value as the default value. MaxSizeFactor gets or sets the maximum size of the bubble radius. Values must be less than or equal to 1. Default is .25. MaxValue gets or sets the bubble size that is used as the maximum. Custom Properties MinValue gets or sets the bubble size that is used as the minimum. Shape gets or sets the shape of the bubbles. Uses or returns a valid MarkerStyle enumeration value. Below is an example of setting the custom chart properties at run time for a bubble chart as shown in the image above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("MaxSizeFactor") = 0.25F Me.ChartControl1.Series(0).Properties("MaxValue") = 55.0R Me.ChartControl1.Series(0).Properties("MinValue") = 5.0R Me.ChartControl1.Series(0).Properties("Shape") = MarkerStyle.Circle To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["MaxSizeFactor"] = .25f; this.chartControl1.Series[0].Properties["MaxValue"] = 55D; this.chartControl1.Series[0].Properties["MinValue"] = 5D; this.chartControl1.Series[0].Properties["Shape"] = MarkerStyle.Circle;
Bubble XY Chart
The Bubble XY chart is an XY chart in which bubbles represent data points. The BubbleXY uses a numerical X axis and plots the x values and first set of Y values on the chart. The second Y value is used to set the size of the bubble.
Chart Information Chart Information Number of Y values per 2 data point Number of Series 1 or more Marker Support Series or Data Point. Marker labels use the second Y value as the default value. MaxSizeFactor gets or sets the maximum size of the bubble radius. Values must be less than or equal to 1. Default is .25. MaxValue gets or sets the bubble size that is used as the maximum. Custom Properties MinValue gets or sets the bubble size that is used as the minimum. Shape gets or sets the shape of the bubbles. Uses or returns a valid MarkerStyle enumeration value. Below is an example of setting the custom chart properties at run time for a bubble XY chart as shown in the image above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("MaxSizeFactor") = 0.25F Me.ChartControl1.Series(0).Properties("MaxValue") = 50.0R Me.ChartControl1.Series(0).Properties("MinValue") = 0.0R Me.ChartControl1.Series(0).Properties("Shape") = MarkerStyle.InvTriangle To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["MaxSizeFactor"] = .25f; this.chartControl1.Series[0].Properties["MinValue"] = 0D; this.chartControl1.Series[0].Properties["MaxValue"] = 50D; this.chartControl1.Series[0].Properties["Shape"] = MarkerStyle.InvTriangle;
Line XY Chart
A line XY chart plots points on the X and Y axes as one series and uses a line to connect points to each other.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties None
Plot XY Chart
A plot XY chart shows the relationships between numeric values in two or more series sets of XY values.
Chart Information Chart Information Number of Y values per data point 1 Number of Series 1 or more Marker Support Series or Data Point Custom Properties None
Financial Charts
The ActiveReports Chart control can draw a number of financial chart types:
Candle, High Low, High Low Open Close Kagi, Renko Point and Figure, Three Line Break
Candle Chart
A candle chart displays stock information using High, Low, Open and Close values. The size of the wick line is determined by the High and Low values, while the size of the bar is determined by the Open and Close values. The bar is displayed using different colors, depending on whether the price of the stock has gone up or down.
Chart Information Number of Y values per data point Number of Series Marker Support Chart Information 4 (The first value is the high figure, the second is the low figure, the third is the opening figure, and the fourth is the closing figure.) 1 or more Series or Data Point. Marker labels use the first Y value as the default value. BodyDownswingBackdrop gets or sets the backdrop information used to fill the rectangle for data points in which the closing figure is lower than the opening figure. BodyUpswingBackdrop gets or sets the backdrop information used to fill the Custom Properties rectangle for data points in which the closing figure is higher than the opening figure. BodyWidth gets or sets the width of the rectangle used to show upswing or downswing. WickLine gets or sets the line information for the wick line.
Below is an example of how to set the custom chart properties at run time for a candle chart as shown in the image above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the report class. Imports DataDynamics.ActiveReports.Chart.Graphics Visual Basic.NET code. Paste INSIDE the section Format event. With Me.ChartControl1.Series(0) .Properties("BodyDownswingBackdrop") = New Chart.Graphics.Backdrop(Color.FromArgb(255, 192, 255)) .Properties("BodyUpswingBackdrop") = New Chart.Graphics.Backdrop(Color.FromArgb(192, 192, 255)) .Properties("WickLine") = New Chart.Graphics.Line(Color.Indigo) .Properties("BodyWidth") = 7.0F End With To write the code in C# C# code. Paste ABOVE the report class. Using DataDynamics.ActiveReports.Chart.Graphics
HiLo Chart
A HiLo chart displays stock information using High and Low or Open and Close values. The length of the HiLo line is determined by the High and Low values or the Open and Close values.
Chart Information Chart Information Number of Y values per data point Number of Series Marker Support Custom Properties 2 1 or more Series or Data Point. Marker labels use the first Y value as the default value. HiloLine gets or sets the line information for the HiLo line.
Below is an example of how to set the custom chart properties at run time for a HiLo chart as shown in the image above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).Properties("HiloLine") = New DataDynamics.ActiveReports.Chart.Graphics.Line (Color.DeepSkyBlue, 4) To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["HiloLine"] = new DataDynamics.ActiveReports.Chart.Graphics.Line (Color.DeepSkyBlue, 4);
Chart Information
Custom Properties
Below is an example of how to set the custom chart properties at run time for a HiLoOpenClose chart as shown in the image above. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the report class. Imports DataDynamics.ActiveReports.Chart.Graphics Visual Basic.NET code. Paste INSIDE the section Format event. With Me.ChartControl1.Series(0) .Properties("OpenLine") = New Chart.Graphics.Line(Color.Green) .Properties("CloseLine") = New Chart.Graphics.Line(Color.Red) .Properties("HiloLine") = New Chart.Graphics.Line(Color.Black, 2) .Properties("TickLen") = 10.0F End With To write the code in C# C# code. Paste ABOVE the report class. using DataDynamics.ActiveReports.Chart.Graphics; C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["OpenLine"] = new Chart.Graphics.Line(Color.Green); this.chartControl1.Series[0].Properties["CloseLine"] = new Chart.Graphics.Line(Color.Red); this.chartControl1.Series[0].Properties["HiloLine"] = new Chart.Graphics.Line(Color.Black, 2); this.chartControl1.Series[0].Properties["TickLen"] = 10f;
Kagi Chart
A Kagi chart displays supply and demand trends using a sequence of linked vertical lines. The thickness and direction of the lines vary depending on the price movement. If closing prices go in the direction of the previous Kagi line, then that Kagi line is extended. However, if the closing price reverses by the preset reversal amount, a new Kagi line is charted in the next column in the opposite direction. Thin lines indicate that the price breaks the previous low (supply) while thick lines indicate that the price breaks the previous high (demand).
Chart Information Chart Information Number of Y values per data 1 point Number of 1 Series Marker Support Series or Data Points
Custom Properties
Below is an example of how to set the custom chart properties at run time for a Kagi chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the report class. Imports DataDynamics.ActiveReports.Chart.Graphics Visual Basic.NET code. Paste INSIDE the section Format event. With Me.ChartControl1.Series(0) .Properties("BodyDownswingBackdrop") = New Backdrop(Color.Red) .Properties("BodyUpswingBackdrop") = New Backdrop(Color.Blue) .Properties("DownswingLine") = New Chart.Graphics.Line(Color.DarkRed) .Properties("ReversalAmount") = "25" .Properties("UpswingLine") = New Chart.Graphics.Line(Color.DarkBlue) .Properties("Width") = 50.0F End With To write the code in C# C# code. Paste ABOVE the report class. using DataDynamics.ActiveReports.Chart.Graphics; C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["BodyDownswingBackdrop"] = new Backdrop(Color.Red); this.chartControl1.Series[0].Properties["BodyUpswingBackdrop"] = new Backdrop(Color.Blue); this.chartControl1.Series[0].Properties["DownswingLine"] = new Chart.Graphics.Line(Color.DarkRed); this.chartControl1.Series[0].Properties["ReversalAmount"] = "25"; this.chartControl1.Series[0].Properties["UpswingLine"] = new Chart.Graphics.Line(Color.DarkBlue); this.chartControl1.Series[0].Properties["Width"] = 50f;
Custom Properties
Below is an example of how to set the custom chart properties at run time for a Point and Figure chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the report class. Imports DataDynamics.ActiveReports.Chart.Graphics Visual Basic.NET code. Paste INSIDE the section Format event. With Me.ChartControl1.Series(0) .Properties("DownswingLine") = New Chart.Graphics.Line(Color.Red) .Properties("UpswingLine") = New Chart.Graphics.Line(Color.Blue) .Properties("BoxSize") = 3.0F End With To write the code in C# C# code. Paste ABOVE the report class. using DataDynamics.ActiveReports.Chart.Graphics; C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].Properties["DownswingLine"] = new Chart.Graphics.Line(Color.Red); this.chartControl1.Series[0].Properties["UpswingLine"] = new Chart.Graphics.Line(Color.Blue); this.chartControl1.Series[0].Properties["BoxSize"] = 3f;
Renko Chart
The Renko chart uses bricks of uniform size to chart price movement. When a price moves to a greater or lesser value than the preset BoxSize value required to draw a new brick, a new brick is drawn in the succeeding column. The change in box color and direction signifies a trend reversal.
Chart Information Chart Information Number of Y values per data point Number of Series Marker Support Custom Properties 2 1 Series or Data Points BodyDownswingBackdrop Gets or sets the style and color settings for the downswing bricks. BodyUpswingBackdrop Gets or sets the style and color settings for the
Chart Information Chart Information Number of Y values 1 per data point Number of Series 1 Marker Support Series or Data Points BodyDownswingBackdrop Gets or sets the style and color settings for the downswing boxes. Chart-Specific BodyUpswingBackdrop Gets or sets the style and color settings for the upswing Properties boxes. NewLineBreak Gets or sets the number of previous boxes/lines that must be compared before a new box/line is drawn. The default value is 3. Below is an example of how to set the custom chart properties at run time for a Three Line Break chart. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the report class.
Chart Appearance
These topics introduce you to some basic information about manipulating the appearance of Charts. Chart Effects Learn about the visual effects possible with the Chart control. Chart Control Items Learn about Chart control items that can be used to customize your chart. Chart Axes and Walls Learn some basic information about Chart axes and walls.
Chart Effects
Colors
In the Chart control, colors can be used in different ways to enhance the chart's appearance, distinguish different series, point out or draw attention to data information such as averages, and more.
Color Palettes
The Chart control includes several pre-defined color palettes that can be used to automatically set the colors for data values in a series. The pre-defined palettes are as follows:
Cascade (default) A cascade of eight cool colors ranging from deep teal down through pale orchid. Confetti A sprinkling of bright and pastel colors. Iceberg A range of the soft blues and greys found in an iceberg. Springtime The colors of spring, in deep green, two vivid colors and five pastels. None All data is drawn using the same teal color.
These enumerated values are accessed through the Series class with code like the following. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to set the color palette for the series. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Me.ChartControl1.Series(0).ColorPalette = DataDynamics.ActiveReports.Chart.ColorPalette.Iceburg To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.Series[0].ColorPalette = DataDynamics.ActiveReports.Chart.ColorPalette.Iceburg;
Gradients
Gradients can be used in object backdrops to enhance the visual appearance of various chart items. Gradients can be used in the following chart sections:
Chart backdrop Chart area backdrops Wall backdrops Title backdrops Legend backdrops Legend item backdrops (for custom legend items) WallRange backdrops Series backdrops Data point backdrops Marker backdrops Marker label backdrops Annotation TextBar backdrops
You can set gradients for a backdrop at run time by creating a BackdropItem, setting its Style property to Gradient, setting the GradientType, and setting the two colors to use for the gradient as shown in the following example. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to set gradients for the backdrop.
3D Effects
Using the projection and viewpoint settings, you can display your 3D chart at any angle to provide the desired view or call attention to a specific chart section.
Projection
Determine the projection for a 3D chart using three factors: the Z depth ratio, the projection type, and the projection DX and DY values.
ZDepth ratio The Z depth ratio is the level of depth the Z axis has in the chart. Values range from 0 (for a 2D chart) to 1.0. ProjectionType The type of projection used for the chart. In order to show charts three dimensionally, the ProjectionType in the ChartArea Collection editor must be set to Orthogonal. To access this dialog box, click the ellipsis button next to the ChartAreas (Collection) property in the Properties Window.
ProjectionDX The origin position of the Z axis in relation to the X axis. This property is valid only when the ProjectionType is Orthogonal. ProjectionDY The origin position of the Z axis in relation to the Y axis. This property is valid only when the ProjectionType is Orthogonal. HorizontalRotation The HorizontalRotation property allows you to set the degree (-90 to 90) of horizontal rotation from which the chart is seen. VerticalRotation The VerticalRotation property allows you to set the degree (-90 to 90) of vertical rotation from which the chart is seen.
Alpha Blending
The Backdrop class in the Chart control has an Alpha property which employs GDI+, and is used to set the transparency level of each object's backdrop. GDI+ uses 32 bits overall and 8 bits per alpha, red, green, and blue channels respectively to indicate the transparency and color of an object. Like a color channel's levels of color, the alpha channel represents 256 levels of transparency. The default value of the Alpha property is 255, which represents a fully opaque color. For a fully transparent color, set this value to 0. To blend the color of the object's backdrop with the background color, use a setting between 0 and 255.
Lighting
The Chart control allows you to completely customize lighting options for 3D charts.
Light Type
By setting the Type property to one of the enumerated LightType values, you can control the type of lighting used in the chart. The settings are as follows:
Ambient An ambient light source is used. It is equal to DirectionalLightRatio = 0. InfiniteDirectional An infinite directional light source (like the sun) is used. FiniteDirectional A point light source is used.
Light Source
You can also set the Source property to a Point3d object, which controls the location of the light source.
The following properties are important when setting up annotations for your chart:
StartPoint Sets the starting point (X and Y axis values) for an annotation line. EndPoint Sets the end point (X and Y axis values) for an annotation line. AnchorPlacement Sets the position of the anchor point for the text bar on the chart surface. AnchorPoint Sets the point (X and Y axis values) where the text bar will be anchored based on the anchor placement selected.
The following code demonstrates creating annotation lines and text bars, setting their properties, and adding them to the series annotations collection at run time. The results are shown in the screen shot above. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create annotation lines and text bars. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. ' create the annotation lines and text bars Dim aLine1 As New DataDynamics.ActiveReports.Chart.Annotations.AnnotationLine Dim aLine2 As New DataDynamics.ActiveReports.Chart.Annotations.AnnotationLine Dim aText1 As New DataDynamics.ActiveReports.Chart.Annotations.AnnotationTextBar Dim aText2 As New DataDynamics.ActiveReports.Chart.Annotations.AnnotationTextBar ' set the properties for each line and text bar With aLine1 .EndPoint = New DataDynamics.ActiveReports.Chart.Graphics.Point2d(1.5F, 30.0F) .Line = New DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red, 2) .StartPoint = New DataDynamics.ActiveReports.Chart.Graphics.Point2d(1.5F, 15.0F) End With With aLine2 .EndPoint = New DataDynamics.ActiveReports.Chart.Graphics.Point2d(4.6F, 47.0F) .Line = New DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red, 2) .StartPoint = New DataDynamics.ActiveReports.Chart.Graphics.Point2d(3.6F, 45.0F) End With With aText1 .AnchorPlacement = DataDynamics.ActiveReports.Chart.Annotations.AnchorPlacementType.Bottom .AnchorPoint = New DataDynamics.ActiveReports.Chart.Graphics.Point2d(1.5F, 31.0F) .Height = 25.0F .Line = New DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red, 2) .Text = "Min Value" .Width = 100.0F End With With aText2 .AnchorPlacement = DataDynamics.ActiveReports.Chart.Annotations.AnchorPlacementType.Left .AnchorPoint = New DataDynamics.ActiveReports.Chart.Graphics.Point2d(4.7F, 47.0F)
' add the annotation lines and text bars to the annotations collection for the series Me.ChartControl1.Series(0).Annotations.AddRange(New DataDynamics.ActiveReports.Chart.Annotations.Annotat To write the code in C# C# code. Paste INSIDE the section Format event.
// create the annotation lines and text bars DataDynamics.ActiveReports.Chart.Annotations.AnnotationLine aLine1 = new DataDynamics.SharpGraph.Windows DataDynamics.ActiveReports.Chart.Annotations.AnnotationLine aLine2 = new DataDynamics.SharpGraph.Windows DataDynamics.ActiveReports.Chart.Annotations.AnnotationTextBar aText1 = new DataDynamics.SharpGraph.Wind DataDynamics.ActiveReports.Chart.Annotations.AnnotationTextBar aText2 = new DataDynamics.SharpGraph.Wind // set the properties for each line and text bar aLine1.EndPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(1.5F, 30F); aLine1.Line = new DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red, 2); aLine1.StartPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(1.5F, 15F); aLine2.EndPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(4.6F, 47F); aLine2.Line = new DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red, 2); aLine2.StartPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(3.6F, 45F); aText1.AnchorPlacement = DataDynamics.ActiveReports.Chart.Annotations.AnchorPlacementType.Bottom; aText1.AnchorPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(1.5F, 31F); aText1.Height = 25F; aText1.Line = new DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red, 2); aText1.Text = "Min Value"; aText1.Width = 100F; aText2.AnchorPlacement = DataDynamics.ActiveReports.Chart.Annotations.AnchorPlacementType.Left; aText2.AnchorPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(4.7F, 47F); aText2.Height = 25F; aText2.Line = new DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red, 2); aText2.Text = "Max Value"; aText2.Width = 100F;
// add the annotation lines and text bars to the annotations collection for the series this.chartControl1.Series[0].Annotations.AddRange(new DataDynamics.ActiveReports.Chart.Annotations.Annot
The following code demonstrates creating header and footer titles, setting their properties, and adding them to the titles collection at run time. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create header and footer titles. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. ' create the header and footer titles Dim tHeader As New DataDynamics.ActiveReports.Chart.Title
' set the properties for the header tHeader.Alignment = Chart.Alignment.Center tHeader.Backdrop = New DataDynamics.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Thistle) tHeader.Border = New DataDynamics.ActiveReports.Chart.Border(New DataDynamics.ActiveReports.Chart.Graphi tHeader.DockArea = Me.ChartControl1.ChartAreas(0) tHeader.Docking = Chart.DockType.Top tHeader.Font = New DataDynamics.ActiveReports.Chart.FontInfo(System.Drawing.Color.White, New System.Draw tHeader.Text = "Chart Title" tHeader.Visible = True
' set the properties for the footer tFooter.Alignment = Chart.Alignment.Center tFooter.Backdrop = New DataDynamics.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Thistle) tFooter.Border = New DataDynamics.ActiveReports.Chart.Border(New DataDynamics.ActiveReports.Chart.Graphi tFooter.DockArea = Me.ChartControl1.ChartAreas(0) tFooter.Docking = Chart.DockType.Bottom tFooter.Font = New DataDynamics.ActiveReports.Chart.FontInfo(System.Drawing.Color.DimGray, New System.Dr tFooter.Text = "Chart Footer" tFooter.Visible = True ' add the header and footer titles to the titles collection Me.ChartControl1.Titles.AddRange(New DataDynamics.ActiveReports.Chart.Title() {tHeader, tFooter}) To write the code in C# C# code. Paste INSIDE the section Format event. // create the header and footer titles DataDynamics.ActiveReports.Chart.Title tHeader = new DataDynamics.ActiveReports.Chart.Title(); DataDynamics.ActiveReports.Chart.Title tFooter = new DataDynamics.ActiveReports.Chart.Title();
// set the properties for the header tHeader.Alignment = Chart.Alignment.Center; tHeader.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Thistle); tHeader.Border = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphi tHeader.DockArea = this.ChartControl1.ChartAreas[0]; tHeader.Docking = Chart.DockType.Top; tHeader.Font = new DataDynamics.ActiveReports.Chart.FontInfo(System.Drawing.Color.White, new System.Draw tHeader.Text = "Chart Title"; tHeader.Visible = true;
// set the properties for the footer tFooter.Alignment = Chart.Alignment.Center; tFooter.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Thistle); tFooter.Border = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphi tFooter.DockArea = this.ChartControl1.ChartAreas[0]; tFooter.Docking = Chart.DockType.Bottom; tFooter.Font = new DataDynamics.ActiveReports.Chart.FontInfo(System.Drawing.Color.DimGray, new System.Dr tFooter.Text = "Chart Footer"; tFooter.Visible = true; // add the header and footer titles to the titles collection this.chartControl1.Titles.AddRange(new DataDynamics.ActiveReports.Chart.Title[] {tHeader,tFooter});
Legends
The Chart control automatically creates a legend item for each series added to a chart at design time and sets the Legend property for each series by default. However, the legend's Visible property must be set to True for the legend to show with the chart. The text for each default legend entry is taken from the Name property on the series.
The following code demonstrates how to create a legend at run time, add it to the legends collection for the Chart object and set the legend property of the series to the new legend, resulting in the legend shown above. Note: Each Series to be shown in the Legend must have a Name. If the Name property is not set, the Series does not show up in the Legend. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create a legend. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event.
' create the legend and title for the legend Dim legend1 As New DataDynamics.ActiveReports.Chart.Legend Dim lHeader As New DataDynamics.ActiveReports.Chart.Title ' set the properties for the legend title lHeader.Backdrop = New DataDynamics.ActiveReports.Chart.Graphics.Backdrop(Chart.Graphics.BackdropStyle.T lHeader.Border = New DataDynamics.ActiveReports.Chart.Border(New Chart.Graphics.Line(Color.White, 2, Cha lHeader.Font = New DataDynamics.ActiveReports.Chart.FontInfo(Color.White, New System.Drawing.Font("Arial lHeader.Text = "Series:" ' set the properties for the legend and add it to the legends collection legend1.Alignment = DataDynamics.ActiveReports.Chart.Alignment.TopRight legend1.Backdrop = New DataDynamics.ActiveReports.Chart.BackdropItem(Chart.Graphics.BackdropStyle.Transp legend1.Border = New DataDynamics.ActiveReports.Chart.Border(New Chart.Graphics.Line(Color.Navy, 2), 0, legend1.DockArea = Me.ChartControl1.ChartAreas(0) legend1.LabelsFont = New DataDynamics.ActiveReports.Chart.FontInfo(Color.White, New System .Drawing.Font legend1.Header = lHeader legend1.MarginX = 5 legend1.MarginY = 5 Me.ChartControl1.Legends.Add(legend1) ' set the legend property of the series to the legend you created Me.ChartControl1.Series(0).Legend = legend1 Me.ChartControl1.Series(1).Legend = legend1 Me.ChartControl1.Series(2).Legend = legend1 To write the code in C# C# code. Paste INSIDE the section Format event.
// create the legend and title for the legend DataDynamics.ActiveReports.Chart.Legend legend1 = new DataDynamics.ActiveReports.Chart.Legend(); DataDynamics.ActiveReports.Chart.Title lHeader = new DataDynamics.ActiveReports.Chart.Title(); // set the properties for the legend title lHeader.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(Chart.Graphics.BackdropStyle.T lHeader.Border = new DataDynamics.ActiveReports.Chart.Border(new Chart.Graphics.Line(Color.White, 2, Cha lHeader.Font = new DataDynamics.ActiveReports.Chart.FontInfo(Color.White, new Font("Arial", 10F, FontSty lHeader.Text = "Series:"; // set the properties for the legend and add it to the legends collection legend1.Alignment = DataDynamics.ActiveReports.Chart.Alignment.TopRight; legend1.Backdrop = new DataDynamics.ActiveReports.Chart.BackdropItem(Chart.Graphics.BackdropStyle.Transp legend1.Border = new DataDynamics.ActiveReports.Chart.Border(new Chart.Graphics.Line(Color.Navy, 2), 0, legend1.DockArea = this.sharpGraph1.ChartAreas[0]; legend1.LabelsFont = new DataDynamics.ActiveReports.Chart.FontInfo(Color.White, new Font("Arial", 9F)); legend1.Header = lHeader; legend1.MarginX = 5; legend1.MarginY = 5;
Markers
Use markers to show specific data series values in a chart.
The following code demonstrates how to create a marker object at run time and assign it to the Marker property of the series. The results are shown in the image above. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create a marker object and assign it to the series. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. ' create the marker object Dim marker1 As New DataDynamics.ActiveReports.Chart.Marker
' set the marker properties marker1.Backdrop = New Chart.Graphics.Backdrop(Chart.Graphics.GradientType.Horizontal, Color.Navy, Color marker1.Line = New Chart.Graphics.Line(Color.White) marker1.Label = New Chart.LabelInfo(New Chart.Graphics.Line(Color.Transparent, 0, Chart.Graphics.LineSty marker1.Size = 24 marker1.Style = Chart.MarkerStyle.Diamond ' assign the marker to the series Marker property Me.ChartControl1.Series(0).Marker = marker1 To write the code in C# C# code. Paste INSIDE the section Format event. // create the marker object DataDynamics.ActiveReports.Chart.Marker marker1 = new DataDynamics.ActiveReports.Chart.Marker();
// set the marker properties marker1.Backdrop = new Chart.Graphics.Backdrop(Chart.Graphics.GradientType.Horizontal, Color.Navy, Color marker1.Line = new Chart.Graphics.Line(Color.White); marker1.Label = new Chart.LabelInfo(new Chart.Graphics.Line(Color.Transparent, 0, Chart.Graphics.LineSty marker1.Size = 24; marker1.Style = Chart.MarkerStyle.Diamond; // assign the marker to the series Marker property this.chartControl1.Series[0].Marker = marker1;
Important properties
EndValue Sets the end value on the primary axis for the wall range. StartValue Sets the start value on the primary axis for the wall range. PrimaryAxis Sets the axis on which the wall range appears.
The following code demonstrates how to create wall ranges, set their properties, and assign them to a chart area at run time. The results are shown in the image above. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create wall ranges and assign them to a chart area. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. ' create the wall Dim wallRange1 As Dim wallRange2 As Dim wallRange3 As range objects New DataDynamics.ActiveReports.Chart.WallRange New DataDynamics.ActiveReports.Chart.WallRange New DataDynamics.ActiveReports.Chart.WallRange
' set the wall range properties With wallRange1 .Backdrop = New DataDynamics.ActiveReports.Chart.Graphics.Backdrop(Color.White) .Border = New DataDynamics.ActiveReports.Chart.Border(New DataDynamics.ActiveReports.Chart.Graphics. .EndValue = 40 .PrimaryAxis = ((CType(Me.ChartControl1.ChartAreas(0).Axes("AxisY"), DataDynamics.ActiveReports.Char .StartValue = 30 End With With wallRange2 .Backdrop = New DataDynamics.ActiveReports.Chart.Graphics.Backdrop(Color.Lime) .Border = New DataDynamics.ActiveReports.Chart.Border(New DataDynamics.ActiveReports.Chart.Graphics. .EndValue = 34 .PrimaryAxis = ((CType(Me.ChartControl1.ChartAreas(0).Axes("AxisY"), DataDynamics.ActiveReports.Char .StartValue = 33 End With With wallRange3 .Backdrop = New DataDynamics.ActiveReports.Chart.Graphics.Backdrop(Color.DarkGreen, CType(150, Byte) .Border = New DataDynamics.ActiveReports.Chart.Border(New DataDynamics.ActiveReports.Chart.Graphics. .EndValue = 40 .PrimaryAxis = ((CType(Me.ChartControl1.ChartAreas(0).Axes("AxisZ"), DataDynamics.ActiveReports.Char .StartValue = 20 End With
' add the wall ranges to the chart area and set wall and Z axis properties to show lines With ChartControl1.ChartAreas(0) .WallRanges.AddRange(New DataDynamics.ActiveReports.Chart.WallRange() {wallRange1, wallRange2, wallR .WallXY.Backdrop.Alpha = 100 .WallXZ.Backdrop.Alpha = 100 .WallYZ.Backdrop.Alpha = 100 .Axes(4).MajorTick.Step = 20 .Axes(4).Max = 60 .Axes(4).Min = 0 .Axes(4).Visible = True End With
// create the wall range objects DataDynamics.ActiveReports.Chart.WallRange wallRange1 = new DataDynamics.ActiveReports.Chart.WallRange() DataDynamics.ActiveReports.Chart.WallRange wallRange2 = new DataDynamics.ActiveReports.Chart.WallRange() DataDynamics.ActiveReports.Chart.WallRange wallRange3 = new DataDynamics.ActiveReports.Chart.WallRange()
// set the wall range properties wallRange1.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.White) wallRange1.Border = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Gra wallRange1.EndValue = 40; wallRange1.PrimaryAxis = (DataDynamics.ActiveReports.Chart.Axis)this.ChartControl1.ChartAreas[0].Axes["A wallRange1.StartValue = 30; wallRange2.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Lime); wallRange2.Border = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Gra wallRange2.EndValue = 34; wallRange2.PrimaryAxis = (DataDynamics.ActiveReports.Chart.Axis)this.ChartControl1.ChartAreas[0].Axes["A wallRange2.StartValue = 33; wallRange3.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.DarkGr wallRange3.Border = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Gra wallRange3.EndValue = 40; wallRange3.PrimaryAxis = (DataDynamics.ActiveReports.Chart.Axis)this.ChartControl1.ChartAreas[0].Axes["A wallRange3.StartValue = 20;
// add the wall ranges to the chart area and set wall and Z axis properties to show lines this.chartControl1.ChartAreas[0].WallRanges.AddRange(new DataDynamics.ActiveReports.Chart.WallRange[] {w this.chartControl1.ChartAreas[0].WallXY.Backdrop.Alpha = 100; this.chartControl1.ChartAreas[0].WallXZ.Backdrop.Alpha = 100; this.chartControl1.ChartAreas[0].WallYZ.Backdrop.Alpha = 100; this.chartControl1.ChartAreas[0].Axes[4].MajorTick.Step = 20; this.chartControl1.ChartAreas[0].Axes[4].Max = 60; this.chartControl1.ChartAreas[0].Axes[4].Min = 0; this.chartControl1.ChartAreas[0].Axes[4].Visible = true;
Axis Types
Most 2D charts contain a numerical axis (AxisY) and a categorical axis (AxisX). 3D charts include another numerical axis (AxisZ). These axes are accessible at run time from the ChartArea object and allow you to control the settings for each, including scaling, labels, and various formatting properties. For any of the scaling or labeling properties you set to show up at run time, you will need to set the Visible property of the axis to True.
Scaling
For normal linear scaling on a numeric axis, set the Max and Min properties for the axis, which correspond to the numerical values in the chart's data series. Also, set the Step property of the MajorTick to show the major numerical unit values. The Step property controls where labels and tick marks are shown on the numerical axis. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to set the Max, Min, and MajorTick properties. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. With Me.ChartControl1.ChartAreas(0).Axes("AxisY") .Max = 100 .Min = 0 .MajorTick.Step = 10 End With To write the code in C# C# code. Paste INSIDE the section Format event. this.chartControl1.ChartAreas[0].Axes["AxisY"].Max = 100; this.chartControl1.ChartAreas[0].Axes["AxisY"].Min = 0; this.chartControl1.ChartAreas[0].Axes["AxisY"].MajorTick.Step = 10; The Chart control also supports logarithmic scaling which allows you to show the vertical spacing between two points that corresponds to the percentage of change between those numbers. You can set your numeric axis to scale logarithmically by setting the IsLogarithmic property on the axis to True and setting the Max and Min properties of the axis.
Labeling
To show labels on an axis, you will need to specify the value for the LabelsGap property, set your LabelsFont
Secondary Axes
By default, a Chart object includes secondary X and Y axes (AxisX2 and AxisY2). At design time or run time, you can specify a secondary axis to plot data against by setting all of the appropriate properties for AxisX2 or AxisY2, including the Visible property. If you want to use two axes to show the same data as it appears on two different scales, you can set the primary axis to show the actual data value scale, for example, and set the secondary axis to show a logarithmic scale. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create a primary axis with actual data, and a secondary axis with a logarithmic scale. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. ' set properties for AxisY (primary axis) With Me.ChartControl1.ChartAreas(0).Axes("AxisY") .Max = 25 .Min = 0 .MajorTick.Step = 5 End With ' set properties for AxisY2 (secondary Y axis) With Me.ChartControl1.ChartAreas(0).Axes("AxisY2") .Max = 1000 .Min = 0 .MajorTick.Step = 200 ' set the scaling for the secondary axis to logarithmic .AxisType = DataDynamics.ActiveReports.Chart.AxisType.Logarithmic.Visible = True End With To write the code in C# C# code. Paste INSIDE the section Format event. // set properties for AxisY (primary axis) this.chartControl1.ChartAreas[0].Axes["AxisY"].Max = 25; this.chartControl1.ChartAreas[0].Axes["AxisY"].Min = 0; this.chartControl1.ChartAreas[0].Axes["AxisY"].MajorTick.Step = 5;
// set properties for AxisY2 (secondary Y axis) this.chartControl1.ChartAreas[0].Axes["AxisY2"].Max = 1000; this.chartControl1.ChartAreas[0].Axes["AxisY2"].Min = 0; this.chartControl1.ChartAreas[0].Axes["AxisY2"].MajorTick.Step = 200; // set the axis type for the secondary axis to logarithmic this.chartControl1.ChartAreas[0].Axes["AxisY2"].AxisType = DataDynamics.ActiveReports.Chart.AxisType.Log this.chartControl1.ChartAreas[0].Axes["AxisY2"].Visible = true;
Custom Axes
The Chart control supports the creation of additional custom axes through the use of the chart's CustomAxes collection. Once a custom axis has been added to the collection, in addition to setting the normal axis properties, you will need to set the following properties:
Parent - The Parent property allows you to choose the primary or secondary axis on which your custom axis resides.
PlacementLength - The PlacementLength property allows you to set the length of the custom axis in proportion to the Min and Max property values you have already set for the parent axis. PlacementLocation - The PlacementLocation property allows you to set the starting location value for the custom axis to appear in relation to the parent axis.
The following code sample demonstrates creating a custom axis, adding it to the Axes collection for the ChartArea, and setting its properties. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create a custom axis, add it to the chart area, and set its properties. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. ' create the custom axis and add it to the ChartArea's Axes collection Dim customAxisY As New DataDynamics.ActiveReports.Chart.CustomAxis Me.ChartControl1.ChartAreas(0).Axes.Add(customAxisY)
' set the basic axis properties for customAxisY customAxisY.LabelFont = New DataDynamics.ActiveReports.Chart.FontInfo(Color.Red, New Font("Arial", 7.0!) customAxisY.LabelsGap = 1 customAxisY.LabelsVisible = True customAxisY.Line = New DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Red) customAxisY.MajorTick = New DataDynamics.ActiveReports.Chart.Tick(New DataDynamics.ActiveReports.Chart.G customAxisY.MajorTick.GridLine = New DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Red, 1, LineSt customAxisY.MajorTick.Visible = True customAxisY.Max = 5 customAxisY.MaxDerived = False customAxisY.Min = 0 customAxisY.Visible = True
' set the special custom axis properties customAxisY.Parent = ((CType(Me.ChartControl1.ChartAreas(0).Axes("AxisY"), DataDynamics.ActiveReports.Ch customAxisY.PlacementLength = 20 customAxisY.PlacementLocation = 30 To write the code in C# C# code. Paste INSIDE the section Format event.
// create the custom axis and add it to the ChartArea's Axes collection DataDynamics.ActiveReports.Chart.CustomAxis customAxisY = new DataDynamics.ActiveReports.Chart.CustomAxi this.chartControl1.ChartAreas[0].Axes.Add(customAxisY);
// set the basic axis properties for customAxisY customAxisY.LabelFont = new DataDynamics.ActiveReports.Chart.FontInfo(Color.Red, new Font("Arial", 7F, F customAxisY.LabelsGap = 1; customAxisY.LabelsVisible = true; customAxisY.Line = new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Red); customAxisY.MajorTick = new DataDynamics.ActiveReports.Chart.Tick(new DataDynamics.ActiveReports.Chart.G customAxisY.MajorTick.GridLine = new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Red, 1, LineSt customAxisY.MajorTick.Visible = true; customAxisY.Max = 5; customAxisY.MaxDerived = false; customAxisY.Min = 0; customAxisY.Visible = true;
// set the special custom axis properties customAxisY.Parent = (DataDynamics.ActiveReports.Chart.Axis)this.ChartControl1.ChartAreas[0].Axes["AxisY customAxisY.PlacementLength = 20; customAxisY.PlacementLocation = 30;
Types
There are two kinds of gridlines and tick marks in the Chart control: major and minor. The properties for the major gridlines and tick marks are set on the MajorTick object of the particular axis and the properties for minor gridlines and ticks are set on the MinorTick object of the axis. The location for any labels shown for the axis are determined by the Step property of the MajorTick object.
Visible
To make any defined major or minor tick marks to show up at design time or run time, the Visible property of the MajorTick or MinorTick object must be set to True. To show major or minor gridlines at design time or run time, the Visible property of the WallXY object as well as that of the MajorTick or MinorTick object must be set to True.
Chart Data
Bound Data
The Chart control has its own data source which is distinct from the report data source. To access the chart's data source, click the Data Source verb which appears below the Properties window when the chart is selected on the report. If the Data Source verb does not appear, see Access the Chart Wizard and Data Source for help.
Unbound Data
The Chart control allows you to set the data source for a chart control, series, or data points collection at run time. Any of the following objects can be used as data sources:
Dataset Dataset Column Data Table SqlCommand/OleDbCommand SqlDataAdapter/OleDbDataAdapter Array XML data
Below are some examples of binding to different data sources at run time.
Dataset
The Chart control's DataSource property can be set to a dataset at run time. The following code demonstrates how to set up a dataset, set the DataSource property to the dataset, create a series, and set the ValueMembersY property to the dataset expression at run time. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create a data source and bind a series to a dataset expression. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event.
' create the series Dim s As New DataDynamics.ActiveReports.Chart.Series Dim m_cnnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Northwind.mdb; Persist Secu Dim m_cnn As New System.Data.OleDb.OleDbConnection(m_cnnString) Dim oDBAdapter As System.Data.OleDb.OleDbDataAdapter
' create the dataset Dim oDS As DataSet oDBAdapter = New System.Data.OleDb.OleDbDataAdapter("SELECT ShipCountry, SUM(Freight) AS Expr1 FROM Orde oDS = New DataSet oDBAdapter.Fill(oDS, "Expr1") ' set the DataSource and ValueMembersY properties Me.ChartControl1.DataSource = oDS s.ValueMembersY = "Expr1" Me.ChartControl1.Series.Add(s) To write the code in C# C# code. Paste INSIDE the section Format event.
// create the series DataDynamics.ActiveReports.Chart.Series s = new DataDynamics.ActiveReports.Chart.Series(); string m_cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Northwind.mdb;Persist Security Inf System.Data.OleDb.OleDbConnection m_cnn = new System.Data.OleDb.OleDbConnection(m_cnnString);
// create the dataset System.Data.DataSet oDS; oDBAdapter = new System.Data.OleDb.OleDbDataAdapter("SELECT ShipCountry, SUM(Freight) AS Expr1 FROM Orde oDS = new System.Data.DataSet(); oDBAdapter.Fill(oDS, "Expr1"); // set the DataSource and ValueMembersY properties this.chartControl1.DataSource = oDS; s.ValueMembersY = "Expr1"; this.chartControl1.Series.Add(s);
Dataset Column
In the Chart control, the ValueMembersX and ValueMembersY properties of a series can be set to a dataset column. The following code demonstrates how to create a series, set up a dataset, set the DataSource property to the dataset, and set the ValueMembersY and ValueMembersX properties to dataset columns at run time. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create a data source and bind a series to dataset columns. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event.
' create the series Dim s As New DataDynamics.ActiveReports.Chart.Series Dim m_cnnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Northwind.mdb; Persist Secu Dim m_cnn As New System.Data.OleDb.OleDbConnection(m_cnnString) Dim oDBAdapter As System.Data.OleDb.OleDbDataAdapter
' create the dataset Dim oDS As DataSet oDBAdapter = New System.Data.OleDb.OleDbDataAdapter("SELECT * from Orders WHERE OrderDate < #08/17/1994# oDS = New DataSet oDBAdapter.Fill(oDS, "Orders") ' set the DataSource, ValueMembersY, and ValueMembersX properties Me.ChartControl1.DataSource = oDS Me.ChartControl1.Series.Add(s) Me.ChartControl1.Series(0).ValueMembersY = oDS.Tables("Orders").Columns(7).ColumnName Me.ChartControl1.Series(0).ValueMemberX = oDS.Tables("Orders").Columns(8).ColumnName To write the code in C# C# code. Paste INSIDE the section Format event.
// create the series DataDynamics.ActiveReports.Chart.Series s = new DataDynamics.ActiveReports.Chart.Series(); string m_cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Northwind.mdb;Persist Security Inf System.Data.OleDb.OleDbConnection m_cnn = new System.Data.OleDb.OleDbConnection(m_cnnString); System.Data.OleDb.OleDbDataAdapter oDBAdapter;
// create the dataset System.Data.DataSet oDS; oDBAdapter = new System.Data.OleDb.OleDbDataAdapter("SELECT * from Orders WHERE OrderDate < #08/17/1994# oDS = new System.Data.DataSet(); oDBAdapter.Fill(oDS, "Orders"); // set the DataSource, ValueMembersY, and ValueMembersX properties this.chartControl1.DataSource = oDS; this.chartControl1.Series.Add(s); this.chartControl1.Series[0].ValueMembersY = oDS.Tables["Orders"].Columns[7].ColumnName; this.chartControl1.Series[0].ValueMemberX = oDS.Tables["Orders"].Columns[8].ColumnName;
Data Command
' create the series Dim s As New DataDynamics.ActiveReports.Chart.Series Dim m_cnnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Northwind.mdb; Persist Secu Dim m_cnn As New System.Data.Oledb.OleDbConnection(m_cnnString) Dim query As String = "SELECT ShipCountry, SUM(Freight) AS Expr1 FROM Orders GROUP BY ShipCountry" ' create the OleDbCommand and open the connection Dim command As New System.Data.Oledb.OleDbCommand(query, m_cnn) command.Connection.Open() ' set the DataSource and ValueMembersY properties Me.ChartControl1.DataSource = command Me.ChartControl1.Series.Add(s) Me.ChartControl1.Series(0).ValueMembersY = "Expr1" ' close the connection m_cnn.Close() To write the code in C# C# code. Paste INSIDE the section Format event.
// create the series DataDynamics.ActiveReports.Chart.Series s = new DataDynamics.ActiveReports.Chart.Series(); string m_cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Northwind.mdb;Persist Security Inf System.Data.Oledb.OleDbConnection m_cnn = new System.Data.Oledb.OleDbConnection(m_cnnString); string query = "SELECT ShipCountry, SUM(Freight) AS Expr1 FROM Orders GROUP BY ShipCountry"; // create the OleDbCommand and opent the connection System.Data.Oledb.OleDbCommand command = new System.Data.Oledb.OleDbCommand(query, m_cnn); command.Connection.Open(); // set the DataSource and ValueMembersY properties this.chartControl1.DataSource = command; this.chartControl1.Series.Add(s); this.chartControl1.Series[0].ValueMembersY = "Expr1"; // close the connection m_cnn.Close();
Array
The Chart control allows you to set the data source for the data points collection to an array. The following code demonstrates how to create a series, create an array, and use the DataBindY method to set the data source for the data points collection at run time. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create a series, an array, and a data source. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. ' create the series Dim s As New DataDynamics.ActiveReports.Chart.Series ' create the array Dim a As Double() = {1, 4, 2, 6, 3, 3, 4, 7}
' set the data source for the data points collection Me.ChartControl1.Series.Add(s) Me.ChartControl1.Series(0).Points.DataBindY(a) To write the code in C# C# code. Paste INSIDE the section Format event. // create the series DataDynamics.ActiveReports.Chart.Series s = new DataDynamics.ActiveReports.Chart.Series(); // create the array double [] a = {1,4,2,6,3,3,4,7}; // set the data source for the data points collection this.chartControl1.Series.Add(s); this.chartControl1.Series[0].Points.DataBindY(a);
Calculated Series
You can easily create a calculated series based on the values of one or more series by setting the ValueMembersY property of a series to a formula. To reference a series in the formula, use the name of the series. The following code demonstrates how to create two series, one bound to a data array and the other bound to a formula based on the Y values of the first series. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to create a data bound series and a calculated series. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the FetchData event. Dim s As New DataDynamics.ActiveReports.Chart.Series Dim cS As New DataDynamics.ActiveReports.Chart.Series Dim a As Double() = {1, 4, 2, 6, 3, 3, 4, 7} Me.ChartControl1.Series.AddRange(New DataDynamics.ActiveReports.Chart.Series() {s, cS}) Me.ChartControl1.Series(0).Points.DataBindY(a) Me.ChartControl1.Series(0).Name = "Series1" Me.ChartControl1.Series(1).ValueMembersY = "Series1.Y[0]+10" To write the code in C# C# code. Paste INSIDE the FetchData event. DataDynamics.ActiveReports.Chart.Series s = new DataDynamics.ActiveReports.Chart.Series(); DataDynamics.ActiveReports.Chart.Series cS = new DataDynamics.ActiveReports.Chart.Series(); double [] a = { 1,4,2,6,3,3,4,7}; this.chartControl1.Series.AddRange(new DataDynamics.ActiveReports.Chart.Series[] {s, cS}); this.chartControl1.Series[0].Name = "Series1"; this.chartControl1.Series[0].Points.DataBindY(a); this.chartControl1.Series[1].ValueMembersY = "Series1.Y[0]+10";
Sequence Series
Set a sequence series by specifying the minimum value, maximum value, and step for the series. The following code shows how to set the ValueMembersY property at run time to create a sequence series. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to add a series to the chart and set its members. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. Dim s As New DataDynamics.ActiveReports.Chart.Series Me.ChartControl1.Series.Add(s) Me.ChartControl1.Series(0).ValueMembersY = "sequence(12,48,4)"
XML Data
The Chart control allows you to set the data source to an XML document. The following code demonstrates how to create a series and to set the ValueMembersY and ValueMemberX properties at run time. 1. 2. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section. Add code to the handler to add a series to the chart and set its members. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the section Format event. ' create the series Dim s As New DataDynamics.ActiveReports.Chart.Series() Dim xmlDS As New DataDynamics.ActiveReports.DataSources.XMLDataSource("c:/customer.xml", "//CUSTOMER") ' set the DataSource, ValueMembersY and ValueMemberX properties Me.ChartControl1.DataSource = xmlDS Me.ChartControl1.Series.Add(s) Me.ChartControl1.Series(0).ValueMembersY = "xpath:ORDER/ITEM/PRICE" Me.ChartControl1.Series(0).ValueMemberX = "xpath:ORDER/ITEM/AUTHOR" To write the code in C# C# code. Paste INSIDE the section Format event.
// create the series DataDynamics.ActiveReports.Chart.Series s = new DataDynamics.ActiveReports.Chart.Series(); DataDynamics.ActiveReports.DataSources.XMLDataSource xmlDS = new XMLDataSource("c:/customer.xml","//CUST // set the DataSource, ValueMembersY and ValueMemberX properties this.chartControl1.DataSource = xmlDS; this.chartControl1.Series.Add(s); this.chartControl1.Series[0].ValueMembersY = "xpath:ORDER/ITEM/PRICE"; this.chartControl1.Series[0].ValueMemberX = "xpath:ORDER/ITEM/AUTHOR";
RichText
The RichText control gives you an enormous amount of control over the appearance of text in the report. Unlike the TextBox control which applies formatting to the entire contents of the control, the RichText control allows you to apply selective formatting to various areas of text within the control. For example, the Find method allows you to find specific words or characters in the control, while the various selection properties allow you to select text and change its formatting in a dozen ways. You can set the control's text directly using the Text, Html, or RTF properties, or you can load it from a plain text, RTF or HTML file or stream using the Load method. Tip: In order to show special characters in an html file loaded into the control, use the character entity reference (for example, è for or & for &). Use the InsertField and ReplaceField methods for field merging reports, such as the mail merge report demonstrated in the Mail Merge with RichText walkthrough. The RichTextBox now automatically binds inserted fields to the report's fields collection, so you only need to use InsertField and ReplaceField for special cases such as conditional values or system dates. Note: If you have trouble loading a file at design time, be sure that you are not in edit mode. You are in edit mode if your cursor appears inside the control. The following is a list of all of the HTML tags that can be used with the RichText control. Unsupported tags are ignored. Please note that W3C conventions are strictly observed. Supported HTML Tags Tag <B> <I> <P> <STRONG> <BIG> <SMALL> <PRE> <FONT> <BODY> <H1> <H6> <BR> <EM> <U> <IMG> <SUP> <SUB> <CENTER> <TABLE> <TR> <TH> <TD> <LI> <OL> <UL> <STRIKE> Description Bold Italic Paragraph Strong (looks like bold) Big Small Preformatted Font The body tag Heading levels one through six Line break Emphasized (looks like Italics) Underlined Image Superscript Subscript Center alignment Table Table row Table head Table datum List item Ordered list Unordered list Strike through Attributes none none align, style none none none none face, size, color, style (see notes for style attributes) background, text, leftmargin none none none none align, height, src, width none none none align, border, cellpadding, cellspacing, height, style, width align none align, border, colspan, rowspan, width none (nested levels automatically use disc, then circle, then square bullets) type type, value none
The style attribute of <FONT>, <P>, and <TABLE> supports the following properties: Supported Style Attribute Properties border-bottom border-top-width margin-top
Grouping Data
When you add a pair of group header and group footer sections to a report, the new sections appear immediately above and below the detail section. Note: You cannot add a header section without a corresponding footer section. If you try to do so in code, the results are highly unstable. You can, however, hide one of the sections. To hide a section, set its Visible property to False, or set its Height property to 0. Set group header section's DataField property to the field on which you want to group the report. For best results, in the SQL query, order the data by the grouping field. When you run the report, it renders the group header, followed by all related instances of the detail section, and then the group footer. It renders a new group header section for each instance of the grouping field. Controls in the group header render once for each instance of the group, so this is a good place for column header labels to describe the data in the detail fields.
Group options
With the group header selected in the Properties window, there are a number of properties that allow you to control group header behavior. For more information on columnar reporting, see Columnar Reports. For more information on KeepTogether options, see KeepTogether Options. Property Description ColumnGroupKeepTogether If possible, keeps grouped items together in a single column. If True, lays out the group header with the same number of columns as the detail ColumnLayout section. DataField Sets the field on which to group the report. GroupKeepTogether If possible, keeps grouped items together on a single page. KeepTogether If possible, keeps the section together on a single page. NewColumn Tells the group to begin a new column before or after the group field changes. NewPage Tells the group to begin a new page before or after the group field changes. Allows you to have the group header render on each page or column for long RepeatStyle groups. If True, renders the group header as a layer underneath the following section. This is useful if you want to render a group header control in the same row as UnderlayNext data in a nested group header or in the detail section. Take care to leave the BackColor property set to Transparent in the following section, or the group header is hidden.
Multiple Groupings
You can nest group header and footer pairs and group each on a different field. Important: As with any group header and footer pair, group your data on the fields that you specify in the DataField property of the group header, but in the order of your groups. For example:
When you run a report with multiple groupings like the one above, the sections print in an order like the following: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. ReportHeader1 prints once and does not repeat. PageHeader1 prints once at the top of each page. GroupHeader1 prints once for the first value its DataField returns. GroupHeader2 prints once for the first value its DataField returns within the context of GroupHeader1's DataField value. GroupHeader3 prints once for the first value its DataField returns within the context of GroupHeader2's DataField value. Detail1 prints once for each record that falls within the context of GroupHeader3's DataField value. GroupFooter3 prints once at the end of the records that fall within the context of GroupHeader3's DataField value. GroupHeader3 may print again, if more values return within the context of GroupHeader2's DataField value. Each time GroupHeader3 prints again, it is followed by Detail1 (once for each related record) and GroupFooter3. GroupFooter2 prints once after GroupFooter3. GroupHeader2 may print again, if more values return within the context of GroupHeader1's DataField value. Each time GroupHeader2 prints again, it is followed by Detail1 (once for each related record) and GroupFooter2. GroupFooter1 prints once after GroupFooter2. GroupHeader1 prints once for the second value its DataField returns, followed by GroupHeader2, and so on in a pattern similar to the one above. PageFooter1 prints once at the bottom of each page. (Its position within groupings varies.) ReportFooter1 prints once at the end of the report.
You can add up to 32 groupings in one report. With many groupings, you might find the need to rearrange the order of your groups. If your report has more than one group and you right-click the report surface, you
Subreports
In ActiveReports, you can embed a report in another report using the Subreport control. Once you place the Subreport control on a report, you attach a report object to it in code. You can pass parameters to the subreport from the main report, ensuring that data related to the main report displays in each instance of the subreport. Since they render inside the main report, subreports are disconnected from any concept of a printed page. For this reason, page-dependent features are not supported for use in subreports. Keep any such logic in the main report. Page-related concepts that are not supported in subreports include:
Page numbers Page header and footer sections (delete these sections to save processing time) KeepTogether properties GroupKeepTogether properties NewPage properties
Because of the high overhead of running a second report and embedding it in the first, it is generally best to instead use grouping wherever possible. If grouping cannot accommodate your particular report, use subreports. Some uses of subreports include:
Repeating groups Relational data Multiple data sources Multiple detail sections
As a best practice, create an instance of the report for your Subreport control in the ReportStart event of the main report, and then dispose of it in the ReportEnd event. In this way, you are creating only one subreport instance when you run the main report. If you instantiate the subreport in a section Format event, it creates a new instance of the subreport each time the section processes. This consumes a lot of memory and processing time, especially in a report that processes a large amount of data.
Report Events
Events that are Raised Only Once
The following events are all of the events that are raised only once during a report's processing. These events are raised at the beginning and at the end of the report processing cycle.
ReportStart
This event is raised before the DataInitialize event. Use this event to initialize any objects or variables needed while running a report. Also use this event to set any Subreport control objects to a new instance of the report assigned to the Subreport control. Do not add items dynamically to a report once this event has finished.
DataInitialize
This event is raised after ReportStart. Use it to add custom fields to the report's Fields collection. Custom fields can be added to a bound report (one that uses a Data Control to connect and retrieve records) or an unbound report (one that does not depend on a data control to get its records). In a bound report the dataset is opened and the dataset fields are added to the custom fields collection, then the DataInitialize event is raised so new custom fields can be added. The DataInitialize event can also be used to make adjustments to the DataSource or to set up database connectivity.
ReportEnd
This event is raised after the report finishes processing. Use this event to close or free any objects that you were using while running a report in unbound mode, or to display information or messages to the end user. This event can also be used to export reports.
FetchData
This event is raised every time a new record is processed. The FetchData has an EOF parameter indicating whether the FetchData event should be raised. This parameter is not the same as the Recordset's EOF property and is defaulted to True. When working with bound reports (reports using a DataControl), the EOF parameter is automatically set by the report; however, when working with unbound reports this parameter needs to be controlled manually. Use the FetchData event with unbound reports to set the values of custom fields that were added in the DataInitialize event or with bound reports to perform special functions, such as combining fields together or performing calculations. The FetchData event should not have any references to controls on the report. If you need to use a value from a Dataset with a control in the Detail section, set a variable in the FetchData event and use the variable in the section's Format event to set the value for the control. Please note that this method of setting a variable in the FetchData event and using it to set a control's value is only supported in the Detail_Format event. Also use the FetchData event to increment counters when working with arrays or collections.
PageStart
This event fires before a page is rendered. Use this event to initialize any variables needed for each page when running an unbound report.
PageEnd
This event is raised after each page in the report is rendered. Use this event to update any variables needed for each page when running an unbound report.
Section 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-raising sequence is dynamic in order to accommodate individual report demands. The only guaranteed sequence is that a section's Format event is raised before the BeforePrint event, which in turn occurs before the AfterPrint event but not necessarily all together. Reports should not be designed to rely on these events being raised in immediate succession. Important: Never reference the report's Fields collection in these section events. Only reference the Fields collection in the DataInitialize and FetchData events.
Format event
ActiveReports raises this event 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 in which you can change the section's height. Use this section to set or change the properties of any controls or the section itself. Also use the Format event to pass information, such as an SQL String, to a Subreport. If the CanGrow or CanShrink property is True for the section or any control within the section, all of the growing and shrinking takes place in the Format event. Because of this, you cannot obtain information about a control or section's height in this event. Because a section's height is unknown until the Format event finishes, it is possible for a section's Format event to be raised while the report is on a page to which the section is not rendered. For example, the Detail Format event is raised but the section is too large to fit on the page. This causes the PageFooter events and the PageEnd event to be raised on the current page, and the PageStart, any other Header events, and possibly the FetchData event to be raised before the section is rendered to the canvas on the next page.
BeforePrint event
ActiveReports raises this event before the section is rendered to the page. The growing and shrinking of the section and its controls have already taken place. Therefore, you can use this event to get an accurate height of the section and its controls. You can modify values and resize controls in the BeforePrint event, but you cannot modify the height of the section itself. Also use this event to do page-specific formatting since the report knows which page the section will be rendered to when this event is raised. Once this event has finished, the section cannot be changed in any way because the section is rendered to the canvas immediately after this event.
AfterPrint event
ActiveReports raises this event after the section is rendered to the page. 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. This event is still useful, however, if you want to draw on the page after text has already been rendered to it.
Sequence of Events
Intelligent, multi-threaded, single-pass processing enables ActiveReports to surpass other reports in processing and output generation speed. ActiveReports processes and renders each page as soon as the page is ready. If a page has unknown data elements or its layout is not final, it places the page in cache until the data is available. Summary fields and KeepTogether constraints are two reasons why a page might not render immediately. 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 are delayed until all of the data is read. There are eleven report events in the code behind an ActiveReport, or seven in an ActiveReport script.
Because there are so many ways in which you can customize your reports, not all reports execute in the same way. However, when you run a report, this is generally what happens: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. ActiveReports raises the ReportStart event. The report validates any changes made to the report structure in ReportStart. In some cases, data source properties raise the DataInitialize event. Printer settings are applied. If none are specified, the local machine's default printer settings are used. If the DataInitialize event was not already raised, ActiveReports raises it and opens the data source. If the data source contains parameters with unset values and the ShowParameterUI property is set to True, ActiveReports displays a parameters dialog to request values from the user. Closing the dialog raises the ParameterUIClosed event. If the report is a subreport that requires parameters, ActiveReports binds the subreport parameters to any fields in the parent report. ActiveReports raises the FetchData event. If there is no data, the NoData event is raised. The PageStart event raises, and then raises again after each PageEnd event until the final page. Group sections are bound and sections begin rendering on pages. ActiveReports raises Section Events to process sections in (roughly) the following order:
Report header Page header Group header Detail Group footer Page footer Report footer
After each event, ActiveReports checks the Cancel flag to ensure that it should continue. Other events may raise, depending on the report logic. The PageEnd event raises after each page becomes full, and the PageStart raises if the report has not finished.
Unbound Reporting
ActiveReports allows you to bind reports to any type of data source, including arrays. You can create a report without setting its data source, then load the data into the control at run time. Use the ReportStart event to set up your data source, the ReportEnd event to close it, the DataInitialize event to create your fields collection, and the FetchData event to populate it.
Set the database path (place this code above the ReportStart event) Set the data source connection string Set the data source SQL query Open the connection to create the DataReader
The following examples show what the code for the method looks like. Add using or Imports statements for System.Data and System.Data.OleDb. To create a GetDatabasePath method in Visual Basic.NET Visual Basic.NET code. Paste JUST ABOVE the ReportStart event. Private Function getDatabasePath() As String Dim regKey As Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine regKey = regKey.CreateSubKey _ ("SOFTWARE\\GrapeCity\\ActiveReports 6\\SampleDB") getDatabasePath = CType(regKey.GetValue(""), String) End Function Private conn As OleDbConnection Private reader As OleDbDataReader Private cmd As OleDbCommand Visual Basic.NET code. Paste INSIDE the ReportStart event.
Private Sub rptYourReportName_ReportStart(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles MyBase.ReportStart Dim dbPath As String = getDatabasePath() Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + dbPath + "\\NWIND.mdb" conn = New OleDbConnection(connString) cmd = New OleDbCommand("SELECT * FROM categories INNER JOIN products ON _ categories.categoryid = products.categoryid ORDER BY products.categoryid, products.productid", conn.Open() reader = cmd.ExecuteReader() End Sub To create a GetDatabasePath method in C# C# code. Paste JUST ABOVE the ReportStart event. private string getDatabasePath() { Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine; regKey = regKey.CreateSubKey("SOFTWARE\\GrapeCity\\ActiveReports 6\\SampleDB"); return ((string)(regKey.GetValue(""))); } private static OleDbConnection conn; private static OleDbDataReader reader; C# code. Paste INSIDE the ReportStart event. string dbPath = getDatabasePath(); string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + dbPath + "\\NWIND.mdb";
conn = new OleDbConnection(connString); OleDbCommand cmd = new OleDbCommand("SELECT * FROM categories INNER JOIN products ON categories.category conn.Open(); reader = cmd.ExecuteReader();
Visual Basic.NET code. Paste INSIDE the ReportEnd event. reader.Close() conn.Close() To write the code in C# 1. 2. 3. 4. Click in the gray area below the report to select it. Click the events icon in the Properties window to display available events for the report. Double-click ReportEnd. This creates an event-handling method for the report's ReportEnd event. Add code to the handler to close the data connection
Visual Basic.NET code. Paste INSIDE the DataInitialize event. Fields.Add("CategoryName") Fields.Add("ProductName") Fields.Add("UnitsInStock") Fields.Add("Description") To write the code in C# 1. 2. 3. 4. Click in the gray area below the report to select it. In the Properties window, click the events icon to display available events for the report. Double-click DataInitialize. This creates an event-handling method for the report's DataInitialize event. Add code to the handler to add fields to the report's fields collection.
C# code. Paste INSIDE the DataInitialize event. Fields.Add("CategoryName"); Fields.Add("ProductName"); Fields.Add("UnitsInStock"); Fields.Add("Description");
Visual Basic.NET code. Paste INSIDE the FetchData event. Try reader.Read() Me.Fields("CategoryName").Value = reader("CategoryName") Me.Fields("ProductName").Value = reader("ProductName") Me.Fields("UnitsInStock").Value = reader("UnitsInStock") Me.Fields("Description").Value = reader("Description") eArgs.EOF = False Catch ex As Exception eArgs.EOF = True End Try To write the code in C# 1. 2. 3. 4. Click in the gray area below the report to select it. In the Properties window, click the events icon to display available events for the report. Double-click FetchData. This creates an event-handling method for the report's FetchData event. Add code to the handler to retrieve information to populate the report fields.
C# code. Paste INSIDE the FetchData event. try { reader.Read(); Fields["CategoryName"].Value = reader["CategoryName"].ToString(); Fields["ProductName"].Value = reader["ProductName"].ToString(); Fields["UnitsInStock"].Value = reader["UnitsInStock"].ToString(); Fields["Description"].Value = reader["Description"].ToString(); eArgs.EOF = false; } catch { eArgs.EOF = true; }
Optimizing ActiveReports
Optimization can be crucial for large reports (i.e. over 100 pages). Here is some information which will help you to achieve the best possible results for such reports. To optimize ActiveReports for the web, please refer to the memory considerations section.
Memory Considerations
Images Limit the use of large images when exporting to RTF and TIFF formats. Note that even one image uses a lot of memory if it's repeated on every page of a very long report exported to TIFF or RTF. If you are not exporting, or if you are exporting to Excel, PDF, or HTML, repeated images are stored only once to save memory, but the comparison necessary to detect duplicate images slows the processing time for the report. Subreports Limit the use of subreports in repeating sections because each subreport instance consumes memory. For example, consider that a subreport in the Detail section of a report in which the Detail section is repeated 2,000 times will have 2,000 instances of the subreport. Nested subreports will compound the number of instances. If you need to use subreports in repeating sections, instantiate them in the ReportStart event instead of the Format event of the repeating section so that they will be instantiated only once and use less memory. CacheToDisk Set the CacheToDisk property of the Document object to True. Although it will slow down the processing time, this will cause the document to be cached to disk instead of loading the whole report in memory. The PDF export will also detect this setting and use the cached report to export. Please note that only the PDF export is affected by the CacheToDisk Property; other exports may run out of memory with very large reports. Also note that CacheToDisk uses IsolatedStorage to store a pages canvasItems to disk. To use CacheToDisk you must have IsolatedStorageFilePermission. Summaries Placing summaries (primarily page count and report totals) in header sections will have an adverse effect on memory as well as rendering speed with large reports using the CacheToDisk property. Since the rendering of the header is delayed until ActiveReports determines the total or page count of the following sections, CacheToDisk is unable to perform any optimization. The greater the number of affected sections, the longer rendering is delayed and the less optimization CacheToDisk will offer. Therefore, a group total in a group header section does not affect performance and memory as much as a report total in the report header. Releasing Reports To properly release a report instance from memory, take these steps in the following order: 1. 2. 3. Call the Dispose() method of the Document object Call the Dispose() method of the Report object Set the Report object to null
The following code uses the above steps to release a report. To write the code in Visual Basic.NET Visual Basic.NET code. rpt.Document.Dispose() rpt.Dispose() rpt = Nothing To write the code in C# C# code. rpt.Document.Dispose(); rpt.Dispose(); rpt = null;
Speed Considerations
Images An image repeated on every page of a very long report is stored only once to improve memory, but the comparison necessary to detect duplicate images slows performance. This is not only the case with the report document itself, but also with the Excel, PDF, and HTML exports as they perform their own comparisons.
Summaries Placing summaries (primarily page count and report totals) in header sections will slow report processing. ActiveReports must determine the total or page count of the following sections before it can render the header section. The greater the number of affected sections, the longer rendering is delayed. Therefore, a group total in a group header section does not affect performance and memory as much as a report total in the report header. CacheToDisk Be sure that the CacheToDisk property of the Document object is not set to True. Setting it to True increases the amount of time the report takes to load, and should only be used with very large reports that use a lot of memory. If this is used with smaller reports of less than 100 pages, it may actually cause more memory to be used. Stored Procedures Using stored procedures instead of SELECT statements speeds up the processing time of a report, as it reduces the number of records handled by ActiveReports. Using SELECT * statements is not recommended unless you are actually using all of the data returned by such a statement. Consult your database administrator for other ways to speed up data retrieval, such as indexing tables.
Accessibility Summary:
All major features of ActiveReports software are accessible via keyboard navigation.
DISCLAIMER:
GRAPECITY MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. The following information reflects the general accessibility features of GrapeCity software components as related to the Section 508 standards. If you find that the information is not accurate, or if you have specific accessibility needs that our products do not meet, please contact us and we will attempt to rectify the problem, although we cannot guarantee that we will be able to do so in every case.
Supported
(j) When a product permits a user to adjust color and contrast settings, a variety of color selections capable of producing a range of contrast levels shall be provided.
Supported
(k) Software shall not use flashing or blinking text, objects, The controls do not use flashing or or other elements having a flash or blink frequency greater Supported blinking text or objects. than 2 Hz and lower than 55 Hz. Any form-type dialogs or windows (l) When electronic forms are used, the form shall allow associated with the controls provide people using Assistive Technology to access the Assistive Technology with access to information, field elements, and functionality required for Supported information on all directions, cues, completion and submission of the form, including all field elements, and functionality directions and cues. required for completion.
By default, the software (o) A method shall be provided that permits users to skip repetitive Not contains no repetitive navigation links. Applicable navigation links. (p) When a timed response is required, the user shall be alerted Not No timed responses are and given sufficient time to indicate more time is required. Applicable required with ActiveReports.
ActiveReports
Section 1194.31 Functional Performance Criteria Criteria (a) At least one mode of operation and information retrieval that does not require user vision shall be provided, or support for assistive technology used by people who are blind or visually impaired shall be provided. (b) At least one mode of operation and information retrieval that does not require visual acuity greater than 20/70 shall be provided in audio and enlarged print output working together or independently, or support for assistive technology used by people who are visually impaired shall be provided. (c) At least one mode of operation and information retrieval that does not require user hearing shall be provided, or support for assistive technology used by people who are deaf or hard of hearing shall be provided. (d) Where audio information is important for the use of a product, at least one mode of operation and information retrieval shall be provided in an enhanced auditory fashion, or support for assistive hearing devices shall be provided. (e) At least one mode of operation and information retrieval that does not require user speech shall be provided, or support for assistive technology used by people with disabilities shall be provided. (f) At least one mode of operation and information retrieval that does not require fine motor control or simultaneous actions and that is operable with limited reach and strength shall be provided. Status Not Supported Not Supported Not Applicable Not Applicable Not Applicable Not Applicable Remarks
Documentation
Section 1194.41 Information, Documentation, and Support Criteria Status (a) Product support documentation provided to end-users shall be made available in alternate formats upon request, Supported at no additional charge. (b) End-users shall have access to a description of the accessibility and compatibility features of products in Supported alternate formats or alternate methods upon request, at no additional charge. (c) Support services for products shall accommodate the Supported Remarks Documentation is available in three formats: hxs (Visual Studio Integrated help), chm, and pdf. Accessibility information is available upon request. Support services are available by
Localization
ActiveReports uses the Hub and Spoke model for localizing resources. The hub is the main executing assembly, for example, the Viewer Control, ActiveReports.Viewer6.dll. The spokes are the satellite DLLs that contain localized resources for the application, for example, ActiveReports.Viewer6.resources.dll. The Localization folder, C:\Program Files\GrapeCity\ActiveReports 6\Localization, contains everything you need to localize all of your ActiveReports components. Within that folder, each component of ActiveReports that you can localize, 14 in all, has two files:
*.bat Set the culture to which you want to localize. *.zip Change the strings in the resource files (*.resx) it contains.
There is one application in the folder: NameCompleter.exe When you run your bat file after changing it to your culture, it runs this application to create a SatelliteAssembly folder with a language subfolder containing the localized ActiveReports.AssemblyName.resources.dll file. Place the culture subdirectories containing the satellite assemblies in the folder that contains your main executing assembly. Note: If you want to put your localization in the Global Assembly Cache (GAC), you must first send the localized ActiveReports.AssemblyName.resources.dll file to GrapeCity (mailto:support@datadynamics.com?subject=Need to have localized resource dll signed.) and get it signed. Then you can drag the language subfolder with the signed dll file into C:\WINDOWS\ASSEMBLY. When the main executing assembly needs a resource, it uses a ResourceManager object to load the required resource. The ResourceManager uses the thread's CurrentUICulture property. The common language runtime sets the CurrentUICulture property or you can set it in code to force a certain UI Culture to test whether your satellite DLL is loading properly. The ResourceManager class uses the CurrentUICulture Property to locate subdirectories that contain a satellite DLL for the current culture. If no subdirectory exists, the ResourceManager uses the resource that is embedded in the assembly. US English is the default culture for ActiveReports. For more detailed information about how the Framework locates satellite DLLs, please refer to the help system in Visual Studio or the book Developing International Software, 2nd edition by MS Press that contains information on localizing applications using the .NET Framework.
How To
See step-by-step instructions for performing common tasks using ActiveReports.
4.
Bind a report to a data source using the data source icon in the detail section band which opens the Report Data Source window. There are four tabs on the window for the four most commonly used data sources: To use the OLE DB data source 1. Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog.
2. 3. 4. 5. 6. 7.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to your database or the sample Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter a SQL query to select the data that you want. Click OK to save the data source and return to the report design surface. To use the SQL data source
1.
Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog.
2. 3. 4. 5. 6. 7.
On the SQL tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft OLE DB Provider for SQL Server and click the Next button. Under 1. Select or enter a server name, drop down the box and select your server. Under 2. Enter information to log on to the server, set up your log on information. Under 3. you can select a database on the server or attach a database file. Click OK to close the window and fill in the Connection String field.
2. 3.
On the XML tab, next to File URL, click the .. button. In the Open File window that appears, navigate to your XML data file, select it, and click the Open button. (The sample xml data file is located in C:\Program Files\GrapeCity\ActiveReports 6 \Data\customer.xml) In the Recordset Pattern field, enter a valid XPath expression. (for example, //CUSTOMER for the sample xml data file) Click OK to save the data source and return to the report design surface. To use an Unbound data source
4. 5.
1. 2.
Double-click in the gray area below the design area of your report to create an event-handling method for the ReportStart event. Add code to:
Change the data source at run time Close the data connection Add fields to the report Populate fields in the report
To create a data source in Visual Basic.NET The following example shows what the code for the method looks like. Visual Basic.NET code. Paste JUST ABOVE the ReportStart event. Dim conn As System.Data.OleDb.OleDbConnection Dim reader As System.Data.OleDb.OleDbDataReader Visual Basic.NET code. Paste INSIDE the ReportStart event. Dim dbPath As String = getDatabasePath() Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath + "\\NWIND.mdb" conn = New System.Data.OleDb.OleDbConnection(connString) Dim cmd As New System.Data.OleDb.OleDbCommand("SELECT * FROM Products WHERE UnitPrice = 18", conn) conn.Open() reader = cmd.ExecuteReader() Me.DataSource = reader To create a data source in C# The following example shows what the code for the method looks like. C# code. Paste JUST ABOVE the ReportStart event. private static System.Data.OleDb.OleDbConnection conn; private static System.Data.OleDb.OleDbDataReader reader; C# code. Paste INSIDE the ReportStart event.
string dbPath = getDatabasePath(); string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath + "\\NWIND.mdb"; conn = new System.Data.OleDb.OleDbConnection(connString); System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("SELECT * FROM Products WHERE Un conn.Open(); reader = cmd.ExecuteReader(); this.DataSource = reader;
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the ReportEnd event. reader.Close() conn.Close() To close the data connection in C# 1. 2. 3. 4. Click in the gray area below rptModifyDS to select the report. Click the events icon in the Properties Window to display available events for the report. Double-click ReportEnd. This creates an event-handling method for the ReportEnd event. Add code to the handler to close the data connection.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the ReportEnd event. reader.Close(); conn.Close(); Warning: Do not access the Fields collection outside the DataInitialize and FetchData events. Accessing the Fields collection outside of these events is not supported, and has unpredictable results. To add fields in Visual Basic 1. 2. 3. 4. Right-click in any section of the design surface of the report, and select View Code to display the code view for the report. At the top left of the code view of the report, click the drop-down arrow and select (YourReportName Events). At the top right of the code window, click the drop-down arrow and select DataInitialize . This creates an event-handling method for the report's DataInitialize event. Add code to the handler to add fields to the report's Fields collection.
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the DataInitialize event. Fields.Add("CategoryID") Fields.Add("CategoryName") Fields.Add("ProductName") Fields.Add("UnitsInStock") Fields.Add("Description") Fields.Add("TotalLabel") To add fields in C# 1. 2. 3. 4. Click in the gray area below the report to select it. Click the events icon in the Properties Window to display available events for the report. Double-click DataInitialize. This creates an event-handling method for the report's DataInitialize event. Add code to the handler to add fields to the report's Fields collection.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the DataInitialize event. Fields.Add("CategoryID"); Fields.Add("CategoryName"); Fields.Add("ProductName"); Fields.Add("UnitsInStock"); Fields.Add("Description");
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the FetchData event. Try reader.Read() Me.Fields("CategoryID").Value = reader("categories.CategoryID") Me.Fields("CategoryName").Value = reader("CategoryName") Me.Fields("ProductName").Value = reader("ProductName") Me.Fields("UnitsInStock").Value = reader("UnitsInStock") Me.Fields("Description").Value = reader("Description") Me.Fields("TotalLabel").Value = "Total Number of " + reader("CategoryName") + ":" eArgs.EOF = False Catch eArgs.EOF = True End Try To populate fields in C# 1. 2. 3. 4. Back in design view, click in the gray area below the report to select it. Click the events icon in the Properties window to display available events for the report. Double-click FetchData. This creates an event-handling method for the report's FetchData event. Add code to the handler to retrieve information to populate the report fields.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the FetchData event. try { reader.Read(); Fields["CategoryID"].Value = reader["categories.CategoryID"].ToString(); Fields["CategoryName"].Value = reader["CategoryName"].ToString(); Fields["ProductName"].Value = reader["ProductName"].ToString(); Fields["UnitsInStock"].Value = reader["UnitsInStock"].ToString(); Fields["Description"].Value = reader["Description"].ToString(); Fields["TotalLabel"].Value = "Total Number of " + reader["CategoryName"].ToString() + ":"; eArgs.EOF = false; } catch { eArgs.EOF = true; }
Group Data
To group a report on a field
1. 2. Right-click the design surface of a report and select Insert, then Group Header/Footer to add a group header and group footer section. With the group header selected in the Properties window, drop down the DataField property and select the field on which to group the report.
string dbPath = getDatabasePath(); string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath + "\\NWIND.mdb"; conn = new System.Data.OleDb.OleDbConnection(connString); System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("SELECT * FROM Products WHERE Un conn.Open(); reader = cmd.ExecuteReader(); this.DataSource = reader;
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the ReportEnd event. reader.Close() conn.Close() To write the code in C# 1. 2. 3. 4. Click in the gray area below rptModifyDS to select the report. Click the events icon in the Properties Window to display available events for the report. Double-click ReportEnd. This creates an event-handling method for the ReportEnd event. Add code to the handler to close the data connection.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the ReportEnd event. reader.Close(); conn.Close();
To use a substring
Change the DataField property for the text box to the substring needed. If setting up grouping, change the GroupHeader's DataField property to the same substring. Example: =ProductName.Substring(0, 1)
To use date/time
Change the DataField property for the text box to the following. Example: =System.DateTime.Now.ToString()
To concatenate fields
Change the DataField property for the text box to the following.
To round a calculation
Change the DataField Property for the text box to the following. Example: =(double)System.Math.Round(UnitPrice*UnitsOnOrder,2)
Note: The SummaryRunning property is only set when the SummaryType is GrandTotal or SubTotal, otherwise it is set to None. 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 (for example, DSum for distinct summary or DCount for distinct count).
2.
With field1 selected in the Properties Window, change the Formula property to Quantity * UnitPrice to bind it to the product of the Quantity and UnitPrice fields, substituting the names of fields that you have under the Bound node in your report.
3. 4.
Change other properties as desired. Drag the field from the Calculated node onto the detail section of the report. This creates an ActiveReports TextBox object, and sets its DataField property to the name of the calculated field.
2. 3. 4. 5. 6.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, paste the following SQL query. SQL Query SELECT TOP 10 Customers.CompanyName, Sum([UnitPrice]*[Quantity]) AS Sales FROM (Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID GROUP BY Customers.CompanyName ORDER BY Sum([UnitPrice]*[Quantity]) DESC
7.
DataField: the field that you want to summarize SummaryGroup: the name of the GroupHeader section SummaryRunning: Group SummaryType: SubTotal
DataField: the field that you want to summarize SummaryRunning: All SummaryType: GrandTotal
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste JUST ABOVE the Detail Format event. Dim color As Boolean Visual Basic.NET code. Paste INSIDE the Detail Format event. If color = True Then Me.Detail1.BackColor = System.Drawing.Color.DarkSeaGreen color = False Else Me.Detail1.BackColor = System.Drawing.Color.Transparent color = True End If To write the code in C#
2.
Or you can right-click the Settings node in the Report Explorer and select Show.
3. 4.
In the Report Settings dialog, click Global Settings. Change Ruler Units from inches to centimeters or centimeters to inches.
2.
3.
You can customize the preset values by editing the string after you select it. For more information on creating formatting strings, see the Date, Time, and Number Formatting topic.
Format BarCodes
The ActiveReports BarCode control offers all of the following barcode styles: Barcode styles and descriptions BarCodeStyle Ansi39 Ansi39x Code_2_of_5 Code25intlv Code25mat Code39 Code39x Code_128_A Code_128_B Code_128_C Code_128auto Code_93 Code93x MSI PostNet Codabar EAN_8 EAN_13 UPC_A Description ANSI 3 of 9 (Code 39) uses upper case, numbers, - , * $ / + %. This is the default barcode style. ANSI Extended 3 of 9 (Extended Code 39) uses the complete ASCII character set. Code 2 of 5 uses only numbers. Interleaved 2 of 5 uses only numbers. Code 25 Matrix is a two-dimensional version of the linear Code 2 of 5 barcode. Code 39 uses numbers, % * $ /. , - +, and upper case. Extended Code 39 uses the complete ASCII character set. Code 128 A uses control characters, numbers, punctuation, and upper case. Code 128 B uses punctuation, numbers, upper case and lower case. Code 128 C uses only numbers. Code 128 Auto uses the complete ASCII character set. Automatically selects between Code 128 A, B and C to give the smallest barcode. Code 93 uses uppercase, % $ * / , + -, and numbers. Extended Code 93 uses the complete ASCII character set. MSI Code uses only numbers. PostNet uses only numbers with a check digit. Codabar uses A B C D + - : , / and numbers. EAN-8 uses only numbers (7 numbers and a check digit). EAN-13 uses only numbers (12 numbers and a check digit). If there are only 12 numbers in the string, it calculates a checksum and adds it to the thirteenth position. If there are 13, it validates the checksum and throws an error if it is incorrect. UPC-A uses only numbers (11 numbers and a check digit). UPC-E0 uses only numbers. Used for zero-compression UPC symbols. For the Caption property, you may enter either a six-digit UPC-E code or a complete 11-digit (includes code type, which must be zero) UPC-A code. If an 11-digit code is entered, the Barcode control will convert it to a six-digit UPC-E code, if possible. If it is not possible to convert from the 11-digit code to the six-digit code, nothing is displayed. UPC-E1 uses only numbers. Used typically for shelf labeling in the retail environment. The length of the input string for U.P.C. E1 is six numeric characters. Royal Mail RM4SCC uses only letters and numbers (with a check digit). This is the barcode used by the Royal Mail in the United Kingdom. UCC/EAN 128 uses the complete ASCII character Set. This is a special version of Code 128 used in HIBC applications. QRCode is a 2D symbology that is capable of handling numeric, alphanumeric and byte data as well as Japanese kanji and kana characters. This symbology can encode up to 7,366 characters. Code 49 is a 2D high-density stacked barcode containing two to eight rows of eight characters each. Each row has a start code and a stop code. Encodes the complete ASCII character set. This is the barcode used by the Japanese Postal system. Encodes alpha and numeric characters consisting of 18 digits including a 7-digit postal code number, optionally followed by block and house number information. The data to be encoded can include hyphens. Pdf417 is a popular high-density 2-dimensional symbology that encodes up to 1108 bytes of information. This barcode consists of a stacked set of smaller barcodes. Encodes the full ASCII character set. It has ten error correction levels and three data compaction modes: Text, Byte, and Numeric. This
UPC_E0
Code49
JapanesePostal
Pdf417
A allows standard alphanumeric plus control and special characters B allows standard alphanumeric plus lower case alpha and special characters C allows a set of 100 digit pairs from 00 to 99
FNC (function) 1 character which allows scanners to identify this as an EAN-128 barcode Data (AI plus data field) Symbol check character (Start code value plus product of each character position plus value of each character divided by 103. The checksum is the remainder value.) Stop character Trailing quiet zone (blank area)
EAN128FNC1
The AI in the Data section sets the type of the data to follow (i.e. ID, dates, quantity, measurements, etc.). There is a specific data structure for each type of data. This AI is what distinguishes the EAN-128 code from Code 128. Multiple AIs (along with their data) can be combined into a single bar code.
EAN128FNC1 is a UCC/EAN-128 (EAN128) type barcode that allows you to insert FNC1 character at any place and adjust the bar size, etc., which is not available in UCC/EAN-128. To insert FNC1 character, set \n for C#, or vbLf for VB to Text property at runtime.
RSS14 is a 14-digit Reduced Space Symbology that uses EAN.UCC item identification for point-of-sale omnidirectional scanning. RSS14Truncated uses the EAN.UCC information as in the RSS14, but also RSS14Truncated includes Indicator digits of zero or one for use on small items not scanned at the point of sale. RSS14Stacked uses the EAN.UCC information with Indicator digits as in the RSS14Stacked RSS14Truncated, but stacked in two rows for a smaller width. RSS14StackedOmnidirectional uses the EAN.UCC information RSS14StackedOmnidirectional with omnidirectional scanning as in the RSS14, but stacked in two rows for a smaller width. RSSExpanded uses the EAN.UCC information as in the RSS14, but also adds AI RSSExpanded elements such as weight and best-before dates. RSSExpandedStacked uses the EAN.UCC information with AI elements as in RSSExpandedStacked the RSSExpanded, but stacked in two rows for a smaller width. RSS14 * The RSS and QRCode styles have fixed height-to-width ratios. When you resize the width, the height is automatically calculated. The following properties help you to customize the exact barcode you need for your application: Barcode properties and descriptions Property Alignment AutoSize BackColor BarWidth Description The horizontal alignment of the caption in the control. Select from Near, Center, or Far. See CaptionPosition for vertical alignment. When set to True, the barcode automatically stretches to fit the control. Select a background fill color for the barcode. Set the width, in inches, of the barcode's narrow bars. Setting the width to 0 expands the barcode to fit the control. The width ratio is 1 to 0.012 inches. So setting the BarWidth to
Dpi sets the printer resolution. Specify the resolution of the printer as dots per inch to create an optimized barcode image with the specified Dpi value. BarAdjust sets the adjustment size by dot units, which affects the size of the module and not the entire barcode.
Code49
ModuleSize sets the horizontal size of the barcode module. Code49 Options include Grouping and Group. If Grouping is set to True, any value not expressed by a single barcode is expressed by splitting it into several barcodes, and the Group property may be set to a number between 0 and 8. The default values are False and 0, respectively. When the Group property is set to 2, the grouped barcode's second symbol is created. When invalid group numbers are set, the BarCodeDataException is thrown. Specify the print direction of the barcode symbol. Select from LeftToRight (the default value), RightToLeft, TopToBottom, or BottomToTop. Set the font for the caption. Only takes effect if you set the CaptionPosition property to a value other than None. Select a color for the barcode and caption. PDF417 Options only apply to the barcode style PDF417.
Column sets column numbers for the barcode. Values for this property range from 1 to 30. The default value is -1 which automatically determines row numbers. ErrorLevel sets the error correction level for the barcode. Values range between 0 and 8. The error correction capability increases as the value increases. With each increase in the ErrorLevel value, the size of the barcode increases. The default value is -1 for automatic configuration. Row sets row numbers for the barcode. Values range between 3 and 90. The default value is -1 which automatically determine row numbers. Type sets the barcode type to Normal or Simple. Simple is the compact type in which the right indicator is neither displayed nor printed.
PDF417
Connection allows any value which cannot be expressed by a single barcode to split into several barcodes. This property is used in conjunction with the ConnectionNumber property. ConnectionNumber Use this property with the Connection property to set the number of barcodes it can split into. Values between 0 and 15 are valid. An invalid number raises the BarCodeData Exception. ErrorLevel values are L (7% restorable), M (15% restorable), Q (25% restorable), and H (30% restorable). The higher the percentage, the larger the barcode becomes. Mask is used to balance brightness and offers 8 patterns in the QRCodeMask enumeration. The default value is Auto, which sets the masking pattern automatically, and is recommended for most uses.
QRCode
Mask000 (i+j) mod 2 = 0 Mask001 i mod 2 = 0 Mask010 j mod 3 = 0 Mask011 (i+j) mod 3 = 0 Mask100 (( i div 2)+(j div 3)) mod 2 = 0
Mask101 (ij) mod 2 + (ij) mod 3 = 0 Mask110 ((ij) mod 2 +(ij) mod 3) mod 2 = 0 Mask111 ((ij)mod 3 + (i+j) mod 2) mod 2 = 0
Model sets Model1, the original model, or Model2, the extended model.
Version indicates the size of the barcode. As the value increases, the barcode's size increases, enabling more information to be stored. Specify any value between 1 and 14 when the Model property is set to Model1 and 1 to 40 for Model2. The default value is -1, which automatically determines the version most suited to the value. Sets the number of stacked rows in the barcode. Sets the symbology used to render the barcode. See the table above for details about each style. Sets the value to print as a barcode symbol and caption. ActiveReports fills this value from the bound data field if the control is bound to the data source.
Add Hyperlinks
Using the Hyperlink property available on the following ActiveReports controls, you can add hyperlinks that connect to a Web page, open an e-mail, or jump to a bookmark.
Parse the URL out of the HomePage field Assign it to the HyperLink property of txtHomePage Remove the URL markers from the text displayed in txtHomePage
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Format event. Dim iStart As Integer Dim sHTML As String If txtHomePage.Text <> "" Then iStart = InStr(1, txtHomePage.Text, "#", CompareMethod.Text) sHTML = Right(txtHomePage.Text, (Len(txtHomePage.Text) - iStart)) sHTML = Replace(sHTML, "#", "", 1, -1, CompareMethod.Text) txtHomePage.HyperLink = sHTML txtHomePage.Text = Replace(txtHomePage.Text, "#", "", 1, -1, CompareMethod.Text) End If To write the code in C# C# code. Paste INSIDE the Format event. int iStart; string sHTML; if (txtHomePage.Text != "") { iStart = txtHomePage.Text.IndexOf("#",0); sHTML = txtHomePage.Text.Substring(iStart, txtHomePage.Text.Length - iStart); sHTML = sHTML.Replace("#", ""); txtHomePage.HyperLink = sHTML; txtHomePage.Text = txtHomePage.Text.Replace("#", ""); }
Parse the URL out of the HomePage field Assign it to the HyperLink property of txtHomePage Remove the URL markers from the text displayed in txtHomePage
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste JUST ABOVE the Format event. Public pBM As New BookmarksCollection() Dim iEntry As Integer Visual Basic.NET code. Paste INSIDE the Format event. Me.Detail1.AddBookmark(Me.txtCompanyName.Text) Me.txtEntry.HyperLink = "toc://" + pBM(iEntry - 1).Label Me.txtEntry.Text = pBM(iEntry - 1).Label Me.txtPage.Text = pBM(iEntry - 1).PageNumber To write the code in C# C# code. Paste JUST ABOVE the Format event. public BookmarksCollection pBM = new BookmarksCollection(); int iEntry; C# code. Paste INSIDE the Format event. this.detail.AddBookmark(this.txtCompanyName.Text); this.txtEntry.HyperLink = "toc://" + pBM[iEntry - 1].Label; this.txtEntry.Text = pBM[iEntry - 1].Label; this.txtPage.Text = pBM[iEntry - 1].PageNumber.ToString(); To display the page number of the bookmark in the table of contents To write the code in Visual Basic 1. 2. 3. At the top left of the code view for the report, click the drop-down arrow and select (YourReportName Events). At the top right of the code window, click the drop-down arrow and select FetchData. This creates an event-handling method for the report's FetchData event. Add code to the handler to retrieve information to populate the report fields.
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the FetchData event. If iEntry > pBM.Count - 1 Then eArgs.EOF = True Else eArgs.EOF = False iEntry += 1 End If To write the code in C# 1. 2. 3. 4. Back in design view, click in the gray area below the report to select it. Click the events icon in the Properties window to display available events for the report. Double-click FetchData. This creates an event-handling method for the report's FetchData event. Add code to the handler to retrieve information to populate the report fields.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the FetchData event. if (iEntry > pBM.Count - 1) { eArgs.EOF = true; } else {
Add Annotations
You or your users can add notes, special instructions, even images, directly to the ActiveReport, making team collaboration, feedback, and support an easier task. Annotations are added in two ways: via the viewer's toolbar, or in code. Annotations added via the viewer's toolbar are temporary. They reside on the Page object in which they are placed, and are destroyed when the report closes. In order to save annotations you must save the report data and accompanying annotations to RDF format. Each annotation type allows you to change the colors, transparency, border, font, and alignment, plus other properties specific to the type of annotation. Available annotations include:
AnnotationText A rectangular box in which you can enter text. AnnotationCircle A circle without text. You can change the shape to an oval. AnnotationRectangle A rectangular box without text. AnnotationArrow A 2D arrow in which you can enter text. You can change the arrow direction. AnnotationBalloon A balloon caption in which you can enter text. You can point the balloon's tail in any direction. AnnotationLine A line with text above or below it. You can add arrow caps to one or both ends and select different dash styles. AnnotationImage A rectangle with a background image and text. You can select an image and its position, and place text on the image.
2. 3.
Click the annotation you want to add and drag it onto the report. Drag the corners to resize the annotation as needed, or drag the center to relocate it.
2.
In the Annotation Properties window that appears, add text, change the alignment, set colors, and use any other special properties to make the annotation appear the way you want it.
To save annotations
You can save annotations along with report data into an RDF file. The following example shows how to add a Save Annotated Report button to the viewer. 1. 2. From the Visual Studio toolbox, drag a Button control onto the viewer. Set the Text property of the button to Save Annotated Report.
Export Reports
To export your reports to the various formats that ActiveReports supports, you must first add the export controls to your Visual Studio toolbox. For more information, see the Adding ActiveReports Controls topic. Here are the export formats that are included with ActiveReports:
HTML For displaying in Web browsers or e-mail. PDF For preserving formatting on different computers. RTF For preserving some formatting, but allowing reports to be opened with Word or WordPad. Text For transmitting raw data, with little or no formatting. TIFF For transmitting faxes. XLS For spreadsheets.
To export a report
1. 2. 3. From the Visual Studio toolbox, drag the export filter that you want to use onto your Windows form. The control appears in the component tray below the form. Double-click in the title bar of the form to create an event-handling method for the form Load event. Add code to the event to run the report and export it.
The following examples show what the code for the method looks like for each of the export types. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form Load event. Dim rpt As New NewActiveReport1() rpt.Run() Me.HtmlExport1.Export(rpt.Document, Application.StartupPath + "\\HTMLExpt.html") Me.PdfExport1.Export(rpt.Document, Application.StartupPath + "\\PDFExpt.pdf") Me.RtfExport1.Export(rpt.Document, Application.StartupPath + "\\RTFExpt.rtf") Me.TextExport1.Export(rpt.Document, Application.StartupPath + "\\TextExpt.txt") Me.TiffExport1.Export(rpt.Document, Application.StartupPath + "\\TIFFExpt.tiff") Me.XlsExport1.Export(rpt.Document, Application.StartupPath + "\\XLSExpt.xls") To write the code in C# C# code. Paste INSIDE the Form Load event. NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); this.htmlExport1.Export(rpt.Document, Application.StartupPath + "\\HTMLExpt.html"); this.pdfExport1.Export(rpt.Document, Application.StartupPath + "\\PDFExpt.pdf"); this.rtfExport1.Export(rpt.Document, Application.StartupPath + "\\RTFExpt.rtf"); this.textExport1.Export(rpt.Document, Application.StartupPath + "\\TextExpt.txt"); this.tiffExport1.Export(rpt.Document, Application.StartupPath + "\\TIFFExpt.tiff"); this.xlsExport1.Export(rpt.Document, Application.StartupPath + "\\XLSExpt.xls");
The following code samples assume that you have a report variable rpt, and that you have dragged the PDFExport object onto your form.
Me.PdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.In ' Set certificate & password. Me.PdfExport1.Signature.Certificate = New Security.Cryptography.X509Certificates.X509Certificate2(Applic ' Signature items. Me.PdfExport1.Signature.Reason = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField( Me.PdfExport1.Signature.Location = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField( Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\VisibilityType_Invisible.pdf") To write the code in C# C# code. Paste INSIDE the Form Load event. String path = Path.Combine(Application.StartupPath, "\..\..\certificate.pfx");
String output = output.pdf; // Set certificate & password. this.pdfExport1.Signature.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificat // Signature items. this.pdfExport1.Signature.Reason = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField < this.pdfExport1.Signature.Location = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField < this.pdfExport1.Export(rpt.Document, output);
' Text signature. Me.PdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.Te Me.PdfExport1.Signature.Stamp.Bounds = New RectangleF(1, 1, 4, 2) Me.PdfExport1.Signature.Stamp.TextAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Le
' Signature items. Me.PdfExport1.Signature.SignDate = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of D Me.PdfExport1.Signature.Contact = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of St Me.PdfExport1.Signature.Reason = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of Str Me.PdfExport1.Signature.Location = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of S ' Time stamp. Me.PdfExport1.Signature.TimeStamp = New DataDynamics.ActiveReports.Export.Pdf.Signing.TimeStamp(" Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\TimeStamped.pdf") To write the code in C# C# code. Paste INSIDE the Form Load event.
// Text signature. this.pdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType. this.pdfExport1.Signature.Stamp.Bounds = new RectangleF(1, 2, 5, 2); this.pdfExport1.Signature.Stamp.TextAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.
// Signature items. this.pdfExport1.Signature.SignDate = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<Sy this.pdfExport1.Signature.Contact = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<Str this.pdfExport1.Signature.Reason = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<Stri this.pdfExport1.Signature.Location = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<St // Time stamp. this.pdfExport1.Signature.TimeStamp = new DataDynamics.ActiveReports.Export.Pdf.Signing.TimeStamp(" this.pdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\TimeStamped.pdf");
' ImageText signature. Me.PdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.Im ' Bounds (Container of Text & Image). Me.PdfExport1.Signature.Stamp.Bounds = New RectangleF(2, 1, 5, 1)
' Text area. Me.PdfExport1.Signature.Stamp.TextAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Le Me.PdfExport1.Signature.Stamp.Font = New Font(System.Drawing.FontFamily.GenericSansSerif, 8, FontStyle.R ' Note: Specify (x, y) in relative coordinate from Bounds top-left. Me.PdfExport1.Signature.Stamp.TextRectangle = New RectangleF(2, 0, 3, 1)
' Image area. Me.PdfExport1.Signature.Stamp.Image = Image.FromFile(Application.StartupPath & "\..\..\image\stamp.bmp") Me.PdfExport1.Signature.Stamp.ImageAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.C ' Note: Specify (x, y) in relative coordinate from Bounds top-left. Me.PdfExport1.Signature.Stamp.ImageRectangle = New RectangleF(0, 0, 2, 1)
' Set certificate & password. Me.PdfExport1.Signature.Certificate = New Security.Cryptography.X509Certificates.X509Certificate2(Applic ' Signature items. Me.PdfExport1.Signature.SignDate = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField( Me.PdfExport1.Signature.Contact = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField( Me.PdfExport1.Signature.Reason = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField( Me.PdfExport1.Signature.Location = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField( Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\TextAndGraphics.pdf") To write the code in C# C# code. Paste INSIDE the Form Load event.
// ImageText signature. this.pdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType. // Bounds (Container of Text & Image). this.pdfExport1.Signature.Stamp.Bounds = new RectangleF(2, 1, 5, 1);
// Text area. this.pdfExport1.Signature.Stamp.TextAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment. this.pdfExport1.Signature.Stamp.Font = new Font("Comic Sans MS", 8, FontStyle.Regular); // Note: Specify (x, y) in relative coordinate from Bounds top-left. this.pdfExport1.Signature.Stamp.TextRectangle = new RectangleF(2, 0, 3, 1);
// Image area. this.pdfExport1.Signature.Stamp.Image = Image.FromFile("stamp.bmp"); this.pdfExport1.Signature.Stamp.ImageAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment // Note: Specify (x, y) in relative coordinate from Bounds top-left. this.pdfExport1.Signature.Stamp.ImageRectangle = new RectangleF(0, 0, 2, 1);
// Set certificate & password. this.pdfExport1.Signature.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificat //Signature items. this.pdfExport1.Signature.SignDate = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField< this.pdfExport1.Signature.Contact = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<st this.pdfExport1.Signature.Reason = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField< this.pdfExport1.Signature.Location = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField< this.pdfExport1.Export(rpt.Document, "c:\\TextAndGraphics.pdf");
' Image signature. Me.PdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.Im Me.PdfExport1.Signature.Stamp.Image = Image.FromFile(Application.StartupPath & "\..\..\image\stamp.bmp") Me.PdfExport1.Signature.Stamp.Bounds = New RectangleF(1, 2, 4, 1) Me.PdfExport1.Signature.Stamp.ImageAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.L
' Set certificate & password. Me.PdfExport1.Signature.Certificate = New Security.Cryptography.X509Certificates.X509Certificate2(Applic Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\VisibilityType_Image.pdf")
// Image signature. this.pdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType. this.pdfExport1.Signature.Stamp.Image = Image.FromFile("c:\\stamp.bmp"); this.pdfExport1.Signature.Stamp.Bounds = new RectangleF(1, 2, 4, 1); this.pdfExport1.Signature.Stamp.ImageAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment
Me.PdfExport1.Signature.Certificate = New System.Security.Cryptography.X509Certificates.X509Certificate2 Me.PdfExport1.Signature.CertificationLevel = DataDynamics.ActiveReports.Export.Pdf.Signing.Certification Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\Certified_FormFilling.pdf") To write the code in C# C# code. Paste INSIDE the Form Load event.
Multiple Copies
To set multiple copies in the print dialog 1. With a report displayed in the viewer, click Print.
2.
In the Print dialog that appears, next to Number of copies, select the number of copies that you want to print. To use code to set multiple copies
1. 2.
Double-click in the gray section below the report to create an event-handling method for the report's ReportStart event. Add code to the handler to set multiple copies of the report for printing.
The following example shows what the code for the method looks like for printing five copies. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the ReportStart event. Me.Document.Printer.PrinterSettings.Copies = 5 Visual Basic.NET code. Paste INSIDE the ReportEnd event. Me.Document.Print(false, false) To write the code in C# C# code. Paste INSIDE the ReportStart event. this.Document.Printer.PrinterSettings.Copies = 5; C# code. Paste INSIDE the ReportEnd event. this.Document.Print(false, false);
Printer Settings
At design time, you can set paper size, orientation, collation, duplexing or paper source on the Printer Settings tab of the Report Settings window. To open the Report Settings window 1. 2. 3. Open an ActiveReport. Click on any section of the report to select it so that the Report menu appears. Drop down the Report menu and select Settings.
4.
Duplex
To set duplexing in Printer Settings 1. 2. Open the Report Settings window and select Printer Settings . Next to Duplex, select one of the following options:
Printer Default: The report uses 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.
3.
Orientation
To change page orientation in Printer Settings 1. Open the Report Settings window and select Printer Settings .
The following example shows what the code for the method looks like. This code assumes that your report has the following fields:
Visual Basic.NET code. Paste INSIDE the Detail Format event. If Me.txtReorderLevel.Value = 0 And Me.txtDiscontinued.Value = False Then Me.Detail1.Visible = True Me.txtDiscontinued.Text = "" Me.txtReorderLevel.Text = "Need to Reorder" Me.txtReorderLevel.ForeColor = System.Drawing.Color.DarkRed Else Me.Detail.Visible = False End If
2.
In the Report Settings window that appears, click the Styles button to view the style settings.
3.
By default, ActiveReports has six predefined styles: Normal, Heading1, Heading2, Heading3, DetailRecord, and ReportTitle. Click each of these styles in the list to modify them using the fields to the right, or click the New button to create a new style. To save your styles to an external XML *.reportstyle file, click the Export styles to file button. In the Save As dialog that appears, navigate to the location in which you want to save the style sheet, provide a name for the file, and click the Save button. Back on the Report Settings window, click the OK button to close the window and save the styles in the current report. To import an external style sheet at design time
4. 5. 6.
1. 2. 3. 4.
With an ActiveReport open and selected in Visual Studio, drop down the Report menu and select Settings. In the Report Settings window that appears, click the Styles icon to view the style settings. Click the Import styles from file button. A message box warns that current styles will be deleted. Click Yes to continue. In the Open dialog that appears, navigate to the *.reportstyle file that you want to use and click the Open button. To apply an external style sheet at run time
To make a style sheet available at run time, double-click the grey area of the report to create an eventhandling method for the ReportStart event of the report. Add code inside the handler to make the style style sheet available to the report.
3.
Or in the Properties Window, drop down the ClassName field and select the style to apply.
4.
When you run the report, ActiveReports applies the default style values for the selected style, or the style values contained in the specified external style sheet. To apply styles to controls at run time
You can apply styles to four types of ActiveReports controls: CheckBox, Label, TextBox, and ReportInfo. To apply a style at run time, double-click the section of the report containing the control to create an eventhandling method for the Format event of the section. Add code inside the handler to apply the style to the control.
Add Bookmarks
ActiveReports can display bookmarks and nested bookmarks in the viewer's table of contents for fields, groups, subreports. You can also add special bookmarks at run time.
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Detail Format event. Me.Detail1.AddBookmark(txtProductName1.text) To write the code in C# C# code. Paste INSIDE the Detail Format event. detail.AddBookmark(txtProductName1.Text);
The following example shows what the code to set up leveled or nested Bookmarks looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Detail Format event. Me.Detail1.AddBookmark(txtCategoryName.Text + "\" + txtProductName.Text) To write the code in C# C# code. Paste INSIDE the Detail Format event. detail.AddBookmark(txtCategoryName.Text + "\\" + txtProductName.Text);
The following example shows what the code for the detail section looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Detail Format event. Me.Detail1.AddBookmark(txtCountry1.Text + "\" + txtCity1.Text + "\" + txtCompanyName1.Text) To write the code in C# C# code. Paste INSIDE the Detail Format event. this.detail.AddBookmark(txtCountry1.Text + "\\" + txtCity1.Text + "\\" + txtCompanyName1.Text);
The following example shows what the code for the group header looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Group Header Format event. Me.GroupHeader1.AddBookmark(txtCountry1.Text) To write the code in C# C# code. Paste INSIDE the Group Header Format event. this.groupHeader1.AddBookmark(txtCountry1.Text);
The following example shows what the code for the method looks like for the main report. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Detail Format event of the main report. Me.Detail1.AddBookmark( txtCategoryName1.Text) To write the code in C# C# code. Paste INSIDE the Detail Format event of the main report. detail1.AddBookmark(txtEmployeeID1.Text); 1. 2. Double-click in the Detail section of the subreport to create an event-handling method for the report's Detail Format event. Add code to the handler to create a bookmark for each instance of the CategoryName field in the subreport.
The following example shows what the code for the method looks like for the subreport. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Detail Format event of the subreport. Me.Detail1.AddBookmark(CType(Me.ParentReport.Sections("Detail1").Controls("txtCategoryName1"), TextBox).Text + "\" + Me. txtProductName.Text) To write the code in C# C# code. Paste INSIDE the Detail Format event of the subreport. this.detail1.AddBookmark(((TextBox)(this.ParentReport.Sections["ghEmployees"].Controls ["txtEmployeeID1"])).Text + "\\" + this.txtCompanyName1.Text);
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the ReportEnd event. Me.Document.Pages(0).AddBookmark("New Bookmark", 1) To write the code in C# 1. 2. 3. 4. Click in the gray area below the report to select it. Click the events icon in the Properties Window to display available events for the report. Double-click ReportEnd. This creates an event-handling method for the ReportEnd event. Add code to the handler to add a bookmark.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the ReportEnd event. this.Document.Pages[0].AddBookmark("New Bookmark", 1);
The following example shows what the code for the Add() method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste JUST ABOVE the Form Load event. Dim i As Integer Visual Basic.NET code. Paste INSIDE the Form Load event. Dim rpt As New rptOne() rpt.Run() Viewer1.Document = rpt.Document 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 To write the code in C# C# code. Paste JUST ABOVE the Form Load event. int i; C# code. Paste INSIDE the Form Load event. rptOne rpt1 = new rptOne(); rpt1.Run(); Viewer1.Document = rpt.Document rptTwo rpt2 = new rptTwo(); rpt2.Run(); for(i = 0; i < rpt2.Document.Pages.Count; i++) { rpt1.Document.Pages.Add(rpt2.Document.Pages[i]); }
The following example shows what the code for the AddRange() method looks like. To write the code in Visual Basic.NET
The following example shows what the code for the Insert method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form Load event. Dim rpt As New rptInsertPage() Viewer1.Document = rpt.Document rpt.Run() Dim rpt2 As New rptCoverPage() rpt2.Run() rpt.Document.Pages.Insert(1, rpt2.Document.Pages(0)) To write the code in C# C# code. Paste INSIDE the Form Load event. rptInsertPage rpt = new rptInsertPage(); viewer1.Document = rpt.Document; rpt.Run(); rptCoverPage rpt2 = new rptCoverPage(); rpt2.Run(); rpt.Document.Pages.Insert(1, rpt2.Document.Pages[0]);
The following example shows what the code for the InsertNew() method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form Load event. Dim rpt As New rptInsertPage() rpt.Run() rpt.Document.Pages.InsertNew(3) Viewer1.Document = rpt.Document
Create Charts
The ActiveReports ChartControl offers 45 chart types which, along with many other properties, allow you to create virtually any type of chart that you can conceive. The fastest way to create a chart is to use the Chart Wizard. Note: If your Chart Wizard does not appear when you add a ChartControl to a report, see Access the Chart Wizard and Data Source for information.
3.
Select the type of chart that you want to create. You can scroll to the right to view more charts, or select the 2D tab. You can also drop down the Chart Group field to limit the chart types displayed to Area, Bar, Financial, Line, Pie/Doughnut, or Point/Bubble. Some of the chart types are available only as 2D charts. Still on the Chart Type tab, you can further configure the chart by selecting the Swap Axes checkbox. If you are using a 3D chart, you can also change the projection and light settings. To do so, click the arrow to drop down the window for each item. When you have the chart type configured the way you want it, click the Next button to move on to the Appearance page.
4.
5.
Appearance page
1. The Appearance page has two tabs: one allows you to select a color scheme, and the other allows you to select individual elements of the chart preview and select appearance settings for them.
2. 3.
Select a palette to set the color scheme, then click the Appearance tab. Click the different areas of the preview chart, such as the title, footer, legend, legend title, backdrop, and the chart itself. Each reveals a different set of properties that you can use to control the appearance of the element. When you finish with the appearance settings, click the Next button to move on to the Series page.
4.
Series page
1. The Series page has two tabs: one allows you to set the data source for the chart and bind data fields to
2. 3. 4. 5. 6. 7.
Next to Data Source, click the ellipsis button to open the Chart Data Source dialog. On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to your database or the sample Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter a SQL query to select the data that you want. Tip: A commonly used SQL Query for charts on the Nwind.mdb sample database is: SQL Query. Paste in the Query textbox. SELECT ShipCountry, SUM(Freight) AS FreightSum FROM Orders GROUP BY ShipCountry
Click OK to save the data source and return to the Chart Wizard. Select Series1 in the list of series, and set its name and chart type in the fields to the right. Drop down the fields in the Data Binding section to select X and Y values. The X value takes a string field, while the Y value takes a numeric field. If you do not need more than one series, delete Series2 and Series3. Click the Data Points tab to view the bound data or change the values. When you finish setting up the data series for the chart, click the Next button to go to the Titles page.
Titles page
1. There is only one tab on the Titles page. Select the header or footer in the list, and change its properties in the fields below.
2. 3.
If you do not want to include a title, either delete it or clear the Visible checkbox. Otherwise, set the title text and increase the font size, and click the Next button to go to the Axes page.
Axes page
1. The Axes page has two tabs: one for Axis X and one for Axis Y.
2. 3. 4.
On the Axis X tab, enter a title for the axis, and set the font size and other font properties. Select the check boxes next to any of the properties that you want to apply to the X axis. Enter or select a label format. Tip: The ActiveReports chart control uses standard Visual Studio .NET formatting syntax. The format is {Tag : Format}. For example, {Value:C} formats the text as currency. {Value:D} formats the text as a date. When you have set up Axis X, click the Axis Y tab to set its properties. When you have finished, click the Next button to go to the Legend page.
5. 6.
Legend page
1. There is only one tab on the Legend page. Use it to set up the appearance of the legend.
2. 3. 4. 5. 6. 7.
If you do not want to display a legend for the chart, clear the Visible check box. Otherwise, set font properties for the labels in the Labels section. Enter text to display in the legend header and footer, and set font properties on the text in the Header and Footer section. In the Position section, select the position relative to the chart in which to display the legend. You can also select the Legend inside check box to place the legend inside the chart. In the Grid Layout section, select the layout for the legend items. When you have finished, click the Finish button to save the changes and close the Chart Wizard.
To access verbs in the Properties window if they are not displayed by default
1. 2. Right-click anywhere in the Properties window. Select Commands so that it becomes checked.
3.
The verbs display at the bottom of the Properties window. You may need to resize the verb area in order to see all six of them.
Here is a table describing each of the six verbs. Verb Clear Chart Usage Clears all data, including default data, from the chart. Click the OK button to clear the chart, or click Cancel. Window
Load...
Loads a chart previously saved to XML format. In the Open window that appears, navigate to the XML file, select it, and click the Open button to load the saved chart into the current chart control.
Save As...
Saves all data from a chart into XML format. In the Save As window that appears, navigate to the directory in which you want to save the XML file, enter a File Name, and click the Save button to save the current chart's settings to XML format. Saved charts can be loaded into chart controls on other reports.
Opens the Chart Designer window, where you Customize... can change settings on the chart areas, titles, series, legends, and appearance of the chart.
Wizard...
Opens the Chart Wizard, which takes you through the basic steps of creating a chart.
Data Source...
Opens the Chart Data Source window, from which you can connect the chart to any data source.
Rancho grande Ocano Atlntico Ltda. Cactus Comidas para llevar Piccolo und mehr Ernst Handel Suprmes dlices Maison Dewey Familia Arquibaldo Wellington Improtadora Que Delcia Tradio Hipermercados Ricardo Adocicados Hanari Carnes Queen Cozinha Comrcio Mineiro Gourmet Lanchonetes
Austria
Belgium
Brazil
Dim streamHTML As New System.IO.FileStream(System.Windows.Forms.Application.StartupPath + "\sample.HTML" Me.RichTextBox1.Load(streamHTML, RichTextType.Html) To write the code in C# C# code. Paste INSIDE the Detail Format event. System.IO.FileStream streamHTML = new System.IO.FileStream(System.Windows.Forms.Application.StartupPath this.RextTextBox1.Load(streamHTML, RichTextType.Html);
4.
Select all four textboxes, and in the Properties window, change the Visible property to False.
The following examples show what the code for the function looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the report class.
Private Function AddNodeToTreeView(ByVal colNodes As TreeNodeCollection, ByVal sText As String) As TreeN Dim objTreeNode As TreeNode objTreeNode = New TreeNode(sText) colNodes.Add(objTreeNode) Return objTreeNode End Function To write the code in C# C# code. Paste INSIDE the report class. private TreeNode AddNodeToTreeView(TreeNodeCollection colNodes, string sText) { TreeNode objTreeNode; objTreeNode = new TreeNode(sText); colNodes.Add(objTreeNode); return objTreeNode; }
The following example shows what the code for the method looks like.
Label
3.
Click in the grey area below the report to select it, and in the Properties window, set the MasterReport property to True. Important: Do not set the MasterReport property to True until you have finished making changes to the report. Setting this property to True triggers major changes in the designer file for the report.
4.
The detail section of the report is disabled. When you create reports that inherit from this class, they will provide the detail section.
5. 6.
Add a second ActiveReport to your project and name the file rptLetter. This report will inherit its PageHeader and PageFooter sections from rptLetterhead. In the Solution Explorer tool strip, click the Show All Files button.
7.
Expand the rptLetter node and double-click to open the rptLetter.Designer file.
10.
Add data and controls to the detail section of the report as you would any other report. See the Basic Data Bound Reports walkthrough for more information. Caution: Base reports and the reports that inherit from them cannot contain controls with duplicate names. You can compile and run your project with duplicate control names, but you cannot save the layout until the duplicate names are changed.
Add Parameters
There are several ways to use parameters in ActiveReports
2. 3.
Once you add a parameter to the Report Explorer, you can set it up in the Properties window. You can pass the parameter to a field on the report, or access it programmatically.
2. 3. 4. 5. 6.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to your database or the sample Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter a SQL query like the one below, which contains parameter syntax that ActiveReports uses to generate the following dialog. SQL Query. Paste in the Report Data Source window's Query box. SELECT * FROM Products INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID WHERE Products.SupplierID = <%SupplierID|Enter Supplier ID|1000%> AND OrderDate = #<%OrderDate|Order date|1/1/2001|D%># AND Discount = <%Discount|Is this checked?|true|B%>
7.
Click OK to save the data source and return to the report design surface.
The SQL query above causes ActiveReports to display the following dialog to the user. The user can accept these or input other values to select report data.
Each of these parameters follow the syntactical pattern <%FieldName | PromptString | DefaultValue | Type | PromptUser%> FieldName The name of the field you wish to request (e.g. SupplierID or OrderDate). This is the only part of the syntax which is required, so you can use <%FieldName%> if you do not wish to use the other values. Note: Although FieldName is the only required parameter, if you do not specify a DefaultValue for each parameter, the Report Explorer is not populated with bound fields at design time. PromptString An optional string value which sets the text that appears in the dialog next to the control (e.g. "Enter Supplier ID: "). DefaultValue Sets a default value for the parameter. For example, if you have a date parameter, you can set the DefaultValue for the field to the current date so users can just hit ENTER unless they want to generate a report based on a new date. If you do not supply this value, the Report Explorer is not populated with bound fields at design time. Type Indicates the type of data requested. The possible values S for string, D for date, and B for Boolean. If you do not provide a value, string is assumed. A string type provides a textbox for input, a date type provides a calendar drop-down control for input, and a Boolean type provides a check box for input. PromptUser Sets whether to prompt the user for a value. The value can be set to True for some parameters and False for others. If you set the report's ShowParameterUI property to False, users are not prompted for any parameters, regardless of the PromptUser value set for any parameter in the report. Tip : For Strings, if you specify a default value that is enclosed in apostrophes or quotation marks, ActiveReports sends the same marks to SQL. For Boolean parameters, if you specify true/false for the DefaultValue it generates true/false for SQL output. If you specify 0,1, it generates 0 or 1. For date values, enclose the parameter syntax in pound signs, for example, #<%Date%># Stored Procedures You can use stored procedures with parameters in ActiveReports. The SQL query has the stored procedure call and placeholders for the parameters: CustOrderHist <%ID | Enter Customer ID | AFLKI%>. ActiveReports replaces the parameter with what the user types into the dialog to create a query like this: CustOrderHist 'AFLKI'.
Run-time Parameters
You can add, edit, and delete parameters at run time. The following code demonstrates how to add a parameter and display its value in an ActiveReports textbox control. To add parameters at run time in Visual Basic.NET 1. 2. Double-click in the gray area below the report to create an event-handling method for the ReportStart event. Add code to the handler to change the data source at run time.
Visual Basic.NET code. Paste INSIDE the ReportStart event. Dim myParam1 As New Parameter() myParam1.Key = "myParam1" myParam1.Type = Parameter.DataType.String myParam1.PromptUser = True 'set to False if you do not want input from user myParam1.Prompt = "Enter last name:" myParam1.DefaultValue = "This is myParam1 default value" Me.Parameters.Add(myParam1) 'Set textbox text equal to the value of the parameter Me.txtParam1.Text = Me.Parameters("myParam").Value To add parameters at run time in C# 1. 2. Double-click in the gray area below the report to create an event-handling method for the ReportStart event. Add code to the handler to change the data source at run time.
C# code. Paste INSIDE the ReportStart event. Parameter myParam1 = new Parameter(); myParam1.Key = "myParam1"; myParam1.Type = Parameter.DataType.String; myParam1.PromptUser = true; //set to false if you do not want input from user myParam1.Prompt = "Enter last name:"; this.Parameters.Add(myParam1); //Set textbox text equal to the value of the parameter this.txtParam1.Text = this.Parameters["myParam"].Value;
Set the subreport's ShowParametersUI property to False. Set the subreport's SQL query to use the parameter syntax = <%fieldname%>.
Both report queries must contain the same field (so the main report must have a categoryID field and the subreport also must have a categoryID field.
Parameters in Charts
To set a parameter in a chart data source Caution: If you don't set the same ORDER in both SQL queries, that of the report and that of the chart, the chart data is not ordered. 1. With the chart control highlighted, click the Data Source verb below the Properties Window to open the Chart DataSource dialog. If you do not see the verb, see the Access the Chart Wizard and Data Source topic for more information.
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste JUST ABOVE the ReportStart event. Dim rpt As rptYourChildReportName Visual Basic.NET code. Paste INSIDE the ReportStart event. rpt = New rptYourChildReportName() To write the code in C# 1. 2. 3. 4. Click in the gray area below the parent report to select it. Click 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 create a new instance of the child report.
The following example shows what the code for the method looks like. C# code. Paste JUST ABOVE the ReportStart event. rptCustomers rpt = rptYourChildReportName(); C# code. Paste INSIDE the ReportStart event. rpt = new rptYourChildReportName();
To add code to display the child report in a subreport control on a parent report
1. 2. Double-click in the detail section of the design surface of the parent report to create a detail_Format event. Add code to the handler to display a report in the subreport control. To write the code in Visual Basic The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the Format event. Me.SubReport1.Report = rpt To write the code in C# The following example shows what the code for the method looks like. C# code. Paste INSIDE the Format event. this.subReport1.Report = rpt;
2. 3. 4. 5. 6.
On the "OLE DB" tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query SQL Query
SELECT Employees.EmployeeID, Employees.LastName, Employees.FirstName, Employees.Extension, Customers. FROM Customers, Employees ORDER BY Employees.EmployeeID, Customers.CustomerID 7. Click OK to save the data source and return to the report design surface. Note: This query joins the Employees table for the parent report to the Customers table for the child report.
2. 3. 4. 5. 6.
On the "OLE DB" tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query SQL Query SELECT Customers.*, Employees.EmployeeID, Orders.OrderID FROM Employees INNER JOIN (Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) ON Employees.EmployeeID = Orders.EmployeeID WHERE CustomerID = '<%CustomerID%>'
7.
Click OK to save the data source and return to the report design surface. Note: This SQL query uses parameters syntax: '<%CustomerID%>'. For more information on parameters, see the Parameters topic.
To display the child report in the subreport control on the parent report, see the Embed Subreports in a Report topic.
The following examples show what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form Load event. Dim strm As New System.IO.MemoryStream() Dim rpt As New rptMemoryStream() 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) To write the code in C#
2. 3.
Name the file and select the location in which to save it. The file extension is *.rpx. Click the Save button to save the report layout. Note: When you save a layout that contains a dataset, ActiveReports saves the data adapter and data connection in the component tray, but not the dataset itself. When the saved layout is loaded into another report, you can regenerate the dataset with the data adapter and data connection.
2. 3.
Navigate to the RPX file that you want to load and select it. Click the Open button to load the report layout.
The following examples show what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form class.
The following examples show what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form class. Dim rpt As New DataDynamics.ActiveReports.ActiveReport() Private Sub LoadRPX() rpt.LoadLayout("C:\NewRPX.RPX") Viewer1.Document = rpt.Document rpt.Run() End Sub To write the code in C# C# code. Paste INSIDE the Form class. private void LoadRPX() { DataDynamics.ActiveReports.ActiveReport rpt = new DataDynamics.ActiveReports.ActiveReport(); rpt.LoadLayout(@"C:\NewRPX.rpx"); viewer1.Document = rpt.Document; rpt.Run(); }
You can use scripting to provide VB.NET or C# functionality to reports without compiling .vb or .cs files. This permits reports saved to report RPX format to serve as stand-alone reports. By including scripting when you save the report as an RPX file, you can later load, run, and display it in the viewer control without the designer. This allows you to update distributed reports without recompiling. You can use Visual Basic or C# script. ActiveReports loads RPX files, including any scripting, in the InitializeComponent() method. You can add script to the script editor at design time, or use the rpt.Script property to add it at run time and save it to the RPX file. Since the RPX file can be read with any text editor, use the AddCode or AddNamedItem method to add secure information, such as a connection string, to a project. Note: The ActiveReports script editor supports IntelliSense that helps the writing of code by making the access to the language elements fast and easy.
Make sure the report class is public. If the report class is not set to public, the script will not be able to recognize the items in your report. The report class is public by default. Make sure the control being referenced in the script has its Modifiers property set to Public. If the control's Modifiers property is not set to Public, the control cannot be referenced in script and an error will be raised when the report is run. The Modifiers property has a default value of Private, so you must set this property in the designer. Use "this" (as in C# code-behind) or "Me" (as in VB code-behind) to reference the report. Using "rpt" to reference the report is also possible but it is recommended to use the "this" and "Me" keywords. Use error handling. When working with scripting, use error handling around the .Run() call. When errors are raised, the returned error should point to the section of script causing the error. Remember to save the layout after you make changes to the report. It is easy to forget to save the layout after you have made changes to the report in the designer or script editor.
Object Drop down the list and select one of the report sections, or the report itself. Event If you select a report section as the Object, there are three events: Format, BeforePrint, and AfterPrint. For more information, see the Section Events topic. If you select ActiveReport as the Object, there are seven events. For more information, see the Report Events topic. Select an event to create an event handling method in the scripting language you chose for the report.
Add script to the events in the same way that you add code to events in the code view of the report.
Me.TextBox1.Text = "Hello"
Visual Basic.NET script. On the Script tab of the report, paste INSIDE the Detail Format event. CType(rpt.Sections("Detail1").Controls("TextBox1"), TextBox).Text = "Hello" To access a textbox in the detail section in C# script C# script. On the Script tab of the report, paste INSIDE the Detail Format event.
this.TextBox1.Text = "Hello";
C# script. On the Script tab of the report, paste INSIDE the Detail Format event. ((TextBox)rpt.Sections["detail1"].Controls["TextBox1"]).Text = "Hello";
To access namespaces
Use the AddScriptReference method to gain access to .NET or other namespaces. This is only necessary if you need a reference, such as System.Data.dll, that is not initialized in the project before the script runs. To access a namespace in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form code. Private Sub runReport() Dim rpt as new ActiveReport1() rpt.AddScriptReference("System.Data.dll") rpt.Run() Me.Viewer1.Document = rpt.Document End Sub To access a namespace in C# C# code. Paste INSIDE the Form code. private void runReport() { ActiveReport1 rpt = new ActiveReport1(); rpt.AddScriptReference("System.Data.dll"); rpt.Run(); this.viewer1.Document = rpt.Document; }
Public Function addThisCode() As String Dim sCode As String = "Public Function ShowACMessage() As String" + Environment.NewLine + "ShowACMess addThisCode = sCode End Function VB.NET script. Paste INSIDE the ReportStart event. rpt.AddCode(addThisCode) To add code in C# C# code. Paste INSIDE the report class. public string addThisCode()
Copy the ActiveRepors.FlashViewer.swf file into your project folder. This file is located in: C:\Program Files\GrapeCity\ActiveReports 6\Deployment.
5.
Run the project to see the report print with no user interaction.
Dim menuStrip As ToolStrip = Me.Designer1.CreateToolStrips(DataDynamics.ActiveReports.Design. Dim editStrip As ToolStrip = Me.Designer1.CreateToolStrips(DataDynamics.ActiveReports.Design. Dim formatStrip As ToolStrip = Me.Designer1.CreateToolStrips(DataDynamics.ActiveReports.Desig Dim layoutStrip As ToolStrip = Me.Designer1.CreateToolStrips(DataDynamics.ActiveReports.Desig Dim reportStrip As ToolStrip = Me.Designer1.CreateToolStrips(DataDynamics.ActiveReports.Desig Dim undoStrip As ToolStrip = Me.Designer1.CreateToolStrips(DataDynamics.ActiveReports.Design. Dim zoomStrip As ToolStrip = Me.Designer1.CreateToolStrips(DataDynamics.ActiveReports.Design. Me.ToolStripContainer1.TopToolStripPanel.Join(menuStrip, 0) Me.ToolStripContainer1.TopToolStripPanel.Join(editStrip, 1) Me.ToolStripContainer1.TopToolStripPanel.Join(formatStrip, 2) Me.ToolStripContainer1.TopToolStripPanel.Join(layoutStrip, 3) Me.ToolStripContainer1.TopToolStripPanel.Join(reportStrip, 4) Me.ToolStripContainer1.TopToolStripPanel.Join(undoStrip, 5) Me.ToolStripContainer1.TopToolStripPanel.Join(zoomStrip, 6) To write the code in C# C# code. Paste INSIDE the Load event.
ToolStrip menuStrip = this.designer1.CreateToolStrips(DataDynamics.ActiveReports.Design.D ToolStrip editStrip = this.designer1.CreateToolStrips(DataDynamics.ActiveReports.Design.D ToolStrip formatStrip = this.designer1.CreateToolStrips(DataDynamics.ActiveReports.Design ToolStrip layoutStrip = this.designer1.CreateToolStrips(DataDynamics.ActiveReports.Design ToolStrip reportStrip = this.designer1.CreateToolStrips(DataDynamics.ActiveReports.Design ToolStrip undoStrip = this.designer1.CreateToolStrips(DataDynamics.ActiveReports.Design.D ToolStrip zoomStrip = this.designer1.CreateToolStrips(DataDynamics.ActiveReports.Design.D this.toolStripContainer1.TopToolStripPanel.Join(menuStrip, 0); this.toolStripContainer1.TopToolStripPanel.Join(editStrip, 1); this.toolStripContainer1.TopToolStripPanel.Join(formatStrip, 2); this.toolStripContainer1.TopToolStripPanel.Join(layoutStrip, 3); this.toolStripContainer1.TopToolStripPanel.Join(reportStrip, 4); this.toolStripContainer1.TopToolStripPanel.Join(undoStrip, 5); this.toolStripContainer1.TopToolStripPanel.Join(zoomStrip, 6); 3. See the table below for the run-time results of adding each tool strip. ToolStrips at Run Time ToolStrip Name Run-Time
Menu
The File menu includes these commands: New, Open, Save, and Export. The Edit menu includes these commands: Undo, Redo, Cut, Copy, Paste, Delete, and Select All. Edit The Edit tool strip includes these tools: Cut, Copy, Paste, and Delete.
Format The Format tool strip includes these tools: Font Name, Font Size, Bold, Italic, Underline, Fore Color, Back Color, Align Left, Align Center, Align Right, Align Justify, Indent, and Outdent.
Layout The Layout tool strip includes these tools: Align to Grid, Align Lefts, Align Centers, Align Rights, Align Tops, Align Middles, Align Bottoms, Bring to Front, and Send to Back. Report The Report tool strip includes these tools: New, Open, and Save. Undo The Undo tool strip includes these tools: Undo and Redo. Zoom The Zoom tool strip includes these tools: Zoom Out, Zoom In, Zoom %, and Actual Size.
<httpHandlers> <!-- ********** ActiveReports HttpHandler Configuration ********** --> <add verb="*" path="*.rpx" type="DataDynamics.ActiveReports.Web.Handlers.RpxHandler, ActiveRepor <add verb="*" path="*.ActiveReport" type="DataDynamics.ActiveReports.Web.Handlers.CompiledReport <add verb="*" path="*.ArCacheItem" type="DataDynamics.ActiveReports.Web.Handlers.WebCacheAccessH </httpHandlers> 3. Update the Version and PublicKeyToken values to reflect the current version of ActiveReports installed on your machine. Tip: You can find the Version and PublicKeyToken values in the Global Assembly Cache (GAC), C:\WINDOWS\ASSEMBLY.
To add a link that passes a parameter to a report and opens it in HTML format
In order to pass a parameter to a report, you must first Add Parameters to the report. In this case, we are using a report with a Country parameter. Caution: Set your report's ShowParameterUI property to False to prevent the server from hanging while it tries to show the parameter dialog box. Tip: Remember to save your report layout to RPX format again after you make any changes. 1. In the HTML view of the Web Form, add a hyperlink like the following. Hyperlink HTML HTML code. Paste in the HTML view of the Web Form. <a href="rptYourReportName.rpx?Country=USA">Customer Phone List for USA</a> 2. 3. Press F5 to run the program. Click the link on the web form to show the report in its default HTML format.
3. 4. 5. 6. 7.
In the Properties window, set the Dock property to Fill. From the Project menu, select Add New Item . Select ActiveReports 6 File and click the Add button. Double-click in the title bar of the form to create a Form Load event. Add the following code to run the report and display the resulting document in the viewer. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form Load event. Dim rpt as new NewActiveReport1 rpt.Run() Viewer1.Document = rpt.Document To write the code in C# C# code. Paste INSIDE the Form Load event. ActiveReport1 rpt = new ActiveReport1(); rpt.Run(); viewer1.Document = rpt.Document;
8.
2.
When the viewer is split into two sections, report layouts can be examined and report pages can be compared easily.
Visual Basic.NET code. Paste INSIDE the Viewer ToolClick event. ' Capture the new tool's click to show the dialog If e.Tool.Id = 333 Then Dim dlg As New frmPrintDlg() dlg.ShowDialog(Me) End If To write the code in C# 1. 2. 3. 4. Click the viewer on the form to select it. Click the events icon in the Properties Window to display available events for the viewer. Double-click ToolClick. This creates an event-handling method for the viewer's ToolClick event. Add code to the handler to display frmPrintDlg when the custom print button is clicked.
C# code. Paste INSIDE the Viewer ToolClick event. // Capture the new tool's click to show the dialog if(e.Tool.Id == 333) { frmPrintDlg dlg = new frmPrintDlg(); dlg.ShowDialog(this); } 7. Press F5 to run the project and see the custom MyPrint button on the viewer.
Change strings in the resource files: 1. 2. 3. 4. Double-click the Viewer.zip file to open it. Extract all of the files to C:\Program Files\GrapeCity\ActiveReports 6\Localization. A Viewer subfolder is created. In the new Viewer folder's Res subfolder, open each of the three *.resx files and change the strings as needed. If you want to change any of the images, rename your localized images to the names of the ones in the Res\Resources subfolder and replace them with your localized images.
4.
Back in the main Localization folder, double-click the Viewer.bat file to run it. The NameCompleter.exe application runs, and creates:
A SatelliteAssembly folder inside the Viewer folder. A language subfolder with the same name as the culture you set in the Viewer.bat file inside the SatelliteAssemby folder. A localized ActiveReports.Viewer6.resources.dll file inside the language subfolder.
5.
Copy the language subfolder and paste it into the bin folder of your application. Note: If you want to put your localization in the Global Assembly Cache (GAC), you must first send the localized ActiveReports.Viewer6.resources.dll file to GrapeCity (mailto:support@datadynamics.com?subject=Need to have localized resource dll signed.) and get it signed. Then you can drag the language subfolder with the signed dll file into C:\WINDOWS\ASSEMBLY.
To test your localized application on a machine that does not share the culture of the localized dll
1. 2. Add the following code in the form's constructor just before the InitializeComponent method is called. Replace the "ja" in the example code with the culture specified in the Viewer.bat file. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the the form's constructor just before the InitializeComponent method. System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("ja") To write the code in C# C# code. Paste INSIDE the form's constructor just before the InitializeComponent method. System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ja");
Cultures
For your convenience, here is a list of predefined System.Globalization cultures. (Source: MSDN (http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx).) For ActiveReports localization purposes, use the Culture/Language Name value in the first column. Culture/Language Name Culture Identifier Culture "" (empty string) 0x007F Invariant culture af 0x0036 Afrikaans af-ZA 0x0436 Afrikaans (South Africa) sq 0x001C Albanian sq-AL 0x041C Albanian (Albania) ar 0x0001 Arabic ar-DZ 0x1401 Arabic (Algeria) ar-BH 0x3C01 Arabic (Bahrain) ar-EG 0x0C01 Arabic (Egypt) ar-IQ 0x0801 Arabic (Iraq) ar-JO 0x2C01 Arabic (Jordan) ar-KW 0x3401 Arabic (Kuwait) ar-LB 0x3001 Arabic (Lebanon) ar-LY 0x1001 Arabic (Libya) ar-MA 0x1801 Arabic (Morocco) ar-OM 0x2001 Arabic (Oman) ar-QA 0x4001 Arabic (Qatar) ar-SA 0x0401 Arabic (Saudi Arabia) ar-SY 0x2801 Arabic (Syria) ar-TN 0x1C01 Arabic (Tunisia) ar-AE 0x3801 Arabic (U.A.E.) ar-YE 0x2401 Arabic (Yemen) hy 0x002B Armenian hy-AM 0x042B Armenian (Armenia) az 0x002C Azeri az-Cyrl-AZ 0x082C Azeri (Azerbaijan, Cyrillic) az-Latn-AZ 0x042C Azeri (Azerbaijan, Latin) eu 0x002D Basque eu-ES 0x042D Basque (Basque) be 0x0023 Belarusian be -BY 0x0423 Belarusian (Belarus) bg 0x0002 Bulgarian bg-BG 0x0402 Bulgarian (Bulgaria) ca 0x0003 Catalan ca-ES 0x0403 Catalan (Catalan) zh-HK 0x0C04 Chinese (Hong Kong SAR, PRC) zh-MO 0x1404 Chinese (Macao SAR) zh-CN 0x0804 Chinese (PRC) zh-Hans 0x0004 Chinese (Simplified) zh-SG 0x1004 Chinese (Singapore) zh-TW 0x0404 Chinese (Taiwan) zh-Hant 0x7C04 Chinese (Traditional) hr 0x001A Croatian hr-HR 0x041A Croatian (Croatia) cs 0x0005 Czech cs-CZ 0x0405 Czech (Czech Republic) da 0x0006 Danish da -DK 0x0406 Danish (Denmark)
Change strings in the resource files: 1. 2. 3. 4. Double-click the *.zip file of the assembly that you want to localize to open it. Extract all of the files to C:\Program Files\GrapeCity\ActiveReports 6\Localization. A subfolder with the same name as the zip file is created. In the new folder's Res subfolder, open each of the *.resx files and change the strings as needed. If you want to change any of the images, rename your localized images to the names of the ones in the Res\Resources subfolder and replace them with your localized images.
4.
Back in the main Localization folder, double-click the *.bat file to run it. The NameCompleter.exe application runs, and creates:
A SatelliteAssembly folder inside the new folder. A language subfolder with the same name as the culture you set in the *.bat file inside the SatelliteAssemby folder. A localized ActiveReports.AssemblyName.resources.dll file inside the language subfolder.
5.
Copy the language subfolder and paste it into the bin folder of your application. Note: If you want to put your localization in the Global Assembly Cache (GAC), you must first send the localized ActiveReports.AssemblyName.resources.dll file to GrapeCity (mailto:support@datadynamics.com?subject=Need to have localized resource dll signed.) and get it signed. Then you can drag the language subfolder with the signed dll file into C:\WINDOWS\ASSEMBLY.
To test your localized application on a machine that does not share the culture of the localized dll
1. 2. Add the following code in the form's constructor just before the InitializeComponent method is called. Replace the "ja" in the example code with the culture specified in the *.bat file. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the the form's constructor just before the InitializeComponent method. System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("ja") To write the code in C# C# code. Paste INSIDE the form's constructor just before the InitializeComponent method. System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ja");
6.
In Solution Explorer, select the Installer project. In the Properties window, select the ProductName property and enter the name of your file.
The ProductName property determines the name that is displayed for the application in folder names and in the Add/Remove Programs dialog box.
3. 4. 5. 6.
From the Visual Studio Action menu, select Add, then Project Output. In the Add Project Output Group dialog that appears, choose your ActiveReports project name from the drop-down list. In the list, select Primary Output and click OK. This adds all of the existing assembly dependencies to your project. If you want to add other ActiveReports DLLs to the installer (e.g. if you use OleObjects on reports, you need to include the Interop.dll or Interop64.dll for 64-bit machines), in the Solution Explorer, right-click
Follow this guide to deploy ActiveReports Standard Edition Web projects to your Web server. For Web projects using the Professional Edition WebViewer, see Deploy Web Applications (Pro Edition). To deploy your ActiveReports Web projects, you must have access to the Microsoft .NET Framework version 2.0 or higher and the coordinating version of ASP.NET. You must also have access to Internet Information Services version 5.1 or 6.0, and you need administrative access to the server. For examples of how to create ActiveReports Web projects, see the walkthroughs linked at the bottom of this topic.
If you are saving files (i.e. PDF or RDF) to a folder on Windows XP or 2000 machines, the ASPNET user ID needs Write access to that folder. Windows 2003 is user configurable, so use the name assigned to the ASPNET user instead. If your application reads anything from any folder, assign Read access to it. If your reports run on any networked data source (i.e. SQL, Access, etc.) assign Read access to it. If you use CacheToDisk, assign IsolatedStorageFilePermission to it.
Change strings in the resource files: 1. 2. 3. 4. 5. Double-click the ARDesigner.zip file to open it. Extract all of the files to C:\Program Files\GrapeCity\ActiveReports 6\Localization. An ARDesigner subfolder is created. In the new ARDesigner folder's Res subfolder, open each of the resources.resx file and change the strings as needed. Drill down in each of the following subfolders and edit the *.resx files as needed: Designers, Dialogs, ReportExplorer, and ScriptEditor. If you want to change any of the images, rename your localized images to the names of the ones in the Res\Resources subfolder and replace them with your localized images.
4.
Back in the main Localization folder, double-click the ARDesigner.bat file to run it. The NameCompleter.exe application runs, and creates:
A SatelliteAssembly folder inside the ARDesigner folder. A language subfolder with the same name as the culture you set in the ARDesigner.bat file inside the SatelliteAssemby folder. A localized ActiveReports.ARDesigner.resources.dll file inside the language subfolder.
5.
Copy the language subfolder and paste it into the bin folder of your application. Note: If you want to put your localization in the Global Assembly Cache (GAC), you must first send the localized ActiveReports.ARDesigner.resources.dll file to GrapeCity (mailto:support@datadynamics.com?subject=Need to have localized resource dll signed.) and get it signed. Then you can drag the language subfolder with the signed dll file into C:\WINDOWS\ASSEMBLY.
To test your localized application on a machine that does not share the culture of the localized dll
1. 2. Add the following code in the form's constructor just before the InitializeComponent method is called. Replace the "ja" in the example code with the culture specified in the ARDesigner.bat file. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the the form's constructor just before the InitializeComponent method. System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("ja") To write the code in C# C# code. Paste INSIDE the form's constructor just before the InitializeComponent method. System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ja");
To deploy a solution that includes the Designer control (Professional Edition only), you must include the version of the Microsoft Rich Text Edit Control DLL that is installed with ActiveReports in a location like this: C:\Program Files\Common Files\GrapeCity\ActiveReports 6\riched20.dll. Caution: If you do not deploy Product version 4 (File version 5.40.11.2210) or higher of riched20.dll with the Designer, the user might have a version that is unable to render RTF tables correctly in edit mode of the RichText control. Place this file in the same directory as the ActiveReports assemblies.
To deploy riched20.dll
1. 2. 3. 4. 5. Open the Registry Editor. Expand the tree view to My Computer\HKEY_CURRENT_USER\Software\GrapeCity\ActiveReports 6. Right-click in the pane to the right and select New, then String Value. Name the new String Value RtfPath. Double-click RtfPath, and enter the path to the newer version of riched20.dll.
Once you have finished these steps, you can deploy your Designer application like any other Windows Application.
TOCButton PrintButton PageRangeButton SearchButton ZoomOutButton ZoomBox ZoomInButton SinglePageViewButton MultiPageBox ContinuousViewButton PreviousPageButton NextPageButton CurPageTextArea BackwardButton ForwardButton
'Get an existing tool from the toolbar. (If you prefer, you can specify the index of the tool.) Dim tool As DataDynamics.ActiveReports.Web.Controls.ToolBase = WebViewer1.FlashViewerToolBar.Tools("P 'Remove the tool from the toolbar. WebViewer1.FlashViewerToolBar.Tools.Remove(tool) 'Add the tool in a different position. WebViewer1.FlashViewerToolBar.Tools.Insert(0, tool) To write the code in C# C# code. Paste INSIDE the Page Load event. //Get an existing tool from the toolbar. (If you prefer, you can specify the index of the tool.) ToolBase tool = WebViewer1.FlashViewerToolBar.Tools[ToolsCollection.ToolCommands.PageRangeButton]; //Remove the tool from the toolbar. WebViewer1.FlashViewerToolBar.Tools.Remove(tool); //Add the tool in a different position. WebViewer1.FlashViewerToolBar.Tools.Insert(8, tool);
'Get an existing tool from the toolbar. (If you prefer, you can specify the index of the tool.) Dim tool As DataDynamics.ActiveReports.Web.Controls.ToolBase = WebViewer1.FlashViewerToolBar.Tools("P 'Remove the tool from the toolbar. WebViewer1.FlashViewerToolBar.Tools.Remove(tool) To write the code in C# C# code. Paste INSIDE the Page Load event. //Get an existing tool from the toolbar. (If you prefer, you can specify the index of the tool.) ToolBase tool = WebViewer1.FlashViewerToolBar.Tools[ToolsCollection.ToolCommands.PageRangeButton]; //Remove the tool from the toolbar. WebViewer1.FlashViewerToolBar.Tools.Remove(tool);
'Get the collection of buttons and separators used in the toolbar Dim collection As DataDynamics.ActiveReports.Web.Controls.ToolsCollection = WebViewer1.FlashViewerToo 'Remove all buttons and separators collection.Clear() 'Add pre-defined buttons collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.Create(DataDynamics.ActiveReports.Web.Con collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.Create(DataDynamics.ActiveReports.Web.Con collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.Create(DataDynamics.ActiveReports.Web.Con 'Add separator collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.CreateSeparator()) 'Add pre-defined button collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.Create(DataDynamics.ActiveReports.Web.Con 'Add separator collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.CreateSeparator()) 'Add custom buttons collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.CreateButton("btn1")) collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.CreateButton("btn2")) To write the code in C# C# code. Paste INSIDE the Page Load event.
//Get the collection of buttons and separators used in the toolbar DataDynamics.ActiveReports.Web.Controls.ToolsCollection collection = WebViewer1.FlashViewerToolBar.To //Remove all buttons and separators collection.Clear(); //Add pre-defined buttons collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.Create(DataDynamics.ActiveReports.Web.Con collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.Create(DataDynamics.ActiveReports.Web.Con collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.Create(DataDynamics.ActiveReports.Web.Con //Add separator collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.CreateSeparator()); //Add pre-defined button collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.Create(DataDynamics.ActiveReports.Web.Con //Add separator collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.CreateSeparator()); //Add custom buttons collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.CreateButton("btn1")); collection.Add(DataDynamics.ActiveReports.Web.Controls.Tool.CreateButton("btn2"));
2. 3. 4.
Microsoft .NET Framework Version 2.0 or higher IIS (Internet Information Services) Version 6.0 or higher ASP.NET Version 2.0 or higher (must be the same version as the Framework)
The ProductName property determines the name that is displayed for the application in folder names and in the Add/Remove Programs dialog box.
Tip: If the File System Editor is not open, drop down the View menu and select Editor, then File System. 3. 4. 5. From the Visual Studio Action menu, select Add, then Project Output. In the Add Project Output Group window that appears, next to Project, select your ActiveReports project name from the drop-down list. Hold down the Ctrl key and select Primary Output and Content Files from the list and click OK to add all of the existing assembly dependencies to your Web application.
6.
On the Build menu, select Build YourInstallerProjectName to build your installer project. Note: If you prefer to use the ActiveReports .msm file, please contact activereports.support@datadynamics.com.
Double-click any topic in the table of contents to open it for editing. You will also notice that content in some of the overview topics is highlighted with the purple In Progress build flag. 1. 2. To clear the build flag from content, select the content and in the toolbar, drop down the Build Flags list. Select Remove Build Flag. The selected content no longer appears highlighted in purple, and will be included in the help file output.
6.
If you want to find and replace specific text within the entire project, for example "ActiveReports" or "GrapeCity," from the Tools menu, select Project Find and Replace. 1. 2. 3. Enter the text you want to find in the Find What field, and the text you want to replace it with in the Replace With field. Click the Find in Project button or hit Enter on your keyboard. The list of topics containing the search terms appears. Double-click any item in the list to open the topic for editing. The find dialog appears and the search term is highlighted in the topic.
7.
If you add or remove any topics and you are providing context-sensitive help, you need to regenerate the ActiveReports6.h file. 1. 2. 3. 4. From the Tools menu, select Create .h Help Context ID File. In the Create .h File dialog that appears, click the Browse button. In the Browse dialog that appears, select the ActiveReports6.h file and click OK . Select the check box to Assign Help Context IDs to any Topics without IDs already assigned.
To change the name and other properties of the generated help file, in the Project Explorer, expand the Build Profiles node. 1. 2. Double-click the AR6Designer (Compiled HTML Help 1.x file) build profile to open the Build Profile dialog. Make any changes to the build profile and click the OK button.
9.
To change the name and other properties of the generated PDF booklet, in the Project Explorer, expand the Booklets node. 1. 2. Double-click the AR6Designer booklet to open the booklet properties tab. Make any changes to the booklet and save the project.
10.
To build the help file, in the HelpStudio toolbar, click the Build this Project (F5) icon.
11.
In the Build Options dialog that appears, select the check boxes that you want to build and click the Build button. The compiled CHM or PDF files appear in the Build folder.
Include the ActiveReports6.chm and ActiveReports6.h files in your deployment folder along with your executable. You can put the AR6Designer.pdf file in any folder for deployment.
4.
In the Application Configuration dialog that appears, select the list item with .aspx in the Extension column and click the Edit button. Note: If your machine does not have the ASP.NET server components installed, the .aspx handler does not appear in the Application Mappings list.
5. 6. 7.
In the Executable field, select and copy all of the text, and click Cancel to return to the Application Configuration dialog. Click the Add button to add a new Application Mapping. In the Add/Edit Application Extension Mapping window that appears, paste the value from the .aspx extension into the Executable field.
8. 9.
In the Extension field, enter .rpx. Click the OK button to add the mapping and return to the Application Configuration dialog.
5.
Click the OK button to add the mapping and return to the Application Configuration dialog.
5. 6.
Click the OK button to add the mapping and return to the Application Configuration dialog. Click OK on the remaining open dialogs to exit the IIS Administrative tool.
See the topic Add Report Links to Web Forms (Pro Edition) for information on enabling the handlers in a Web Form.
The Add Script Map window is displayed. 7. In the displayed Add Script Map window, enter the following information:
Request path:*.ActiveReport Executable: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll Name: ActiveReport Script Mapping 8. 9. 10. Click the Request Restrictions button and make sure the "Invoke handler only if request is mapped to:" check box is not selected. Click OK to close the Add Script Map window. Repeat steps 5-8 to add another script mapping. Enter the following information for the second script mapping (see the step 6 above): Request path:*.ArCacheItem Executable: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll Name: ActiveReport Cache Item Script Mapping 11. Repeat steps 5-8 to add the last required script mapping. Enter the following information for the third script mapping (see the step 6 above): Request path:*.rpx Executable: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll Name: ActiveReport RPX Script Mapping 12. 13. To ensure that your Web Application is running in the Classic .NET Application Pool, go to the Internet Information Services Manager and select your Web Application in the Connections panel. In the Actions pane, click Basic Settings.... The Edit Application window will appear.
14. 15.
In the Edit Application window, click the "Select..." button. In the drop-down box, select Classic .NET AppPool, then click OK.
16.
Samples
Your ActiveReports 6 installation includes the following samples, with four versions of each. There is a C# and a Visual Basic.NET version for Visual Studio versions 2005 and 2008. Click a sample name below to drop down a description of the sample. A more complete description of the samples are available in a *README.html file within the sample folder, and comments are sprinkled throughout the sample code. Annual Report Demonstrates how to use subreports and nested subreports, how to modify data source properties at run time, how to use parameters in the chart control, how to create alternate row highlighting and how to use the page break control. See the Annual Report Sample topic for more information. Bound Data Demonstrates binding to ADO.NET Data objects. See the Bound Data Sample topic for more information. Calculated Fields Demonstrates using an unbound data field to perform a calculation which can then be aggregated. See the Calculated Fields Sample (on-line documentation) for more information. Category Selection Demonstrates using the ad hoc report filter by modifying the report's SQL query at run time. See the Category Selection Sample topic for more information. Charting Demonstrates the use of the Chart control in both bound and unbound modes. See the Charting Sample topic for more information. NEW! Cross Section Controls Demonstrates the use of the new cross section lines and boxes. See the NEW Cross Section Control Sample topic for more information. Cross Tab Report Demonstrates using unbound data, conditional highlighting and distributing data across columns to create a cross-tab view and data aggregation. See the Cross Tab Report Sample topic for more information. Custom Preview Demonstrates using viewer control customization, export filters, rich edit control and mail-merge, parameters in the chart control, and grouping. See the Custom Preview Sample topic for more information. Data Field Expressions Demonstrates the use of expressions in the DataField properties of controls. See the Data Field Expressions Sample (on-line documentation) topic for more information. Hyperlinks and Drill Down Demonstrates using hyperlinks and the viewer hyperlink event to simulate drill-down from one report to another. See the Hyperlinks and Drill Down Sample topic for more information. IList Binding Demonstrates how to bind reports to objects. Print Multiple Pages per Sheet Demonstrates how to print multiple pages of a report on a single sheet of paper. RDF Viewer Demonstrates customizing the WinForms viewer control toolbar, loading Report Document Files (RDF) and using the export filters. See the Rdf Viewer Sample topic for more information. Standard Edition Web Sample Demonstrates using Standard Edition in ASP.NET. It shows how to use custom exporting without the Pro Edition server controls or RPX handlers as well as running reports on the server, exporting output to HTML or PDF streams and pushing content to the client. The sample also demonstrates using the Flash viewer to view report output on the client machine.
Professional Edition
NEW! Flash Web Viewer Demonstrates customization possibilities with the new FlashViewer, including localization, themes, and a custom button. See the NEW Flash Web Viewer Sample for more information. End User Designer Demonstrates a custom end-user report designer that can be integrated in your applications to allow users to modify report layouts. Toolbox Class Library This is the project that creates the toolbox used in the End User Designer sample. Professional Edition Web Sample The ASP.NET Web Samples demonstrate the use of Professional Edition ASP.NET features, including HTTP Handlers, Report Caching, and the Server Viewer Control in both Visual Studio 2005 and 2008. Note: The ASP.NET user machine must have ASP.NET write access before you run the sample or an exception is thrown during execution.
ViewReport.aspx This file contains the WebViewer control. It opens to the Source view, so click Design at the bottom to see the WebViewer.
Click the WebViewer control at the top of the page to select it.
In the Properties window, notice that the ViewerType property is set to FlashViewer, and the Height and Width properties are set to 100%. (This ensures that the viewer resizes to fill the browser window.) The ReportName property is not set, as the ReportName value is passed to it in code.
Expand the FlashViewerOptions node to see properties specifically related to this ViewerType. The ResourceLocale and ThemeUrl values are passed to the viewer in code, as are the ShowSplitter, ShowThumbnails, and ShowToc values. Right-click on the design surface of ViewReport.aspx and select View Code . In the C# or VB code page that
ViewerForm
The ViewerForm has three tabs, each with an ActiveReports Viewer control on it. Right-click the form and select View Code to see the code used to change the Invoice report's section properties at run time. Select one of the Viewer controls and in the Properties window, expand the Toolbar property to see where the Visible property is set to False.
Invoice
The Invoice report demonstrates the usage of the following features: PageHeader Section
The Shape control provides a border around the Order ID and Order Date fields and labels. The OrderDate TextBox control has the OutputFormat property set to d to display a short date. The Label controls use the BackColor, ForeColor, and Font properties to add a distinctive style to the report.
GroupHeader Section
The new CrossSectionBox control is hosted in the GroupHeader section, and spans the Detail section to end in the GroupFooter section, forming a rectangle around the details of the invoice at run time.
Three of the new CrossSectionLine controls are hosted in the GroupHeader section, and span the Detail section to end in the GroupFooter section, forming vertical lines between columns of invoice details at run time.
Note: If you try to drop a cross-section control into a section other than a header or footer, the mouse pointer changes to Unavailable, and you cannot drop the control.
Two of the TextBox controls use a CalculatedField in the DataField property. Tip: In the Report Explorer, expand the Fields node, then Calculated to see all of the calculated fields. Select BillingAddress or ShippingAddress to take a closer look at the Formula used in the Properties window.
The Line control is used below the column header labels to draw a horizontal line across the width of the report. (It is not visible at design time unless you make the Height of the GroupHeader section larger.) The DataField property of the section is set to the OrderID field, so that the section (followed by related details and GroupFooter) prints once per order.
Detail Section
Click the Detail RepeatToFill tab to see the Detail section with the new RepeatToFill property set to True. This ensures that the formatting (alternating purple and white rows and CrossSection controls) fills space as needed to push the GroupFooter section to the bottom of the page, just above the PageFooter section.
Four TextBox controls display each row of data associated with the current GroupHeader OrderID. The OutputFormat property of the UnitPrice and Total fields is set to C to display currency. The Line control is used below the text boxes to draw horizontal lines across the width of the report under each row of data. (It is not visible at design time unless you make the Height of the Detail section larger.) Right-click the report and select View Code to see the code used in the Detail Format event to create a green bar (or in this case, purple bar) report by alternating the BackColor property of the section. Click the Data Source icon on the Detail band to review the Connection String and SQL Query used in the report.
GroupFooter Section
Select the GroupFooter PrintAtBottom tab to see the GroupFooter section with the new
This section also has the NewPage property set to After so that a new page is printed for each OrderID (the associated GroupHeader's DataField). The Subtotal text box uses the following properties:
The DataField property uses a CalculatedField. The SummaryFunc property is set to Sum , to add the values of the field in the detail section. The SummaryGroup property is set to the name of the GroupHeader, to reset the summary value each time the GroupHeader section runs. The SummaryRunning property is set to Group so that the value accumulates for the group rather than for the entire report or not at all. The SummaryType property is set to GrandTotal.
Right-click the report and select View Code to see the code used in the GroupFooter Format event to calculate the value for the Grand Total text box, and to format it as currency.
PageFooter Section
The ReportInfo control uses a FormatString property value of Page {PageNumber} of {PageCount}, one of the preset values you can use for quick page numbering.
Design Time
When you select one of these style names on a report control, ActiveReports retrieves the style values, such as font size and color, from the specified style sheet when it runs the report. For more information on creating your own style sheets, see Use External Style Sheets.
Reports
Two reports, CategoryReport and ProductsReport, are included in this sample so that you can each of the styles applied in different ways. Open one of the reports, and select the TextBox and Label controls on it to see which style is used for each.
StyleSheetsForm
The form in this project features radio buttons for choosing the report and style you want, a Choose button that opens a standard Windows Open dialog where you can select a reportstyle, and a Run report button that runs the selected report, applies the selected reportstyle, and displays the results in the ActiveReports viewer control below. To see how all of this works, right-click the form and select View Code . Choose Button Click Event This event contains code that sets up an Open dialog that shows only *.reportstyle files, and passes the selected reportstyle path and file name string to the externalStyleSheet variable. Run Report Button Click Event
AnnualReport
This is the main ActiveReport for the project. ReportHeader Section This report features a two-page ReportHeader section that uses a PageBreak control to separate the two pages, and breaks to the second page by setting the ReportHeader section's NewPage property to After. This report shows how you can use the BackColor and ForeColor properties of labels to create a distinctive look for your reports. The ReportHeader section also has a SubReport control that links to the ProductSalesByCategory report in the code behind the report, in the ReportStart event. Best practice: It is a best practice to initialize reports in the ReportStart event rather than a section Format event so that a new report is not initialized every time the section runs. If the SubReport control were in a section that prints multiple times, you would need to assign the report in the section Format event while still initializing in the ReportStart event. See the SubReports sample for more information. The yellow background in the right half of the ReportHeader below the page break is achieved by using the Shape control and setting its BackColor property. The image to the left is a Picture control. Detail Section The Detail section contains two SubReport controls that link in the code behind the report to the Top10Customers and Top10Products reports. In most reports, the Detail section would run multiple times. In this report, the Detail section has only labels, and no bound textboxes, so it will only run once. Therefore, the Top10 reports can be assigned to the SubReport control in the ReportStart event where it is initialized. Notice that the ReportFooter section has its Height property set to 0. This is because, except for the Detail section, all sections come in pairs. In order to use the ReportHeader section, you must also have a ReportFooter section. If you do not want to use it, you can set its Height to 0.
GetDBPath
This is a helper class that finds the installation path of ActiveReports, and extrapolates the path of the sample NorthWind database that is included in the installation. It returns a connection string that is used by all of the ActiveReports samples that use the NorthWind database.
ProductSalesByCategory
This is the ActiveReport that is assigned to the SubReport control in the ReportHeader section of the Annual Report. Best practice: Notice that this report has had its ReportHeader/Footer and PageHeader/Footer sections removed. That is a best practice for reports to be used as subreports. These sections are not printed within the SubReport control, so removing the sections saves on processing. Notice also that the PrintWidth property of this report is only 2.677 inches. This is so that it fits easily within the SubReport control on the Annual Report. This report uses the GroupHeader section to display labels for the data fields that fill the Detail section. The fields in the Detail section repeat once for each row of data in the database. Right-click in the grey area around the report and select View Code to see the code that sets the data source for the report, and sets the background color to yellow on every second row of data.
StartupForm
This form contains the ActiveReports Viewer control. The Dock property of the viewer is set to Fill so that it resizes automatically with the form at run time. Right-click and select View Code to see the code that displays the AnnualReport when the form loads.
MainForm
The MainForm uses the ActiveReports Viewer control in the bottom section of the form, and a panel docked to the top contains seven tabs, each with a different data binding technique. Click to select a tab, and then double-click the button on the tab to jump to the button's Click event in the code.
Bind to DataSet Bind to DataReader Bind to DataView Bind to DataTable Bind to SQL Server Bind to OleDb Bind to XML
Above the Data Binding Code region is the Drop Down Population Code region that is used to populate the combo boxes on the DataView and SQL Server tabs. The XML tab also features a button that generates a DataSet and saves it as an XML data file. Run the project and click to select a tab, then click the buttons to check the functionality of each type of data binding as it processes the data, passes it to the report, and displays it in the viewer below.
Invoice
The Invoice report uses three GroupHeader sections, the Detail section and a GroupFooter section to display data, and adds a label in the PageFooter section. Note: Except for the Detail section, all sections come in header and footer pairs. Unused counterparts to the sections in use have their Height properties set to 0 and their Visible properties set to False . ghOrderHeader The DataField property of this section is set to OrderID. This setting, in conjunction with data ordered by the OrderID field, causes the report to print all of the information for one order ID value, including all of the related details and footers, before moving on to the next order ID. For more information on grouping, see Grouping Data. This section contains a Picture control, a number of Label controls, and two bound TextBox controls. The TextBoxes are bound using the DataField property in the Properties window, and the date is formatted using the OutputFormat property. ghOrderID The DataField property of this section is also set to OrderID. This allows subtotal summary functions in the related GFOrderID section to calculate properly. This section contains a number of labels and bound text boxes, as well as two Line controls. ghTableHeader This section contains only labels for the data to follow in the Detail section. Detail This section contains bound TextBox controls. These render once for each row of data found in the current OrderID before the report moves on to the GroupFooter sections. GFOrderID The NewPage property of this section is set to After. This causes the report to break to a new page and generate a new invoice after this section prints its subtotals. This section contains several labels and several text boxes. Two of the TextBox controls use the following properties to summarize the detail data: SummaryFunc, SummaryGroup, and SummaryType. For more
For more information on using Script with ActiveReports, see Scripting. PageFooter This section has one simple Label control. Since none of the GroupFooter sections has its PrintAtBottom property set to True, the PageFooter prints at the bottom of each page of the report. For more information about report sections and the order in which they print, see Report Structure and Section Events.
CategorySelectForm
The ActiveReports Viewer control fills most of the form, and a combo box at the top allows the user to select which data to send to the viewer. Right-click the form and select View Code to see how this is done.
The getCategories code populates the combo box. The runCategoryReport code runs the report with a SQL string with the CategoryName passed in by the combo box selection. The SelectIndexChanged event calls runCategoryReport and passes it the CategoryName.
CategoryProducts Report
This report lists products in the selected category, and summarizes the number of products. Here are the features used in each section: ReportHeader This section cannot be deleted, because the related ReportFooter section is used. When this is the case, the best practice is to set the unused section's Height property to 0. PageHeader
This section uses a Label control with a large Font size and its BackColor property set to LightSteelBlue for the report title. The TextBox control, txtCategory, has its DataField property set to CategoryName. Two Line controls and two more Label controls create the column headers for the report.
Detail This section contains two bound TextBox controls to display each product in the selected category along with its price. Although the form passes data to the report at run time, the report's data source is set for design time use. It is easier at design time to drag bound fields onto the report from the Report Explorer than it is to create them and set their properties. The data source also allows you to preview the report while you are designing it.
Click the DataSource Icon on the Detail band to view the data source.
PageFooter This section uses the ReportInfo control to display Page N of M. In the Properties window, you can select a way to display the page number and run date in the FormatString property. ReportFooter This section contains a Label control and a bound TextBox. The TextBox uses the SummaryType of GrandTotal to display the total number of products in the selected category.
Charting Sample
The Charting sample consists of a form with the ActiveReports Viewer control to display the report, and an ActiveReport with two Chart controls, one bound and one unbound.
rptCharting
The GroupHeader section has its NewPage property set to After. This causes the Detail section to print on a new page. ChartSalesCategories The chart in the GroupHeader section gets its data from the chart data source. To see the data source, select the chart, and in the verbs section of the Properties window, click Data Source. If you have trouble with this, see Access the Chart Wizard and Data Source for help. Also in the verbs section of the Properties window, click Customize to open the Chart Designer window. Click the Series tab to see the fields bound to the X and Y axes. Also on that tab, you can see that the Chart type is set to Doughnut 3D . Scroll down to see the Marker settings that label each slice of the pie in the chart.
Click the Legends tab to see which settings are used to set up the legend at the bottom of the chart. The Titles tab is where the title at the top of the report is set, and the Appearance tab is where the colors of the chart are set. You can also access all of these properties in the Properties window by clicking the ellipsis button that appears when you select the property.
ChartUnbound The chart in the Detail section is not connected to data. Instead, values for data points are set in the Series Collection Editor dialog. To open the dialog, click the chart to select it and in the Properties window, click the Series property to display the ellipsis button (see image above). Click the ellipsis button to open the dialog.
Close both dialogs to return to the chart, and in the Properties window, expand the Backdrop property to see the settings used to create the gradient blue backdrop for the chart. Click the ellipsis button next to the Titles property to find where the header and footer titles are set. For more information on creating charts, see the Create Charts topic and the Chart Walkthroughs section.
ViewerForm
The ViewerForm contains the ActiveReports Viewer control, with its Dock property set to Fill. This enables the viewer to automatically resize along with the form. Right-click the form and select View Code to see the three lines of code used to run the report and display it in the viewer.
StartForm
The Viewer control has its Dock property set to Fill. This ensures that the viewer resizes along with the form at run time. Right-click the form and select View Code to see the code used to run the report and display it in the viewer.
ProductWeeklySales
This report features a number of accumulated values using summary function property settings and calculated in the code behind the report. ReportHeader This section of the report features static controls including Labels, a Picture, a Line, and a Shape control with its BackColor property set to yellow. The report header prints only once, on the first page of the report, so it is a good place for a title, company information, and a logo. PageHeader The page header section also contains static Label controls that print at the top of each page and serve as column headers for the group header sections. ghCategory This group header section has its DataField property set to CategoryName. This setting, along with data sorted by the same field, produces a report grouped by category. The section contains one bound TextBox control to display the category name at the beginning of each group. The section's UnderlayNext property is set to True so that the category prints to the left of the top line of data instead of above it. ghProduct Although this group header contains no controls and is hidden using the Height and Visible properties, it still performs two important functions. First, its DataField property is set to ProductName, sorting the data inside each category by product, and second, its related group footer section displays the bulk of the data for the report. Detail The detail section of this report is hidden using the Height and Visible properties, but it does contain four bound fields whose values are used in the code behind the report.
Code
ReportStart Event Right-click the report and select View Code to see how this report, which does not have its data source set using the data source icon on the Detail band, gets its data. Private variables are created to hold values, and are set initially within the ReportStart event. DataInitialize Event The data source is set in the DataInitialize event, and then unbound fields are added to the report's Fields collection. For more information on unbound reporting, see Unbound Reporting. FetchData Event The FetchData event, which runs once for each row in your dataset, is where most of this report's logic is set. See the comments in the code to understand how data is calculated and passed to the report's Fields collection. Detail Format Event In the Detail Format event, the value from the hidden txtDetProduct text box is collected and passed to the _sProductName variable. For more information on section events, see Section Events.
SummaryFunc: Sum (the default value) adds values rather than counting or averaging them. SummaryGroup: ghProduct summarizes the values that fall within the current product group. SummaryRunning: None (the default value) ensures that this value is reset each time the product group changes. SummaryType: SubTotal summarizes the current group rather than a page or report total.
gfCategory This group footer section displays totals of the gfProduct data in TextBox controls that have values passed in code, or are bound to fields from the report's Fields collection (see FetchData and DataInitialize events in the code) using the DataField property. The total units and sales for each category is summarized using the following properties:
SummaryFunc: Sum (the default value) adds values rather than counting or averaging them. SummaryGroup: ghCategory summarizes the values that fall within the current category group. SummaryRunning: None (the default value) ensures that this value is reset each time the category group changes. SummaryType: SubTotal summarizes the current group rather than a page or report total.
PageFooter This section is not used, so it is hidden using the Height and Visible properties. Otherwise, it would print at the bottom of each page. The section cannot be deleted, because its related PageHeader section is in use. ReportFooter This section is not used, so it is hidden using the Height and Visible properties. Otherwise, it would print once at the end of the report. The section cannot be deleted, because its related ReportHeader section is in use.
CustomPreviewForm
The CustomPreviewForm has its IsMdiContainer property set to True. This ensures that when a user opens a child PreviewForm, it is contained within the parent CustomPreviewForm. This form has a menu bar, mnuMain, with three menus: File, Reports, and Window. The MergeType property of the File menu is set to MergeItems so that the menu items from any child PreviewForms are added to it. The form also has two dialogs: dlgOpenFile, and dlgPrint. Right-click the form and select View Code to see how reports selected from the Reports menu are run and passed to the PreviewForm using the ShowReport code.
PreviewForm
The PreviewForm has the ActiveReports Viewer control with it Dock property set to Fill so that the viewer resizes with the form at run time. The form also has a File menu with its MergeType set to MergeItems so that when a report is open, the File menu on the CustomPreviewForm displays the Export, Save, and PrinterSetup menu items. The form also has one dialog: dlgPrint. Right-click the form and select View Code to see how, in the PreviewForm Load event, two custom buttons are added to the toolbar. The ToolClick event of the viewer calls the SaveDocument and ExportDocument functions for the new buttons. The menu item click events call the same functions for the related menu items. The SaveDocument function opens the dialog dlgSave, while the ExportDocument opens a new ExportForm.
ExportForm
The Export Report Document form opens from the ExportDocument function on the PreviewForm. The form features an Export Format combo box, cboExportFormat, that populates the PropertyGrid control below based on the selected item. The export types are added to cboExportFormat via the Items (collection) property. Right-click the form and select View Code to see how, in the cboExportFormat SelectedIndexChanged event, the property grid control's SelectedObject is set to the selected export. This ensures that only the properties related to each export type show in the grid. See the btnOK Click event for the code that exports the report to the selected file name and format, and the btnSaveFile Click event for the code that opens the Save dialog.
Resources Folder
This folder holds the icons used in adding tools to the toolbar.
Reports Folder
Most of the reports in the Reports folder are documented in more detail elsewhere. Here, they are used mainly to show the Viewer and Export features.
Catalog is documented below. CustomerLabels is explained in the Address Labels walkthrough. EmployeeProfiles is explained in detail in the code behind the report. (Right-click and select View Code .) EmployeeSales is explained in the Bar Chart walkthrough. Invoice is in the Bound Data Sample. Letter is explained in the Mail Merge with RichText walkthrough.
Catalog Report
The Catalog report uses the PageBreak control and the NewPage property to create a cover at the beginning and an order form at the end of the catalog. It uses grouping to list products by category.
ReportHeader In the top of the ReportHeader section, the Picture, Line, and Label controls are used to create a static cover page for the catalog. The PageBreak control allows a second page of static labels to be set up in the same section, and setting the section's NewPage property to After ensures that the report breaks to a new page before rendering the next section. The ReportHeader section prints once per report. PageHeader This section is not in use, so the Height property is set to 0. This section cannot be deleted because its related PageFooter section is in use. ghCategoryName This GroupHeader section has its DataField property set to CategoryName. This, along with sorting the data by the same field, ensures that all of the details for one category are printed before the report moves on to the next category. Also, the section's GroupKeepTogether property is set to All. This causes ActiveReports to attempt to print the group header, related details, and the group footer together all on one page. The controls in this section include two bound TextBox controls and a bound Picture control, along with a row of labels to serve as column headers for the Detail section to follow. Detail Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the Connection String and SQL Query that provide data for the bound fields.
The Detail section has four bound TextBox controls. Select one of them and you can see in the Properties window the field that it is bound to in the DataField property. The UnitPrice text box also uses the OutputFormat to display the data in currency format. This section prints once for each row of data. gfCategoryName This section is used only to render a horizontal Line control after each category grouping is completed. PageFooter This section is used to display the page number at the bottom of each page. ReportFooter This section has the NewPage property set to Before to ensure that it begins at the top of a new page. Label, Shape, and Line controls are used to create the static order form layout in this page-long report section that prints once at the end of the report.
ViewerForm
This form contains only an ActiveReports Viewer control with its Dock property set to Fill. This ensures that the viewer resizes along with the form at run time. Right-click the form and select View Code to see the code that allows multiple ViewerForms to display, and see the Form Load event for the code that loads the main report into the viewer. See the Viewer Hyperlink event for the code that collects a string value from the Hyperlink property of the clicked TextBox on the main report and passes it into the customerID Parameter of the report DrillDown1, or collects a numeric value and passes it to the orderID Parameter of the report DrillDown2. This code then runs the report with the parameter value and displays it in another instance of the ViewerForm.
DrillDownMain Report
The main report that is loaded in the ViewerForm by default uses the PageHeader and Detail sections. PageHeader Section This section contains three Label controls to serve as column headers for the details, and a CrossSectionBox control. For more information, see Cross Section Controls. Detail Section The Detail section has its BackColor property set to Thistle, and its RepeatToFill property set to True. This ensures that the background color reaches all the way to the bottom of the page when there is not enough data to fill it. Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the Connection String and SQL Query that provide data for the bound fields.
The Detail section has three bound TextBox controls that display a list of customer information. Select CustomerID and you will see that the HyperLink property is not set in the Properties window. To see the code that assigns the data from the TextBox to its HyperLink property, right-click the report and select View Code. The HyperLink property is set in the Detail BeforePrint event. For more information, see Section Events. Note: This hyperlink does not work in Preview mode, because it relies on code in the ViewerForm to pass the value to DrillDown1 report's parameter. PageFooter Section This section is not in use, so it is hidden by setting the Visible property to False. This section cannot be deleted, because its related PageHeader section is in use.
DrillDown1 Report
This report looks similar to the DrillDownMain report, but the main difference is that it has a CustomerID parameter in its SQL Query. GroupHeader Section Since this report only displays order information for the CustomerID from the clicked hyperlink, the PageHeader section could have been used, but this report uses the GroupHeader section. To make this section print at the top of each page, its RepeatStyle property is set to OnPage. Like in the previous report, this section contains three Label controls to serve as column headers for the details, and a CrossSectionBox control.
Detail Section Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the parameter in the SQL Query that collects its value from the ViewerForm.
Parameters in SQL Queries are denoted by the <% and %> symbols that trigger ActiveReports to add them to the report's Parameters collection. For more information, see Parameters. The Detail section has five bound TextBox controls that display a list of order information for the customer. Select OrderID and you will see that the HyperLink property is not set in the Properties window. To see the code that assigns the data from the TextBox to its HyperLink property, right-click the report and select View Code. The HyperLink property is set in the Detail BeforePrint event. For more information, see Section Events. GroupFooter Section This section is not in use, so it is hidden by setting the Visible property to False. This section cannot be deleted, because its related GroupHeader section is in use.
DrillDown2 Report
Like DrillDown1, this report has a parameter in its SQL Query, but unlike the other two reports, this one has no hyperlink. It displays order details for the OrderID value passed into it from the clicked hyperlink in DrillDown1. GroupHeader Section Like in the previous report, this section contains Label controls to serve as column headers for the details, and a CrossSectionBox control. Detail Section Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the parameter in the SQL Query that collects its value from the ViewerForm.
RdfViewerForm
This form contains an ActiveReports Viewer control with its Dock property set to Fill. This ensures that the viewer resizes along with the form at run time. It also contains a MenuStrip and an OpenFile dialog. To see the code for each of these, right-click the form and select View Code . Code The GetReportDoc property gets the Document object from the viewer. The ExportForm uses this property to export report documents. The OpenToolStripMenuItem Click event filters to show only RDF files and opens the Open File dialog to the RDFs folder. The dlgOpenFile FileOK function loads the selected RDF file into the viewer. The ExportToolStripMenuItem Click event opens a new ExportForm. Each of the other menu item click events performs its function in a straightforward manner. For more information on the Viewer control, see Viewing Reports.
ExportForm
This form contains a combo box to collect the user-selected export format, a property grid to display properties for the selected format, and an OK button to export the report to the selected format. It also contains a Save dialog. Right-click the form and select View Code to see how this is done. Code The overloaded Show method allows the ExportForm to be called as a child object of the RdfViewerForm. The Export Format combo box SelectIndexChanged event sets the exportComponent variable and the pgOptions property grid's SelectedObject to the selected export type. The exportComponent variable is picked up in the OK button Click event, and then the report Document is pulled from the viewer and exported to the selected format.
RDFs Folder
An RDF file is a static copy of a report saved to the native Report Document Format. This can be loaded into the viewer without running it or accessing data. For more information, see Save and Load Report Files (RDF). The following five reports are included in this sample:
SubReports Sample
The SubReports sample consists of a StartForm with an ActiveReports Viewer control with two buttons, one to run and load each main report, and four reports.
StartForm
The StartForm has a Viewer control with its Dock property set to Fill. This ensures that the viewer resizes along with the form at run time. It also has a panel docked to the top that holds two buttons to run the two main reports. Right-click the form and select View Code to see the code that accomplishes this. Code The Click event of the Run SubReport button runs a new Customers report and loads it into the viewer. The Click event of the Orders Report button runs a new Orders report and loads it into the viewer.
Customers Report
The Customers report uses only the Detail section. It uses several Label controls and bound TextBox controls to display customer data, and a SubReport control to display details about the current customer's orders. This section renders once for each line of data found. The data source icon is not used in this report, as the data, along with the subreport, is set up in code. Right-click the report and select View Code to see the code that accomplishes this. Code In the ReportStart event, a new instance of the Orders report is created. This event is the most efficient place to instantiate reports for use in subreport controls as it fires only once when the report is run. The DataInitialize event is where the data source and SQL query for the main report is set. The data source for the subreport is set in the Detail Format event. For more information on subreport usage, see Subreports.
Orders Report
The Orders report is displayed in the SubReport control in the Customers report. The PageHeader and PageFooter sections have been removed because these sections do not display in the SubReport control. This avoids the use of processing time and resources for sections that do not render. This report uses the GroupHeader section to display static labels for the data in the Detail section. The Detail section displays all of the order data for the current customer in the main report.
OrdersMasterReport
The OrdersMasterReport displays general information about orders, and uses a subreport to display the order details. ReportHeader Section This section uses static Label controls to display labels for the details to follow. PageHeader Section Since this section is not in use, its Height property is set to 0. The section cannot be deleted because the related PageFooter section is in use. Detail Section Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the Connection String and SQL Query that provide data for the bound fields.
The Detail section has six bound TextBox controls that display a list of order information, and one SubReport control that displays the OrdersDetailReport.
PageFooter Section This section, which renders once per page, uses the ReportInfo control to display page n of m at the bottom of each page. ReportFooter Section This section is not used, but cannot be deleted because the related ReportHeader section is in use. Code The report for the SubReport control, OrdersDetailReport, is instantiated and assigned to the SubReport control in the ReportStart event.
OrdersDetailReport
This report has static Label controls in the ReportHeader section, and bound TextBoxes in the Detail section. Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the Connection String and SQL Query that provide data for the bound fields.
Walkthroughs
The Walkthroughs section of the User Guide provides you with step-by -step tutorials that you can follow as you create projects in Visual Studio. The walkthroughs progress from basic through advanced for Standard and Professional Editions of ActiveReports.
Creating a new Visual Studio project Adding an ActiveReport to the Visual Studio project Connecting the data source to a database Adding controls to the report Viewing the report
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
2. 3. 4. 5. 6.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query SQL Query SELECT * FROM Products
7.
Click OK to save the data source and return to the report design surface.
2.
Adding controls to a report to display data Adding scripting to supply data for the controls Loading an xml-based report from resources Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files (x86)\GrapeCity\ActiveReports 6\Data\NWIND.mdb. When you have finished this walkthrough, you will have a report that looks similar to the following.
2.
The following example shows what the scripting code looks like. Warning: Do not access the Fields collection outside the DataInitialize and FetchData events. Accessing the Fields collection outside of these events is not supported, and has unpredictable results. To write the script in Visual Basic.NET. Visual Basic.NET script. Paste in the script editor window. Private Shared m_reader As System.Data.OleDb.OleDbDataReader Private Shared m_cnn As System.Data.OleDb.OleDbConnection
Public Sub ActiveReport_ReportStart() 'Set up a data connection for the report Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GrapeCity\Ac Dim sqlString As String = "SELECT * FROM products" m_cnn = new System.Data.OleDb.OleDbConnection(connString) Dim m_Cmd As System.Data.OleDb.OleDbCommand = new System.Data.OleDb.OleDbCommand(sqlString, m_cnn)
If m_cnn.State = System.Data.ConnectionState.Closed Then m_cnn.Open End If m_reader = m_Cmd.ExecuteReader End Sub Public Sub ActiveReport_DataInitialize() 'Add data fields to the report rpt.Fields.Add("ProductName") rpt.Fields.Add("QuantityPerUnit") rpt.Fields.Add("UnitsInStock") End Sub Public Function ActiveReport_FetchData(ByVal eof As Boolean) As Boolean Try eof = False m_reader.Read 'Populated the fields with data from the data reader rpt.Fields("ProductName").Value = m_reader("ProductName") rpt.Fields("QuantityPerUnit").Value = m_reader("QuantityPerUnit") rpt.Fields("UnitsInStock").Value = m_reader("UnitsInStock") Catch Ex as Exception 'If the end of the data file has been reached, tell the FetchData function eof = True End Try Return eof End Function Public Sub ActiveReport_ReportEnd() 'Close the data reader and connection m_reader.Close m_cnn.Close End Sub To write the script in C#. C# script. Paste in the script editor window. private static System.Data.OleDb.OleDbDataReader m_reader; private static System.Data.OleDb.OleDbConnection m_cnn;
public void ActiveReport_ReportStart() { //Set up a data connection for the report string m_cnnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GrapeCity\Activ string sqlString = "SELECT * FROM products"; 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(); } public void ActiveReport_DataInitialize() { //Add data fields to the report rpt.Fields.Add("ProductName"); rpt.Fields.Add("UnitsInStock"); rpt.Fields.Add("QuantityPerUnit"); } public bool ActiveReport_FetchData(bool eof) { try {
The following example shows what the code for the method looks like. To write the script in Visual Basic.NET. Visual Basic.NET script. Paste INSIDE the form load event. Dim asm As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly() Dim st As IO.Stream = asm.GetManifestResourceStream(asm.GetName().Name + ".rptScript.rpx") Dim report As New DataDynamics.ActiveReports.ActiveReport Using reader As New System.Xml.XmlTextReader(st) report.LoadLayout(reader) End Using report.Run() Viewer1.Document = report.Document To write the script in C#. C# script. Paste INSIDE the form load event. System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream st = asm.GetManifestResourceStream(asm.GetName().Name + ".rptScript.rpx"); DataDynamics.ActiveReports.ActiveReport report = new DataDynamics.ActiveReports.ActiveReport(); using (System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(st)) { report.LoadLayout(reader); } report.Run(); Viewer1.Document = report.Document;
Address Labels
ActiveReports can be used to print any label size by using the newspaper column layout. This walkthrough illustrates how to create a report that repeats labels using the LayoutAction property and prints labels to a laser printer. The labels in this example are 1" x 2.5" and print 30 labels per 8" x 11" sheet. The walkthrough is split up into the following activities:
Connecting the report to a data source Adding controls to the report to display data Adding code to the detail_Format event to repeat labels Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
3. 4. 5. 6. 7.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, paste the following SQL query. SQL Query SELECT ContactName, CompanyName, Address, City, PostalCode, Country FROM Customers
8.
Top margin: 0.5 Bottom margin: 0.5 Left margin: 0.2 Right margin: 0.2
3. 4.
Select rptLabels in the Properties Window and Set the PrintWidth property of the report to 8.1 (the width of the label sheet less the Left and Right margins). Click on the detail section of the report to select it and make the following changes:
Set the CanGrow property to False (to maintain the label size) Change the ColumnCount property to 3 (for three labels across the page) Change the ColumnDirection property to AcrossDown (to have labels print in left-to-right order instead of top-to-bottom) Set the ColumnSpacing property to 0.2 (to allow for blank space between labels) Set the height of the Detail section to 1 (the height of the label, one inch)
5.
In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the Size and Location properties of each textbox as indicated. Note: When you drag a field from the Report Explorer onto the design surface of the report, the DataField, Name and Text properties of the textbox object are automatically set to txtFieldName1. Detail fields Field Size Location ContactName 2.5, 0.2 0, 0 CompanyName 2.5, 0.2 0, 0.198 Address 2.5, 0.2 0, 0.396 City 2.5, 0.2 0, 0.594 PostalCode 1.45, 0.2 0, 0.792 Country leave at default 1.5, 0.792
6.
Select all of the textboxes, and in the Properties Window, set the CanGrow property to False . This prevents overlapping text, but may crop data if one of the fields contains more data than the control size allows.
Columnar Reports
ActiveReports supports newspaper column layouts 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 the Group section (i.e. start a new column on the change of a group). There is also a Boolean ColumnGroupKeepTogether property on the GroupHeader. When set to True, the ColumnGroupKeepTogether property attempts to prevent a group from splitting across columns. If a group cannot fit in the current column, it tries the next. If the group is too large for a single column, the property is ignored. Note: The ColumnGroupKeepTogether property is only implemented when the GroupHeader's GroupKeepTogether property is set to All. This walkthrough illustrates how to create a simple report using columns, and is split up into the following activities:
Connecting the report to a data source Adding controls to the report to display data Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
3. 4. 5.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path.
Change the Name property to ghCountry . Change the BackColor property to Gold. Change the DataField property to Country. Change the ColumnGroupKeepTogether property to True to attempt to prevent groups from splitting across columns. Change the GroupKeepTogether property to All to enable the ColumnGroupKeepTogether property.
3. 4.
Select the group footer, and change its BackColor property to Goldenrod. Drag the Country field from the Report Explorer into the GroupHeader section, and set its properties as indicated: Alignment Font Location Size Center Arial, 12pt, style=Bold 0, 0 3.25, 0.2 in Select the PageHeader section and change its BackColor property to Linen. Drag a Label control from the ActiveReports toolbox into the PageHeader section, and set its properties as indicated: Alignment Font Text Location Size Center Arial, 14pt Customer Telephone List by Country 0, 0 6.5, 0.25 in Select the Detail section, and make the following changes in the Properties Window:
5. 6.
7.
Change the CanShrink property to True to eliminate white space after each name. Change the ColumnCount property to 2 to split the detail section into two columns.
8.
Drag the following fields from the Report Explorer into the Detail section and set their properties as indicated: Field Font Location Size CompanyName Arial, 8pt 0, 0 in 1.15, 0.2 in ContactName Arial, 8pt 1.16, 0 in 1.15, 0.2 in Phone Arial, 8pt 2.3, 0 in 0.95, 0.2 in
Connecting the data report to a data source Adding controls to the letterhead and data reports Adding code to overlay the data report pages with the letterhead report Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have completed this walkthrough, you will have a report that looks similar to the following.
3.
On the OLE DB tab, next to Connection String, click the Build button.
Change the Name property to ghCustomers Change the BackColor property to MediumSlateBlue Change the CanShrink property to True Change the DataField property to Country Change the GroupKeepTogether property to FirstDetail Change the KeepTogether property to True
4.
Add the following controls to ghCustomers with properties set as indicated: Group header labels Control Miscellaneous Bold TextBox ForeColor = White Font Size = 12 Bold Label ForeColor = DarkSlateBlue Bold Label ForeColor = DarkSlateBlue Bold Label ForeColor = DarkSlateBlue Bold Label ForeColor = DarkSlateBlue Text (or DataField) Size Location 0, 0 in
0.6, 0.198 in 0, 0.2 in 1.1, 0.198 in 0.7, 0.2 in 1, 0.198 in 1, 0.198 in 2.7, 0.2 in 5.5, 0.2 in
5.
Change the BackColor property to LightGray Change the CanShrink property to True
6.
In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the properties of each textbox as indicated. Detail fields Field Size Location CustomerID 0.6, 0.2 in 0, 0 in CompanyName 2, 0.2 in 0.7, 0 in Address 2.8, 0.2 in 2.7, 0 in City 1, 0.2 in 5.5, 0 in
7.
Change the BackColor property to DarkSlateBlue Change the Height property to 0.65
2.
Add the following controls to the page header with properties set as indicated: Page header labels Control Miscellaneous Size = 36 Style = Bold Label ForeColor = White Text = GrapeCity PictureAlignment = TopLeft Picture Image (click ellipsis, navigate to C:\Program Files\GrapeCity\ActiveReports 6 \Introduction and select itopimage1.gif) Size 3.7, 0.65 in 2.9, 0.65 in Location 0, 0 in
3.6, 0 in
3.
4.
Add a label with the following properties to the page footer: Page footer label Miscellaneous ForeColor Text Alignment = (614) 895-3142, http://www.datadynamics.com Center White (http://www.datadynamics.com/), Style = Bold info@datadynamics.com Size Location 6.5, 0, 0 in 0.2 in
Adding code to overlay the data report pages with the letterhead report
To write the code in Visual Basic.NET
Add the ActiveReports viewer control to the Windows Form. Then, double-click the top of the Windows Form to create an event-handling method for the form's Load event. Add code to the handler to:
Set the viewer to display the rptData report document Overlay rptLetterhead on rptData
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the Form Load event. Dim rpt As New rptData() rpt.Run() Viewer1.Document = rpt.Document Dim rpt2 As New rptLetterhead() rpt2.Run() Dim i As Integer For i = 0 To rpt.Document.Pages.Count - 1 rpt.Document.Pages(i).Overlay(rpt2.Document.Pages(0)) Next To write the code in C#
Add the ActiveReports viewer control to the Windows Form. Then, double-click the top of the Windows Form to create an event-handling method for the form's Load event. Add code to the handler to:
Set the viewer to display the rptData report document Overlay rptLetterhead on rptData
The following example shows what the code for the method looks like. C# code. Paste INSIDE the Form Load event. rptData rpt = new rptData(); rpt.Run(); viewer1.Document = rpt.Document; rptLetterhead rpt2 = new rptLetterhead(); rpt2.Run(); for(int i = 0; i < rpt.Document.Pages.Count; i++) { rpt.Document.Pages[i].Overlay(rpt2.Document.Pages[0]);
Chart Walkthroughs
Charts add quick visual impact to your reports, and allow data to be readily grasped even by casual readers. With a built-in chart control, ActiveReports makes it easy to provide premium reporting without the need to purchase extra tools. Bar Chart Describes how to create a bar chart which compares items across categories. 3D Pie Chart Describes how to create a three dimensional pie chart which shows how the percentage of each data item contributes to a total percentage. Financial Chart Describes how to create a financial chart which lets you plot high, low, opening, and closing prices. Simple Unbound Chart Describes how to create a simple unbound chart.
Bar Chart
Bar charts are useful in comparing items across categories. This walkthrough illustrates how to create a simple bar chart using the ActiveReports chart control. The walkthrough is split up into the following activities:
Adding a chart control to the report Setting a data source for the chart Setting the chart's properties Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
2. 3. 4. 5. 6.
In the Chart DataSource dialog box that appears, click the Build button. In the Data Link Properties window, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis button (...) to browse to the Northwind database. Click Open once you have selected the file. Click the OK button to close the window and fill in the Connection String. In the Query field, enter the following SQL query SQL Query SELECT ShipCountry, SUM(Freight) AS FreightSum FROM Orders GROUP BY ShipCountry
7.
Click OK to save the data source and return to the report design surface.
4. 5. 6. 7.
Choose the Labels tab in the Axis Properties pane on the right, and select the Staggered Labels option to avoid overlapping labels. Click Axis Y on the left, and on the Common tab in the pane to the right, type Freight in the Title textbox and increase the font size to 12. Click the Titles bar on the left to expand it and display Title Properties in the pane to the right. In the list of titles, header is selected by default. Type Simple Bar Chart in the Caption textbox, and increase the font size to 14.
8. 9. 10.
Select the footer in the list of titles to the left, and delete it. Click the Series bar on the left to expand it and display Series Properties in the pane to the right. Series1 is selected by default. In the Data Binding box, set X (Name) to ShipCountry, and set Y to FreightSum.
Delete Series2 and Series3. Click the Legend bar on the left to expand it and display Legend Properties in the pane to the right. defaultLegend is selected by default. Clear the Visible checkbox at the top of the Common tab to hide the legend.
14.
3D Pie Chart
Pie charts are useful in showing how the percentage of each data item contributes to the total. This walkthrough illustrates how to create a three dimensional pie chart. The walkthrough is split up into the following activities:
Adding a chart control to the report Adding a series and data points to the chart Setting the chart's properties Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
When you have finished this walkthrough, you will have a chart that looks similar to the following.
2.
In the Series Collection Editor window that appears, Series1 is selected by default.
6.
In the DataPoint Collection window that appears, click the Add button to add a data point
Set the LegendText property to Figs. Set the YValues property to 19. Expand the Properties node and set the ExplodeFactor property to .5 to pull this slice out from the pie.
7.
Set its LegendText property to Raspberries. Set its YValues property to 15.
8.
Set its LegendText property to Blueberries. Set its YValues property to 37.
9.
Set its LegendText property to Bananas. Set its YValues property to 21.
Click OK to save the data points and return to the Series Collection Editor. Remove Series2 and Series3. Click OK to save the changes and return to the report design surface.
Financial Chart
Financial charts are useful for displaying stock information using High, Low, Open and Close values. This walkthrough illustrates how to create a Candle chart. The walkthrough is split up into the following activities:
Adding a chart control to the report Adding a series and data points to the chart Setting the chart's properties Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
When you have finished this walkthrough, you will have a chart that looks similar to the following.
2. 3.
In the Series Collection Editor window that appears, Series1 is selected by default. Under Series1 Properties, change the Type property to Candle.
8. 9.
Click the Points (Collection) property, then click the ellipsis button that appears. In the DataPoint Collection window that appears, click Add to add a data point
Set its YValues property to 99; 37; 53; 88. Note: The first Y value is the high figure or top of the wick; the second is the low figure, or bottom of the wick; the third is the opening figure; the fourth is the closing figure. If the fourth figure is higher than the third, the candle is DarkViolet, the BodyUpswingBackdrop. Add another data point, and set its YValues property to 115; 22; 101; 35. Add another data point, and set its YValues property to 87; 1; 7; 80. Add another data point, and set its YValues property to 63; 14; 57; 25. Add another data point, and set its YValues property to 130; 25; 25; 120.
Click OK to save the data points and close the window. Back on the Series Collection Editor window, set the Legend property to (none). Remove Series2 and Series3. Click OK to return to the report design surface.
5.
In the Array Data Editor window that appears, enter the following into the editor, each item on a separate line:
6. 7.
Click the OK button to return to the AxisBase Collection Editor. Select the AxisY member, and under AxisY properties, expand the MajorTick property node and set the Step property to 10. This controls the numeric labels along the Y axis, the line along the left side of the chart. Set the LabelsVisible property to True. Set the AxisY member's Title property to $,000 and click OK to return to the ChartArea Collection Editor.
8. 9.
10.
Click OK to return to the report design surface and see the changes reflected in the chart.
5. 6.
With the Chart control highlighted, click the Legends (Collection) property in the Properties Window, then click the ellipsis button that appears. In the Legend Collection Editor window that appears, set the Visible property to False, and click OK to return to the report design surface and see the completed chart.
Unbound Chart
The Chart control allows you to bind charts to any type of data source, including arrays. You can create a chart without setting its data source and load the data into the control at run time. This walkthrough illustrates how to create a simple unbound chart. The walkthrough is split up into the following activities:
Adding the chart control to the report and setting chart properties Adding code to create the chart at run time Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
Tip: If you do not see the verbs, right-click an empty space in the Properties Window and select Commands. 5. 6. In the ChartAreas view which displays by default, click the Axes bar to expand it. Click Axis X, and on the Common tab in the pane to the right, type Company Name in the Title textbox and increase the font size to 12.
7. 8. 9.
Click Axis Y on the left, and on the Common tab in the pane to the right, type Freight in US$ in the Title textbox and increase the font size to 12. Click the Titles bar on the left to expand it and display Title Properties in the pane to the right. In the list of titles, header is selected by default. Type Unbound Chart in the Caption textbox, and increase the font size to 14.
Select the footer in the list of titles to the left, and delete it. Click the Series bar on the left to expand it and display Series Properties in the pane to the right. Delete Series1, Series2 and Series3. Click the Legends bar on the left to expand it and display Legend Properties in the pane to the right. defaultLegend is selected by default. Clear the Visible checkbox at the top of the Common tab to hide the legend.
15.
Back on the design surface of the report, the chart appears empty except for the legends and title.
To write the code to create a chart at run time chart in Visual Basic or C#
Double-click in the gray area below rptUnbound. This creates an event-handling method for rptUnboundChart's ReportStart event. Add code to the handler to:
Set the database path Important: Place this code above the ReportStart event. Create the series Create the dataset Set the chart properties Angle the labels to avoid overlap
The following examples show what the code for the methods look like in Visual Basic.NET and C#. Visual Basic.NET code. Paste JUST ABOVE the ReportStart event. 'Set the database path Private Function getDatabasePath() As String Dim regKey As Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine regKey = regKey.CreateSubKey("SOFTWARE\\GrapeCity\\ActiveReports 6\\SampleDB") getDatabasePath = CType(regKey.GetValue(""), String) End Function Visual Basic.NET code. Paste INSIDE the ReportStart event. 'create the series Dim series As New DataDynamics.ActiveReports.Chart.Series series.Type = Chart.ChartType.Bar3D
'connection string and data adapter Dim dbPath As String = getDatabasePath() Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + dbPath + " Dim da As New System.Data.OleDb.OleDbDataAdapter("SELECT * from Orders WHERE OrderDate < 'create the dataset Dim ds As New DataSet da.Fill(ds, "Orders") 'set chart properties Me.ChartControl1.DataSource = ds Me.ChartControl1.Series.Add(series) Me.ChartControl1.Series(0).ValueMembersY = ds.Tables("Orders").Columns(7).ColumnName Me.ChartControl1.Series(0).ValueMemberX = ds.Tables("Orders").Columns(8).ColumnName 'angle the labels to avoid overlapping Me.ChartControl1.ChartAreas(0).Axes(0).LabelFont.Angle = 90 C# code. Paste JUST ABOVE the ReportStart event.
Adding the Excel export filter to your project Adding an ActiveReport.Document reference to the project Creating a Workbook using code
Adding a sheet to the Workbook's Sheets collection Setting properties on columns and rows in the sheet Setting values of cells in the sheet Using the Save method to create an Excel file
When you have completed this walkthrough, a custom Excel file like the following is created in the Bin/Debug subfolder of your project's folder.
Create a Workbook, and add a sheet to the Workbook's Sheets collection Set properties on columns and rows in the sheet Set values of cells in the sheet Use the Save method to create an Excel file
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste inside the form Load event. 'Dimension a Workbook and add a sheet to its Sheets collection Dim sb As New DataDynamics.SpreadBuilder.Workbook() sb.Sheets.AddNew() 'Set up properties and values for columns, rows, and cells as desired With sb.Sheets(0) .Name = "Customer Call List" 'sets the name of the sheet .Columns(0).Width = 2 * 1440 'sets the width of the 1st column .Columns(1).Width = 1440 .Columns(2).Width = 1440 .Rows(0).Height = 1440 / 4 'Header row .Cell(0, 0).SetValue("Company Name") .Cell(0, 0).FontBold = True .Cell(0, 1).SetValue("Contact Name") .Cell(0, 1).FontBold = True .Cell(0, 2).SetValue("Phone") .Cell(0, 2).FontBold = True 'First row of data .Cell(1, 0).SetValue("GrapeCity") .Cell(1, 1).SetValue("Mortimer") .Cell(1, 2).SetValue("(425) 880-2601") End With 'Save the Workbook to an Excel file sb.Save(Application.StartupPath & "\x.xls") MessageBox.Show("Your Spreadsheet has been saved to " & Application.StartupPath & "\x.xls") To write the code in C# C# code. Paste inside the form Load event. //Dimension a Workbook and add a sheet to its Sheets collection DataDynamics.SpreadBuilder.Workbook sb = new DataDynamics.SpreadBuilder.Workbook(); sb.Sheets.AddNew(); //Set up properties and values for columns, rows and cells as desired sb.Sheets[0].Name = "Customer Call List"; sb.Sheets[0].Columns(0).Width = 2 * 1440; sb.Sheets[0].Columns(1).Width = 1440; sb.Sheets[0].Columns(2).Width = 1440; sb.Sheets[0].Rows(0).Height = 1440/4; //Header row sb.Sheets[0].Cell(0,0).SetValue("Company Name"); sb.Sheets[0].Cell(0,0).FontBold = true; sb.Sheets[0].Cell(0,1).SetValue("Contact Name"); sb.Sheets[0].Cell(0,1).FontBold = true; sb.Sheets[0].Cell(0,2).SetValue("Phone"); sb.Sheets[0].Cell(0,2).FontBold = true; //First row of data sb.Sheets[0].Cell(1,0).SetValue("GrapeCity");
Adding code to connect the report to a data source Adding controls to contain the data Using the DataInitialize event to add fields to the report's fields collection Using the FetchData event to populate the report fields Adding code to close the connection to the data source Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have completed this walkthrough, you will have a report that looks similar to the following.
Set the data source connection string Set the data source SQL query Open the connection and retrieve the data with the data reader
The following examples show what the code for the method looks like in Visual Basic.NET and C#. To write the code in Visual Basic.NET Visual Basic.NET code. Paste JUST ABOVE the ReportStart event. Dim connection As System.Data.OleDb.OleDbConnection Dim reader As System.Data.OleDb.OleDbDataReader Visual Basic.NET code. Paste INSIDE the ReportStart event.
'Create the data connection and change the data source path as necessary Dim connectionString As String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GrapeCity\ActiveReport connection = New System.Data.OleDb.OleDbConnection(connectionString) connection.Open() Dim sqlString As String sqlString = "SELECT * FROM categories INNER JOIN products ON categories.categoryid= products.categoryid Dim command As New System.Data.OleDb.OleDbCommand(sqlString, connection) 'Retrieve data reader = command.ExecuteReader() To write the code in C# C# code. Paste JUST ABOVE the ReportStart event. private System.Data.OleDb.OleDbConnection connection; private System.Data.OleDb.OleDbDataReader reader; C# code. Paste INSIDE the ReportStart event.
//Create the data connection and change the data source path as necessary string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GrapeCity\Acti connection=new System.Data.OleDb.OleDbConnection(connectionString); connection.Open();
string sqlString = "SELECT * FROM categories INNER JOIN products ON categories.categoryid = products.cat System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(sqlString, connection); //Retrieve data reader = command.ExecuteReader();
Name: ghCategories BackColor: Silver CanShrink: True DataField: CategoryID GroupKeepTogether: All KeepTogether: True
3. 4. 5.
Select the group footer, and in the Properties Window, change the Name property to gfCategories. Select the detail section, and in the Properties Window, change the CanShrink property to True. Add the following controls to the GroupHeader section (drag the bottom edge of the section down to display all of the controls): GroupHeader controls Control DataField Name Text Miscellaneous Location
Line
Line1
SummaryType = SubTotal SummaryFunc = Count SummaryRunning = Group 4.4, 0 SummaryGroup = ghCategories X1 = 1.88 LineWeight = 3 X2 = 6.44 Y1 = 0 Y2 = 0
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the DataInitialize event. Fields.Add("CategoryID") Fields.Add("CategoryName") Fields.Add("ProductName") Fields.Add("UnitsInStock") Fields.Add("Description") Fields.Add("TotalLabel") To write the code in C# 1. 2. 3. 4. Click in the gray area below the report to select it. Click the events icon in the Properties Window to display available events for the report. Double-click DataInitialize. This creates an event-handling method for the report's DataInitialize event. Add code to the handler to add fields to the report's Fields collection.
The following example shows what the code for the method looks like.
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the FetchData event. Try reader.Read() Me.Fields("CategoryID").Value = reader("categories.CategoryID") Me.Fields("CategoryName").Value = reader("CategoryName") Me.Fields("ProductName").Value = reader("ProductName") Me.Fields("UnitsInStock").Value = reader("UnitsInStock") Me.Fields("Description").Value = reader("Description") Me.Fields("TotalLabel").Value = "Total Number of " + reader("CategoryName") + ":" eArgs.EOF = False Catch eArgs.EOF = True End Try To write the code in C# 1. 2. 3. 4. Back in design view, click in the gray area below the report to select it. Click the events icon in the Properties window to display available events for the report. Double-click FetchData. This creates an event-handling method for the report's FetchData event. Add code to the handler to retrieve information to populate the report fields.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the FetchData event. try { reader.Read(); Fields["CategoryID"].Value = reader["categories.CategoryID"].ToString(); Fields["CategoryName"].Value = reader["CategoryName"].ToString(); Fields["ProductName"].Value = reader["ProductName"].ToString(); Fields["UnitsInStock"].Value = reader["UnitsInStock"].ToString(); Fields["Description"].Value = reader["Description"].ToString(); Fields["TotalLabel"].Value = "Total Number of " + reader["CategoryName"].ToString() + ":"; eArgs.EOF = false; } catch { eArgs.EOF = true; }
Visual Basic.NET code. Paste INSIDE the ReportEnd event. reader.Close() connection.Close() To write the code in C# 1. 2. 3. 4. Back in design view, click in the gray area below the report to select it. Click the events icon in the Properties window to display available events for the report. Double-click ReportEnd. This creates an event-handling method for the report's ReportEnd event. Add code to the handler to close the connection.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the ReportEnd event. reader.Close(); connection.Close();
Subreport Walkthroughs
Follow step-by -step tutorials as you create Visual Studio projects using the ActiveReports subreport control. You can use the subreport control to embed a report within another report. Subreports are executed each time the parent section (i.e. the section in which the Subreport control is placed) is printed. Some ways to use subreports include:
Repeating a group of relational data (for example, a list of orders in the main report, with ordered items in the subreport) Using multiple data sources within a report Creating multiple detail sections within a report
Adding a main report and a subreport to a Visual Studio project Connecting the main report to a data source Adding controls to the main report to display data and contain the subreport Adding controls to the subreport to display data Adding code to save the current record's CategoryID for use in the subreport's SQL query Adding code to create an instance of the subreport Adding code to assign a data source for the subreport
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
To add controls to the main report to display data and contain the subreport
Drag a Label control onto the Page Header section of rptMain, setting the properties as indicated: Label Properties Size Font Size Name Text Location 5.75, 0.25 in 14 lblProductsbyCategory Products by Category 0, 0 in Drag the following controls onto the Detail section of rptMain, setting the properties as indicated: Detail section controls Control Miscellaneous Name Text Location Label Bold lblCategoryName Category Name: 0, 0.05 in TextBox DataField = CategoryName txtCategoryName1 1.15, 0.05 in Label Bold lblProducts Products: 2.4, 0.05 in SubReport Size = 2.25, 1 in SubReport1 2.25, 0.05 in DataField = CategoryID TextBox txtCategoryID1 Visible = False
3. 4.
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste JUST ABOVE the ReportStart event.
The following example shows what the code for the method looks like. C# code. Paste JUST ABOVE the ReportStart event.
private rptSub rpt; private string categoryIDString; private DataDynamics.ActiveReports.DataSources.OleDBDataSource childDataSource = new DataDynamics.Active C# code. Paste INSIDE the ReportStart event. rpt = new rptSub();
Set the connection string for the OleDBDataSource for the subreport Set the SQL query for the new data source and pass in the current record's CategoryID Set the data source of the subreport to the data source Assign rptSub to the SubReport control
To write the code in Visual Basic The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the Format event.
childDataSource.ConnectionString = CType(Me.DataSource, DataDynamics.ActiveReports.DataSources.OleDBData childDataSource.SQL = "SELECT * FROM Products WHERE CategoryID = " + Me.txtCategoryID1.Value.ToString rpt.DataSource = childDataSource Me.SubReport1.Report = rpt To write the code in C# C# code. Paste INSIDE the Format event.
childDataSource.ConnectionString = ((DataDynamics.ActiveReports.DataSources.OleDBDataSource)this.DataSou childDataSource.SQL = "SELECT * FROM Products WHERE CategoryID = " + this.txtCategoryID1.Value.ToString( rpt.DataSource = childDataSource; this.subReport1.Report = rpt;
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. This walkthrough illustrates how to set up embedded subreports. This walkthrough is split up into the following activities:
Creating parent, child, and grandparent reports Connecting each report to a data source Adding controls to each report to display the data Adding code to display reports in the subreport controls Tip: For basic steps like viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
2. 3. 4. 5. 6.
On the "OLE DB" tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query SQL Query
SELECT Employees.EmployeeID, Employees.LastName, Employees.FirstName, Employees.Extension, Customers. FROM Customers, Employees ORDER BY Employees.EmployeeID, Customers.CustomerID 7. Click OK to save the data source and return to the report design surface. Note: This query joins the Employees table for the parent report to the Customers table for the subreport.
2. 3. 4. 5. 6.
On the "OLE DB" tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query SQL Query SELECT Customers.*, Employees.EmployeeID, Orders.OrderID FROM Employees INNER JOIN (Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) ON Employees.EmployeeID = Orders.EmployeeID WHERE CustomerID = '<%CustomerID%>'
7.
Click OK to save the data source and return to the report design surface. Note: This SQL query uses parameters syntax: '<%CustomerID%>'. For more information on parameters, see the Parameters topic.
3. 4. 5.
Set the Height property of the page header section to 0.3 . Set the CanShrink property of the Detail section to True to eliminate white space. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the group header section and set the properties of each textbox as indicated. Group header fields DataField EmployeeID LastName FirstName Extension Name Location Size txtEmployeeID1 0, 0.3 in 1, 0.2 in txtLastName1 1.05, 0.3 in 1.35, 0.2 in txtFirstName1 2.5, 0.3 in 1.3, 0.2 in txtExtension1 3.85, 0.3 in 1, 0.2 in
6.
Drag the following controls from the ActiveReports Toolbox onto the indicated section of rptEmployees, setting the properties as indicated. Other controls Control Label Section Name Text Customer Orders by Employee Employee ID Last Name First Name Extension Miscellaneous Location Font size = 14 Alignment = Center Bold Bold Bold Bold 0, 0 in Size 6.5, 0.25 in in in in in
PageHeader label1
Label GroupHeader label2 Label GroupHeader label3 Label GroupHeader label4 Label GroupHeader label5 Subreport Detail subReport1
Label
label2
Contact Name
Bold
2, 0 in
Label
label3
Phone
Bold
4.2, 0 in
TextBox
textBox1
CompanyName
0, 0.29 in
TextBox
textBox2
ContactName
2, 0.29 in
TextBox
textBox3
Phone
4.2, 0.29 in
Label
label4
Order ID
2, 0.604 in
Label
label5
Order Date
SubReport subReport1
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the ReportStart event. Me.subReport1.Report = New rptCustomers() To write the code in C# 1. 2. 3. 4. Click in the gray area below rptEmployees to select it. Click 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 create a new instance of the subreport.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the ReportStart event.
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the ReportStart event.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the ReportStart event.
Connecting the parent report to an XML data source Adding controls to display the data Adding code to create a new instance of the subreport Adding code to pass a subset of the parent report's data to the subreport Tip: For basic steps like viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the XML Customer database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\customer.xml. When you have finished this walkthrough, you will have a report that looks similar to the following.
3. 4. 5.
In the tabs along the top of the dialog, select XML. Click the ellipsis button beside File URL to browse for the access path to Customer.xml and click Open. (The default installation path is C:\Program Files\GrapeCity\ActiveReports 6\Data\customer.xml.) In the Recordset Pattern field, enter //CUSTOMER.
3. 4.
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste JUST ABOVE the ReportStart event. Dim rpt As rptSub Visual Basic.NET code. Paste INSIDE the ReportStart event. rpt = New rptSub
The following example shows what the code for the method looks like. C# code. Paste JUST ABOVE the ReportStart event. private rptSub rpt; C# code. Paste INSIDE the ReportStart event. rpt = new rptSub();
To add code to pass a subset of the parent report's data to the subreport
1. 2. Double-click in the detail section of the design surface of rptMain to create a detail_Format event. Add code to the handler to:
Create a new DataDynamics XMLDataSource Type cast the new data source as rptMain's data source and set the NodeList to the "ORDER/ITEM" field Display rptSub in the subreport control Pass the new data source to the subreport
To write the code in Visual Basic The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the Format event.
Dim xmlDS As New DataDynamics.ActiveReports.DataSources.XMLDataSource xmlDS.NodeList = CType(CType(Me.DataSource, DataDynamics.ActiveReports.DataSources.XMLDataSource).Fi rpt.DataSource = xmlDS Me.SubReport1.Report = rpt To write the code in C# The following example shows what the code for the method looks like. C# code. Paste INSIDE the Format event.
DataDynamics.ActiveReports.DataSources.XMLDataSource xmlDS = new DataDynamics.ActiveReports.DataSourc xmlDS.NodeList = (System.Xml.XmlNodeList)((DataDynamics.ActiveReports.DataSources.XMLDataSource) this rpt.DataSource = xmlDS; this.SubReport1.Report = rpt;
Connecting three reports to data sources Adding controls to each report to display data Creating a Windows Form Viewer Adding code to pass hyperlink values to parameters and open the drill-down report Adding code to set hyperlink properties to go back to the previous report Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have reports that look similar to the following.
3. 4. 5. 6. 7.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query SQL Query SELECT CompanyName, ContactName, Phone, CustomerID FROM Customers ORDER BY CustomerID
8. 9. 10.
Click OK to save the data source and return to the report design surface. On rptOrders, click the gray report DataSource icon on the Detail section band and connect it to Nwind.mdb. In the Query field, enter the following SQL query SQL Query
SELECT Orders.OrderID, Orders.CustomerID, Orders.OrderDate, Orders.ShippedDate, [Order Details].Produ Products.ProductName, [Order Details].UnitPrice, [Order Details].Quantity, [Order Details].Discount FROM Products INNER JOIN (Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].Order ON Products.ProductID = [Order Details].ProductID WHERE Orders.CustomerID = '<%CustomerID||ALFKI%>' ORDER BY Orders.OrderID, Products.ProductName 11. Click OK to save the data source and return to the report design surface. Note: The SQL queries for rptOrders and rptProductDetails use parameters syntax: '<% CustomerID||ALFKI%>' and <%ProductID||1%>. Using a default value allows the Report Explorer to populate so you can drag fields onto the report. For more information on parameters, see the Parameters topic. On rptProductDetails, click the gray report DataSource icon on the Detail section band and connect it to Nwind.mdb. In the Query field, enter the following SQL query SQL Query
12. 13.
SELECT Products.ProductID, Products.ProductName, Suppliers.CompanyName, Categories.CategoryName, Prod Products.UnitPrice, Products.UnitsInStock, Products.UnitsOnOrder, Products.ReorderLevel, Products.Dis FROM Categories INNER JOIN (Suppliers INNER JOIN Products ON Suppliers.SupplierID = Products.SupplierID) ON Categories.CategoryID = Products.CategoryID WHERE Products.ProductID = <%ProductID||1%> 14. Click OK to save the data source and return to the report design surface.
2.
Label
PageHeader 0, 0 in
6.5, 0.198 in
PageHeader 0, 0.26 in
1.1, 0.198 in
PageHeader 2.6, 0.26 in 1, 0.198 in PageHeader 4.3, 0.26 in 1, 0.198 in PageHeader 5.5, 0.26 in 1, 0.198 in 0, 0 2.6, 4.3, 5.5, in 0 in 0 in 0 in 2.55, 0.2 in 1.6, 0.2 in 1, 0.2 in 1, 0.2 in CompanyName ContactName Phone CustomerID
(Name) = txtCustomerID1
Label 3. 4.
Right-click the report and select Insert, then GroupHeader/Footer. Set the group header properties as follows:
5.
Add the following controls to the group header section, setting their properties as indicated: Group header controls for rptOrders Control Label Location 0, 0 in Miscellaneous BackColor = PaleTurquoise 1, 0.198 in Order Number Font Style = Bold 0.5, 0.2 in OrderID BackColor = PaleTurquoise Alignment = Right 1, 0.198 in Order Date Font Style = Bold Alignment = Right 1, 0.2 in OrderDate OutputFormat = MM/dd/yy Alignment = Right 1, 0.198 in Date Shipped Font Style = Bold Alignment = Right 1, 0.2 in ShippedDate OutputFormat = MM/dd/yy X1 = 0 X2 = 6.5 Y1 = 0.2 Size DataField Text
0, 0.29 in 1, 0.29 in
1, 0.198 in 1, 0.198 in
= = = = = = = = =
Click in the grey area below the report to select it, and set the ShowParameterUI property to False to avoid requesting parameters from the user. Select the detail section, and set its CanShrink property to True. From the Report Explorer, drag the following fields onto the detail section of rptOrders, setting their properties as indicated: Detail section controls for rptOrders Miscellaneous Alignment = Right ProductID 0, 0 in 0.7, 0.2 in (Name) = txtProductID1 ProductName 1, 0 in 2.2, 0.2 in Alignment = Right UnitPrice 3.34, 0 in 1, 0.2 in OutputFormat = $#,##0.00 Quantity 4.44, 0 in 1, 0.2 in Alignment = Right Alignment = Right Discount 5.5, 0 in 1, 0.2 in OutputFormat = 0% Field Location Size
Add the following labels to the detail section, setting their properties as indicated: rptProductDetails labels Location 0, 0 in 1, 0, 0.28 in 1, 0, 0.54 in 1, 0, 0.83 in 1, 0, 1.12 in 1, 4.4, 0 in 1, 4.4, 0.28 in 1, 4.4, 0.54 in 1, 4.4, 0.83 in 1, Size 0.198 0.198 0.198 0.198 0.198 0.198 0.198 0.198 0.198 Text Miscellaneous in Product Name Font Style = Bold in Supplier Font Style = Bold in Qty per Unit Font Style = Bold in Units in Stock Font Style = Bold in Reorder Level Font Style = Bold in Category Font Style = Bold in Discontinued Font Style = Bold in Unit Price Font Style = Bold in Units Pending Font Style = Bold
3.
From the Report Explorer, drag the following fields onto the detail section, setting their properties as indicated: rptProductDetails fields Field ProductName CompanyName QuantityPerUnit UnitsInStock Location Size 1.14, 0 in 2.05, 0.2 in 1.14, 0.28 in 2.05, 0.2 in 1.14, 0.54 in 2.28, 0.2 in 1.14, 0.83 in 1, 0.2 in Miscellaneous
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste JUST ABOVE the Viewer HyperLink event. Private LastCustID As String Visual Basic.NET code. Paste JUST BELOW the Viewer HyperLink event. Private Sub ClearViewer() Dim doc As DataDynamics.ActiveReports.Document.Document = viewer1.Document viewer1.Document = Nothing viewer1.Refresh() doc.Dispose() doc = Nothing End Sub Visual Basic.NET code. Paste INSIDE the Viewer HyperLink event. 'Process hyperlink text. Dim report, parameter As String If e.HyperLink.IndexOf("\") > 0 And e.HyperLink.Length > 2 Then report = e.HyperLink.Substring(0, e.HyperLink.IndexOf("\")).ToUpper() parameter = e.HyperLink.Substring(e.HyperLink.IndexOf("\") + 1) Else MessageBox.Show("Cannot process hyperlink.") Return End If Dim rpt As DataDynamics.ActiveReports.ActiveReport = Nothing 'Determine which report to run. If report.CompareTo("CUSTOMERS") = 0 Then rpt = New rptCustomers() ElseIf report.CompareTo("ORDERS") = 0 Then rpt = New rptOrders() rpt.Parameters("CustomerID").Value = parameter LastCustID = parameter ElseIf report.CompareTo("PRODUCTS") = 0 Then rpt = New rptProductDetails(LastCustID) rpt.Parameters("ProductID").Value = parameter Else MessageBox.Show("Invalid report ID") End If 'Check whether a report object exists. If so, run and display it. If rpt IsNot Nothing Then
The following example shows what the code for the method looks like. C# code. Paste JUST ABOVE the viewer HyperLink event. private string LastCustID; C# code. Paste JUST BELOW the viewer HyperLink event. private void ClearViewer() { DataDynamics.ActiveReports.Document.Document doc = viewer1.Document; viewer1.Document = null; viewer1.Refresh(); doc.Dispose(); doc = null; } C# code. Paste INSIDE the viewer HyperLink event. //Process hyperlink text. string report, parameter; if (e.HyperLink.IndexOf('\\') > 0 && e.HyperLink.Length > 2) { report = e.HyperLink.Substring(0, e.HyperLink.IndexOf('\\')).ToUpper(); parameter = e.HyperLink.Substring(e.HyperLink.IndexOf('\\') + 1); } else { MessageBox.Show("Cannot process hyperlink."); return; } DataDynamics.ActiveReports.ActiveReport rpt = null; //Determine which report to run. if (report.CompareTo("CUSTOMERS") == 0) { rpt = new rptCustomers(); } else if (report.CompareTo("ORDERS") == 0) { rpt = new rptOrders(); rpt.Parameters["CustomerID"].Value = parameter; LastCustID = parameter; } else if (report.CompareTo("PRODUCTS") == 0) { rpt = new rptProductDetails(LastCustID); rpt.Parameters["ProductID"].Value = parameter; } else
To add code to create a parameter to hold the previous report for rptProductDetails
1. 2. Right-click the report and select View Code . Add code to create a parameter for the previous report. To write the code in Visual Basic.NET Visual Basic.NET code. Paste JUST BELOW the Public Class rptProductDetails line. 'The prevRptParam member is used to track the parameter for 'returning to the orders report for the correct customer Private prevRptParam As String Public Sub New(ByVal previousRptParameter As String) InitializeComponent() prevRptParam = previousRptParameter End Sub To write the code in C# C# code. Paste JUST BELOW the public partial class rptProductDetails() line.
Connecting the report to a data source Adding controls and formatting the report Adding fields and text to the RichText control Using the FetchData event to conditionally format data Adding code to update RichText fields with current date and conditional values Adding code to send the group subtotal value to the RichText field Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you complete this walkthrough, you will have a report that looks similar to the following:
3. 4.
On the "OLE DB" tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button.
DataField: CustomerID (This sets a new group for each customer.) Height: 2.5 KeepTogether: True
3.
Height: 1.1 KeepTogether: True NewPage: After (This ensures that a new page begins after each customer's letter has finished rendering.)
4.
CanShrink: True
5.
Height: 0.8
6.
Add the following controls to the PageHeader section and set the properties as indicated. Page header controls Control Miscellaneous Font Size = 36 Label Style = Bold Text = GrapeCity PictureAlignment = TopLeft Picture Image (click ellipsis, navigate to C:\Program Files\GrapeCity\ActiveReports 6 \Introduction and select itopimage1.gif) Size 3.7, 0.65 in 2.9, 0.65 in Location 0, 0 in
3.6, 0 in
7.
In the Report Explorer, expand the Fields node, then the Bound node. Drag the SubTotal field onto the group header section, add the following controls from the ActiveReports toolbox, and set the properties as indicated. Group header controls 1, 0.2 in Control DataField Textbox SubTotal RichText Label Label Label Size 1, 0.2 in Text (Name) txtSubtotal1 (Name) Miscellaneous Location OutputFormat = Currency Visible = False 5, 0 in SummaryType = SubTotal SummaryGroup = GroupHeader1 AutoReplaceFields = True 0, 0 in Bold 0.875, 2.25 in Bold 1.875, 2.25 in Bold 4.375, 2.25 in Alignment = Right
7.
Add the following text to the RichText control box after all of the fields: Paste into the RichText control Dear [!ContactName],
Thank you for your business. Below is a list of your orders for the past year with a total of [!SubTo Please take this opportunity to review each order and total for accuracy. Call us at 1-800 any questions or concerns. 8. Arrange the text and fields within the control as you would in any text editor to look like the following.
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste JUST ABOVE the FetchData event. Dim region As String Visual Basic.NET code. Paste INSIDE the FetchData event. 'If there is no region for the customer, display nothing If Fields("Region").Value Is System.DBNull.Value Then region = "" Else 'If there is a region, add a comma and a space region = ", " + Fields("Region").Value End If To write the code in C# 1. 2. 3. 4. Back in design view, click in the gray area below the report to select it. Click the events icon in the Properties window to display available events for the report. Double-click FetchData. This creates an event-handling method for the report's FetchData event. Add code to the handler to add a comma and a space if there is a Region value for the customer's address.
The following example shows what the code for the method looks like. C# code. Paste JUST ABOVE the FetchData event. string region; C# code. Paste INSIDE the FetchData event. if(Fields["Region"].Value is System.DBNull) region = ""; else region = ", " + Fields["Region"].Value.ToString();
To add code to update RichText fields with the current date and conditional values
1. 2. Double-click in the group header section of the report to create an event-handling method for the group header's Format event. Add code to the handler to:
Replace the Date field in the RichText control with the current system date Replace the Region field with the conditional value created in the FetchData event
To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Group Header Format event.
To add code to send the group subtotal value to the RichText field
1. 2. 3. 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 GroupHeader1. 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 GroupHeader1_BeforePrint event. Note: We use the BeforePrint event instead of the Format event to get the final value of the subtotal field just prior to printing. For more information on section event usage, see the Section Events topic. Add code to the handler to replace the value of the Subtotal field in the RichText control with the value of the hidden textbox in the group header. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Group Header BeforePrint event. 'Use the value from the hidden group subtotal field Me.RichTextBox1.ReplaceField("SubTotal", Me.txtSubtotal1.Text) To write the code in C# C# code. Paste INSIDE the Group Header BeforePrint event. //Use the value from the hidden group subtotal field this.RichTextBox1.ReplaceField("SubTotal", this.txtSubtotal1.Text);
4.
Run Time Layouts Describes how to create and modify report layouts dynamically. Run Time Data Sources Describes how to change the report data source at run time using the ReportStart event.
Connecting the report to a data source Adding controls to the Windows Form to display fields and a viewer Generating a dataset for the Windows Form Adding code to create the report layout Adding code to fill the check list with fields and to launch the report Adding code to alternate colors in the detail section Adding code to the ReportStart event to call the report layout code Adding code to the button's Click event to collect the selected values and launch the report Adding code to to enable the button when fields are selected Adding code to the Form_Load event to call the fill check list code Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have completed this walkthrough, you will have an application that looks similar to the following.
5. 6.
In the design view of your Windows form, expand the Data section of the Visual Studio Toolbox and double-click DataSet to open the Add Dataset dialog. Under Typed dataset, select YourProjectName.NWINDDataSet and click OK to make the dataset available to your Windows form. NwindDataSet1 appears in the tray below the form.
Create an array of fields Create an option for whether to use groups Set properties on the report sections Add textboxes and labels to the report based on the array of fields Handle exceptions
To write the code in Visual Basic.NET The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the class declaration of the report. Private m_arrayFields As ArrayList Private m_useGroups As Boolean 'Create an array to hold the fields selected by the user Public WriteOnly Property FieldsList() As ArrayList Set(ByVal Value As ArrayList) m_arrayFields = Value End Set End Property 'Create a property to hold the user's grouping choice Public WriteOnly Property UseGroups() As Boolean Set(ByVal Value As Boolean) m_useGroups = False m_useGroups = Value End Set End Property Private m_defaultHeight As Single = 0.2F Private m_defaultWidth As Single = 4.0F Private m_currentY As Single = 0.0F 'Set up report formatting and add fields based on user choices Private Sub constructReport() Try Me.Detail1.CanGrow = True
Me.Detail1.CanShrink = True Me.Detail1.KeepTogether = True If m_useGroups = True Then 'If the user wants grouping, add a group header and footer and set the grouping field Me.Sections.InsertGroupHF() CType(Me.Sections("GroupHeader1"), GroupHeader).DataField = "CategoryID" Me.Sections("GroupHeader1").BackColor = System.Drawing.Color.Gray Me.Sections("GroupHeader1").CanGrow = True Me.Sections("GroupHeader1").CanShrink = True CType(Me.Sections("GroupHeader1"), GroupHeader).RepeatStyle = RepeatStyle.OnPageIncludeNoDetai 'Add a textbox to display the group's category ID Dim txt As New TextBox txt.DataField = "CategoryID" txt.Location = New System.Drawing.PointF(0.0F, 0) txt.Width = 2.0F txt.Height = 0.3F txt.Style = "font-weight: bold; font-size: 16pt" Me.Sections("GroupHeader1").Controls.Add(txt) End If Dim i As Integer For i = 0 To m_arrayFields.Count - 1 'For all fields selected by the user (except CategoryID) create a label and a textbox If m_arrayFields(i).ToString <> "CategoryID" Then Dim lbl As New Label 'Set the label to display the name of the selected field lbl.Text = m_arrayFields(i) + ":" 'Set the location of each label '(m_currentY gets the height of each control added on each iteration) lbl.Location() = New System.Drawing.PointF(0.0F, m_currentY) lbl.Width = 0.9F lbl.Height = m_defaultHeight Me.Detail1.Controls.Add(lbl) Dim txt As New TextBox 'Set the textbox to display data txt.DataField = m_arrayFields(i) 'Set the location of the textbox txt.Location = New System.Drawing.PointF(1.0F, m_currentY) txt.Width = m_defaultWidth txt.Height = m_defaultHeight Me.Detail1.Controls.Add(txt) 'Set the textbox to use currency formatting if the field is UnitPrice If m_arrayFields(i) = "UnitPrice" Then txt.OutputFormat = "$#.00" End If 'Increment the vertical location by adding the height of the added controls m_currentY = m_currentY + m_defaultHeight End If Next Catch ex As Exception System.Windows.Forms.MessageBox.Show("Error in Report-constructReport: " + ex.Message, "Project E End Try End Sub To write the code in C# The following example shows what the code for the method looks like. C# code. Paste INSIDE the class declaration of the report. private ArrayList m_arrayFields; //Create an array to hold the fields selected by the user public ArrayList FieldsList { set{m_arrayFields = value;} } private bool m_useGroups = false; //Create a property to hold the user's grouping choice public bool UseGroups {
set{m_useGroups = value;} } float m_defaultHeight = .2f; float m_defaultWidth = 4f; float m_currentY = 0f; //Set up report formatting and add fields based on user choices private void constructReport() { try { this.detail.CanGrow = true; this.detail.CanShrink = true; this.detail.KeepTogether = true; if(m_useGroups) { //If the user wants grouping, add a group header and footer and set the grouping field this.Sections.InsertGroupHF(); ((GroupHeader)this.Sections["GroupHeader1"]).DataField = "CategoryID"; this.Sections["GroupHeader1"].BackColor = System.Drawing.Color.Gray; this.Sections["GroupHeader1"].CanGrow = true; this.Sections["GroupHeader1"].CanShrink = true; ((GroupHeader)this.Sections["GroupHeader1"]).RepeatStyle = RepeatStyle.OnPageIncludeNoDetail; this.Sections["GroupFooter1"].Height = 0; //Add a textbox to display the group's category ID TextBox txt = new TextBox(); txt.DataField = "CategoryID"; txt.Location = new System.Drawing.PointF(0f,0); txt.Width =2f; txt.Height = .3f; txt.Style = "font-weight: bold; font-size: 16pt;"; this.Sections["GroupHeader1"].Controls.Add(txt); } for(int i=0;i<m_arrayFields.Count;i++) { if(!m_useGroups || (m_useGroups && m_arrayFields[i].ToString() != "CategoryID")) //'For all fields selected by the user (except CategoryID) create a label and a textbox { Label lbl = new Label(); //Set the label to display the name of the selected field lbl.Text = m_arrayFields[i].ToString() + ":"; //Set the location of each label //(m_currentY gets the height of each control added on each iteration) lbl.Location = new System.Drawing.PointF(0f,m_currentY); lbl.Width =.9f; lbl.Height = m_defaultHeight; this.detail.Controls.Add(lbl); TextBox txt = new TextBox(); //Set the textbox to display data txt.DataField = m_arrayFields[i].ToString(); //Set the location of the textbox txt.Location = new System.Drawing.PointF(1f,m_currentY); txt.Width = m_defaultWidth; txt.Height = m_defaultHeight; this.detail.Controls.Add(txt); //Increment the vertical location by adding the height of the added controls m_currentY = m_currentY + m_defaultHeight; } } } catch(Exception ex) { System.Windows.Forms.MessageBox.Show("Error in Report-constructReport: " + ex.Message,"Project Err } }
To add code to fill the check list with fields and to launch the report
1. Right-click the Windows Form and select View Code.
To write the code in Visual Basic.NET The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the class declaration of the form.
Dim i As Integer Dim c As Integer Dim m_arrayField As New ArrayList() Private Sub fillCheckBox() For i = 0 To Me.NwindDataSet1.Tables.Count - 1 For c = 0 To Me.NwindDataSet1.Tables(i).Columns.Count - 1 Me.clbFields.Items.Add(Me.NwindDataSet1.Tables(i).Columns(c).ColumnName) Next Next End Sub Private Sub launchReport() Dim rpt As New rptRunTime() Try rpt.FieldsList = m_arrayField rpt.UseGroups = chkGroup.Checked rpt.DataSource = Me.NwindDataSet1.Products.TableName Viewer1.Document = rpt.Document rpt.Run() Catch ex As Exception System.Windows.Forms.MessageBox.Show(Me, "Error in launchReport: " + ex.Message, "Project Err End Try End Sub To write the code in C# The following example shows what the code for the method looks like. C# code. Paste INSIDE the class declaration of the form.
ArrayList m_arrayField = new ArrayList(); private void fillCheckBox() { for(int i = 0; i < this.dataSet11.Tables.Count; i++) { for(int c = 0; c < this.dataSet11.Tables[i].Columns.Count; c++) { this.clbFields.Items.Add(this.dataSet11.Tables[i].Columns[c].ColumnName); } } } private void launchReport() { try { rptRunTime rpt = new rptRunTime(); rpt.FieldsList = m_arrayField; rpt.UseGroups = chkGroup.Checked; rpt.DataSource = this.dataSet11.Products.TableName; this.viewer1.Document = rpt.Document; rpt.Run(); } catch(Exception ex) { MessageBox.Show(this,"Error in launchReport: " + ex.Message,"Project Error",MessageBoxButtons.OK,M } }
Adding code to the ReportStart event to call the report layout code
1. 2. Double-click in the gray area below rptRunTime to create an event-handling method for rptRunTime's ReportStart event. Add code to call the ConstructReport method. To write the code in Visual Basic.NET The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the ReportStart event. constructReport() To write the code in C# The following example shows what the code for the method looks like. C# code. Paste INSIDE the ReportStart event. constructReport();
Adding code to the button's Click event to collect the selected values and launch the report
1. 2. Double-click btnGenRep to create an event-handling method for its Click event. Add code to the handler to collect the selected values and launch the report. To write the code in Visual Basic.NET The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the button click event. Me.m_arrayField.Clear() For i = 0 To Me.clbFields.CheckedItems.Count - 1
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the SelectedIndexChanged event. If Me.clbFields.CheckedItems.Count < 0 Then Me.btnGenRep.Enabled = False Else Me.btnGenRep.Enabled = True End If To write the code in C# 1. 2. On the form, click clbFields to select it. Click on the events icon in the Properties Window to display available events and double-click SelectedIndexChanged. This creates an event-handling method for the clbFields_SelectedIndexChanged event. Add code to the handler to enable the button when fields are selected.
3.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the SelectedIndexChanged event. if(this.clbFields.CheckedItems.Count>0) { this.btnGenRep.Enabled = true; } else { this.btnGenRep.Enabled = false; }
Adding code to the Form_Load event to call the fill check list code
1. 2. Double-click the title bar of the form. This creates an event-handling method for the Windows Form_Load event. Add code to the handler to call the fillCheckBox() method to populate clbFields with field values and to handle exceptions. To write the code in Visual Basic.NET The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the Form Load event. Try
fillCheckBox() Catch ex As Exception System.Windows.Forms.MessageBox.Show(Me, "Error in Form1_Load: " + ex.Message, "Project Error", Messag End Try To write the code in C# The following example shows what the code for the method looks like. C# code. Paste INSIDE the Form Load event.
try { fillCheckBox(); } catch(Exception ex) { MessageBox.Show(this,"Error in Form1_Load: " + ex.Message,"Project Error", + MessageBoxButtons.OK,Mess }
Connecting the report to a design time data source Adding controls to the report to display data Adding code to find the database path Adding code to change the data source at run time Adding code to close the data connection Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB.
string dbPath = getDatabasePath(); string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath + "\\NWIND.mdb"; conn = new System.Data.OleDb.OleDbConnection(connString); System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("SELECT * FROM Products WHERE Un conn.Open(); reader = cmd.ExecuteReader(); this.DataSource = reader;
The following example shows what the code for the method looks like. Visual Basic.NET code. Paste INSIDE the ReportEnd event. reader.Close() conn.Close() To write the code in C# 1. 2. 3. 4. Click in the gray area below rptModifyDS to select the report. Click the events icon in the Properties Window to display available events for the report. Double-click ReportEnd. This creates an event-handling method for the ReportEnd event. Add code to the handler to close the data connection.
The following example shows what the code for the method looks like. C# code. Paste INSIDE the ReportEnd event. reader.Close(); conn.Close();
PDF
To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Page Load event. Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1 rpt.Run() If Me.PdfExport1 Is Nothing Then Me.PdfExport1 = New DataDynamics.ActiveReports.Export.Pdf.PdfExport End If PdfExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "attachment;filename=MyExport.pdf") Response.BinaryWrite(m_stream.ToArray()) Response.End() To write the code in C# C# code. Paste INSIDE the Page Load event. System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.pdfExport1 == null) { this.pdfExport1 = new DataDynamics.ActiveReports.Export.Pdf.PdfExport(); } pdfExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition","attachment;filename=MyExport.pdf"); Response.BinaryWrite(m_stream.ToArray()); Response.End();
Excel
To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Page Load event.
TIFF
To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Page Load event. Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1() rpt.Run() If Me.TiffExport1 Is Nothing Then Me.TiffExport1 = New DataDynamics.ActiveReports.Export.Tiff.TiffExport End If Me.TiffExport1.CompressionScheme = DataDynamics.ActiveReports.Export.Tiff.CompressionScheme.None Me.TiffExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "image/tiff" Response.AddHeader("content-disposition", "inline; filename=MyExport.tiff") Response.BinaryWrite(m_stream.ToArray()) Response.End() To write the code in C# C# code. Paste INSIDE the Page Load event. System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.tiffExport1 == null) { this.tiffExport1 = new DataDynamics.ActiveReports.Export.Tiff.TiffExport(); } tiffExport1.CompressionScheme = DataDynamics.ActiveReports.Export.Tiff.CompressionScheme.None; tiffExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "image/tiff"; Response.AddHeader("content-disposition","inline; filename=MyExport.tiff"); Response.BinaryWrite(m_stream.ToArray()); Response.End();
RTF
To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Page Load event. Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1() rpt.Run() If Me.RtfExport1 Is Nothing Then Me.RtfExport1 = New DataDynamics.ActiveReports.Export.Rtf.RtfExport End If RtfExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "application/msword" Response.AddHeader("content-disposition", "inline; filename=MyExport.rtf") Response.BinaryWrite(m_stream.ToArray()) Response.End() To write the code in C# C# code. Paste INSIDE the Page Load event. System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.rtfExport1 == null) { this.rtfExport1 = new DataDynamics.ActiveReports.Export.Rtf.RtfExport(); } rtfExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "application/msword"; Response.AddHeader("content-disposition","inline; filename=MyExport.rtf"); Response.BinaryWrite(m_stream.ToArray()); Response.End();
Plain Text
To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Page Load event. Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1() rpt.Run() If Me.TextExport1 Is Nothing Then Me.TextExport1 = New DataDynamics.ActiveReports.Export.Text.TextExport End If TextExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "text/plain" Response.BinaryWrite(m_stream.ToArray()) Response.End() To write the code in C# C# code. Paste INSIDE the Page Load event. System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.textExport1 == null) { this.textExport1 = new DataDynamics.ActiveReports.Export.Text.TextExport(); } textExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "text/plain"; Response.BinaryWrite(m_stream.ToArray()); Response.End();
Adding the Html Export to a Web project Creating a public class for the HTML outputter Adding code to export the report Adding a folder for report output
2.
Drag the HtmlExport control from the Visual Studio toolbox onto the ASPX design view. See Adding ActiveReports controls for help if you need to add it to the toolbox. Note: You can instead add a reference to ActiveReports.HtmlExport in the Solution Explorer if you prefer.
The following example shows what the complete code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste JUST ABOVE the class. Imports Imports Imports Imports Imports Imports System System.IO System.Web System.Text DataDynamics.ActiveReports DataDynamics.ActiveReports.Export.Html
Visual Basic.NET code. Paste INSIDE the class. Implements IOutputHtml 'The http context of the request. Private context As System.Web.HttpContext = Nothing 'The directory in which to save filename--this ensures that the filename 'is unique. Private dirToSave As System.IO.DirectoryInfo = Nothing Public mainPage As String = "" Public Sub New(ByVal context As System.Web.HttpContext) If context Is Nothing Then Throw New ArgumentNullException("context") End If Me.context = context Dim dirName As String = context.Server.MapPath("ReportOutput") Me.dirToSave = New DirectoryInfo(dirName) End Sub
#Region "Implementation of IOutputHtml" Public Function OutputHtmlData(ByVal info As DataDynamics.ActiveReports.Export.Html.HtmlOutputInfoArgs Dim temp As String = "" Select Case info.OutputKind Case HtmlOutputKind.BookmarksHtml Case HtmlOutputKind.FramesetHtml temp = Me.GenUniqueFileNameWithExtension(".html") Dim fs As New FileStream(temp, FileMode.CreateNew) Me.WriteStreamToStream(info.OutputStream, fs) fs.Close() Return temp Case HtmlOutputKind.HtmlPage 'Store the name of the main page so we can redirect the 'browser to it Me.mainPage = Me.GenUniqueFileNameWithExtension(".html") Dim fs As New FileStream(Me.mainPage, FileMode.CreateNew) Me.WriteStreamToStream(info.OutputStream, fs) fs.Close() Return Me.mainPage Case HtmlOutputKind.ImageJpg 'Create a file with a .jpg extension: temp = Me.GenUniqueFileNameWithExtension(".jpg") Dim fs As New FileStream(temp, FileMode.CreateNew) fs = File.Create(temp) Me.WriteStreamToStream(info.OutputStream, fs) fs.Close() Return temp Case HtmlOutputKind.ImagePng 'Create a file with a .png extension: temp = Me.GenUniqueFileNameWithExtension(".png") Dim fs As New FileStream(temp, FileMode.CreateNew) Me.WriteStreamToStream(info.OutputStream, fs) fs.Close() Return temp Case Else 'Default to html: temp = Me.GenUniqueFileNameWithExtension(".html") Dim fs As New FileStream(temp, FileMode.CreateNew) Me.WriteStreamToStream(info.OutputStream, fs) fs.Close() Return temp End Select End Function Public Sub Finish() Implements IOutputHtml.Finish End Sub #End Region Private Sub WriteStreamToStream(ByVal sourceStream As Stream, ByVal targetStream As Stream) 'Find the size of the source stream: Dim size As Integer = CType(sourceStream.Length, Integer) 'Create a buffer that same size Dim buffer(size) As Byte 'Move the source stream to the beginning sourceStream.Seek(0, SeekOrigin.Begin) 'Copy the sourceStream into our buffer sourceStream.Read(buffer, 0, size) 'Write out the buffer to the target stream targetStream.Write(buffer, 0, size) End Sub Private Function GenUniqueFileNameWithExtension(ByVal extensionWithDot As String) As String Dim r As New System.Random() Dim unique As Boolean = False Dim filePath As String = "" Dim iRandom As Integer = 0 'Generate a random name until it's unique
C# code. Paste INSIDE the class. //The http context of the request private System.Web.HttpContext context = null; //The directory in which to save filename--this ensures that the filename //is unique. private System.IO.DirectoryInfo dirToSave = null; public string mainPage = ""; public MyCustomHtmlOutputter(System.Web.HttpContext context) { if(context == null) { throw new ArgumentNullException("context"); this.context = context; string dirName = context.Server.MapPath("ReportOutput"); this.dirToSave = new DirectoryInfo(dirName); } } #region Implementation of IOutputHtml public string OutputHtmlData(DataDynamics.ActiveReports.Export.Html.HtmlOutputInfoArgs info) { string temp = ""; switch(info.OutputKind) { case HtmlOutputKind.BookmarksHtml: case HtmlOutputKind.FramesetHtml: { temp = this.GenUniqueFileNameWithExtension(".html"); FileStream fs = File.Create(temp); this.WriteStreamToStream(info.OutputStream, fs); fs.Close(); return temp; } case HtmlOutputKind.HtmlPage: { //Store the name of the main page so we can //redirect the browser to it this.mainPage = this.GenUniqueFileNameWithExtension(".html"); FileStream fs = File.Create(this.mainPage);
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Page Load event. Dim rpt As New rptCustHTML() Try rpt.Run(False) Catch eRunReport As Exception 'If the report fails to run, report the error to the user Response.Clear() Response.Write("<h1>Error running report:</h1>") Response.Write(eRunReport.ToString()) Return End Try 'Buffer this page's output until the report output is ready. Response.Buffer = True 'Clear any part of this page that might have already been buffered for output. Response.ClearContent() 'Clear any headers that might have already been buffered (such as the content type 'for an HTML page) Response.ClearHeaders() 'Tell the browser and the "network" that the resulting data of this page should be 'cached since this could be a dynamic report that changes upon each request. Response.Cache.SetCacheability(HttpCacheability.NoCache) 'Tell the browser this is an Html document so it will use an appropriate viewer. Response.ContentType = "text/HTML" 'Create the Html export object Dim HtmlExport1 As New DataDynamics.ActiveReports.Export.Html.HtmlExport() Dim outputter As New MyCustomHtmlOutputter(Me.Context) HtmlExport1.Export(rpt.Document, outputter, "") Response.Redirect("ReportOutput" + "/" + System.IO.Path.GetFileName(outputter.mainPage)) To write the code in C#
//Create the HTML export object DataDynamics.ActiveReports.Export.Html.HtmlExport html = new DataDynamics.ActiveReports.Export.Html.H //Export the report to HTML in this session's webcache MyCustomHtmlOutputter outputter = new MyCustomHtmlOutputter(this.Context); this.htmlExport1.Export(rpt.Document, outputter, ""); Response.Redirect("ReportOutput" + "/" + System.IO.Path.GetFileName(outputter.mainPage));
Web Services
ActiveReports provides support for web services to be used to return a dataset as a data source for a report or to return an ActiveReport document to show in a Windows Forms viewer. The following walkthroughs show how to create a simple web service for each scenario and how to create a Windows client application for each web service. DataSet Web Service Describes how to set up a simple web service that returns a dataset. DataSet Windows Application Describes how to set up a Windows client application for the dataset Web Service. Document Web Service Describes how to set up a simple web service that returns an ActiveReports document. Document Windows Application Describes how to set up a Windows client application for the ActiveReports Document Web Service. Important: In order to consume Web services in your Windows applications, you must set permissions to allow the ASP.NET user to consume the services. Ask your server administrator for help with this.
Creating an ASP.NET Web Service project Adding code to create the Web method Testing the Web service Publishing the Web service Creating a virtual directory in IIS
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB.
Private connString As String <WebMethod(Description:="Returns a DataSet containing all Products")> _ Public Function GetProduct() As Data.DataSet connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GrapeCity\ActiveReports 6\ Dim adapter As New Data.OleDb.OleDbDataAdapter("select * from products", connString) Dim ds As New Data.DataSet() adapter.Fill(ds, "Products") Return ds End Function To write the code in C# C# code. Paste OVER the existing WebMethod.
private static string connString = "Provider=Microsoft.Jet.OLEDB.4.0;C:\Program Files\GrapeCity\ActiveRe [WebMethod(Description="Returns a DataSet containing all Products")] public Data.DataSet GetProduct() { Data.OleDb.OleDbDataAdapter adapter; Data.DataSet ds; adapter = new Data.OleDb.OleDbDataAdapter("select * from products", connString); ds = new Data.DataSet(); adapter.Fill(ds, "Products"); return ds; }
Adding controls to a report Adding a web reference to the project Setting the report data source to the one returned by the Web service
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports for .NET 3.0\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
4.
To set the report data source to the one returned by the Web service
1. 2. Double-click the gray area below the report. This creates an event-handling method for the ReportStart event. Add code to the handler to use the web service dataset in the report.
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the ReportStart event. Dim ws As New localhost.Service Dim ds As New DataSet() ds = ws.GetProduct() Me.DataSource = ds Me.DataMember = "Products" To write the code in C# C# code. Paste INSIDE the ReportStart event. localhost.DataSetWS ws = new localhost.Service; DataSet ds = ws.GetProduct(); this.DataSource = ds; this.DataMember = "Products";
Creating an ASP.NET Web Service project Adding a report and connecting it to data Adding controls to the report Adding code to create the Web Method Testing the Web Service Publishing the Web Service
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. You must also add a reference in your project to the System.Data.OleDb namespace. When you have completed this walkthrough, you will have a Web Service that returns the contents of an ActiveReport as a byte array.
6. 7. 8. 9. 10.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query SQL Query SELECT * FROM Products INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID ORDER BY CategoryName
Change the Name property to ghCategories Change the DataField property to CategoryName Change the BackColor property to LightGray
3. 4.
In the Report Explorer, expand the Fields node, then the Bound node. Drag the following field onto ghCategories and set the properties as indicated. Field for ghCategories Field Size Location Miscellaneous Font size = 14 ForeColor = DarkGreen
Add a second GroupHeader/Footer section to the report to contain labels. Make the following changes to the new group header:
Change the Name property to ghProducts Change the BackColor property to WhiteSmoke
7.
Add labels with the following properties to ghProducts: Labels for ghProducts Name Text Location lblProductName Product Name 0, 0 in lblUnitPrice Unit Price 2.4, 0 in lblUnitsInStock Units in Stock 4, 0 in lblUnitsOnOrder Units on Order 5.5, 0 in
8. 9.
Set the CanShrink property of the detail section to True. From the Report Explorer, drag the following fields onto the detail section and set the properties as indicated. Controls for the detail section
Field Text Miscellaneous Location ProductName Product Name Size = 2.25, 0.2 in 0, 0 in OutputFormat = Currency UnitPrice Unit Price 2.4, 0 in Alignment = Right UnitsInStock Units In Stock Alignment = Right 4, 0 in UnitsOnOrder Units On Order Alignment = Right 5.5, 0
Creating a Visual Studio project Adding the ActiveReports Windows Forms viewer control to the form Adding a web reference to the project Displaying the content returned by the Document Web Service in the viewer Running the project
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
To display the content returned by the Document Web Service in the viewer
1. 2. Double-click on Form1 to create an event-handling method for the Form1_Load event. Add code to the handler to display the document Web service content in the viewer.
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the Form Load event. Dim ws As New localhost.Service Me.Viewer1.Document.Content = ws.GetProductsReport() To write the code in C# C# code. Paste INSIDE the Form Load event. localhost.Service ws = new localhost.Service(); this.viewer1.Document.Content = ws.GetProductsReport();
Adding controls to a report to display data Adding scripting to supply data for the controls Saving the report to an RPX file Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have completed this walkthrough, you will have a report that looks similar to the following.
BackColor: LightBlue CanShrink: True DataField: CategoryID GroupKeepTogether: All KeepTogether: True
5.
Add the following controls to the GroupHeader section and set the properties as indicated. Group header controls Control Miscellaneous BackColor = CadetBlue TextBox CategoryName 0, 0 in 6.5, 0.2 in Font Style = Bold Font Size = 12 TextBox Description 0, 0.2 in 6.5, 0.2 in BackColor = CadetBlue Label Product Name 0, 0.4 in 1, 0.2 in Font Style = Bold Font Style = Bold Label Units in Stock 5.5, 0.4 in 1, 0.2 in Alignment = Right DataField Text Location Size
6.
In the Report Explorer, expand the Fields node, then the Bound node, and drag the following fields onto the detail section, setting the properties as indicated. Detail section fields DataField Location Size Alignment ProductName 0, 0 in 5.5, 0.198 in UnitsInStock 5.5, 0 in 1, 0.198 in Right
7. 8.
Set the CanShrink property of the detail section to True. Select both of the text boxes in the detail section, right-click and select Format Border.
Select dark cyan in the color combo box Select the solid line in the Line Styles pane Click the bottom edge in the Preview pane Click the OK button to add a solid cyan line to the bottom edge of the text boxes.
9. 10.
Increase the group footer section's height so that you have room to work. Make the following changes to the group footer:
11.
Add the following controls to the GroupFooter section, setting the properties as indicated. Group footer controls Control DataField Size TextBox TotalLabel 3, 0.198 in Miscellaneous Location Font Style = Bold 2.5, 0 SummaryType = Subtotal SummaryFunc = Count TextBox ProductName txtTotalItems SummaryRunning = Group 5.5, 0 SummaryGroup = GroupHeader1 Alignment = Right BackColor = White (creates white space after the subtotal) Label 6.5, 0.198 in 0, 0.25 Delete default text from Text property
2.
3.
The following example shows what the scripting code looks like. Warning: Do not access the Fields collection outside the DataInitialize and FetchData events. Accessing the Fields collection outside of these events is not supported, and has unpredictable results. To write the script in Visual Basic.NET. Visual Basic.NET script. Paste in the script editor window. Private Shared m_reader As System.Data.OleDb.OleDbDataReader Private Shared m_cnn As System.Data.OleDb.OleDbConnection
Public Sub ActiveReport_ReportStart() 'Set up a data connection for the report Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GrapeCity\Ac Dim sqlString As String = "SELECT * FROM categories INNER JOIN products ON categories.categoryid = pro m_cnn = new System.Data.OleDb.OleDbConnection(connString) Dim m_Cmd As System.Data.OleDb.OleDbCommand = new System.Data.OleDb.OleDbCommand(sqlString, m_cnn) If m_cnn.State = System.Data.ConnectionState.Closed Then m_cnn.Open End If m_reader = m_Cmd.ExecuteReader End Sub Public Sub ActiveReport_DataInitialize() 'Add data fields to the report rpt.Fields.Add("CategoryID") rpt.Fields.Add("CategoryName") rpt.Fields.Add("ProductName") rpt.Fields.Add("UnitsInStock") rpt.Fields.Add("Description") rpt.Fields.Add("TotalLabel") End Sub Public Function ActiveReport_FetchData(ByVal eof As Boolean) As Boolean Try m_reader.Read 'Populated the fields with data from the data reader rpt.Fields("CategoryID").Value = m_reader("categories.CategoryID") rpt.Fields("CategoryName").Value = m_reader("CategoryName") rpt.Fields("ProductName").Value = m_reader("ProductName") rpt.Fields("UnitsInStock").Value = m_reader("UnitsInStock") rpt.Fields("Description").Value = m_reader("Description") 'Concatenate static text with data rpt.Fields("TotalLabel").Value = "Total Number of " + m_reader("CategoryName")+ " Products:" eof = False Catch 'If the end of the data file has been reached, tell the FetchData function eof = True End Try Return eof End Function Public Sub ActiveReport_ReportEnd() 'Close the data reader and connection m_reader.Close m_cnn.Close End Sub To write the script in C#. C# script. Paste in the script editor window.
public void ActiveReport_ReportStart() { //Set up a data connection for the report string m_cnnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GrapeCity\Active string sqlString = "SELECT * FROM categories INNER JOIN products ON categories.categoryid = products. 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(); } public void ActiveReport_DataInitialize() { //Add data fields to the report rpt.Fields.Add("CategoryID"); rpt.Fields.Add("CategoryName"); rpt.Fields.Add("ProductName"); rpt.Fields.Add("UnitsInStock"); rpt.Fields.Add("Description"); rpt.Fields.Add("TotalLabel"); }
public bool ActiveReport_FetchData(bool eof) { try { m_reader.Read(); //Populated the fields with data from the data reader rpt.Fields["CategoryID"].Value = m_reader["categories.CategoryID"].ToString(); rpt.Fields["CategoryName"].Value = m_reader["CategoryName"].ToString(); rpt.Fields["ProductName"].Value = m_reader["ProductName"].ToString(); rpt.Fields["UnitsInStock"].Value = m_reader["UnitsInStock"].ToString(); rpt.Fields["Description"].Value = m_reader["Description"].ToString(); //Concatenate static text with data rpt.Fields["TotalLabel"].Value = "Total Number of " + m_reader["CategoryName"].ToString() + " Produ eof = false; } catch { //If the end of the data file has been reached, tell the FetchData function eof = true; } return eof; } public void ActiveReport_ReportEnd() { //Close the data reader and connection m_reader.Close(); m_cnn.Close(); }
Temporarily connecting the main report to a data source Connecting the subreport to a data source Adding controls to each report to display data Saving the rptSub layout to RPX format Adding the scripting code for rptMain Saving the rptMain layout to RPX format Loading a saved RPX into the viewer Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. When you have finished this walkthrough, you will have a report that looks similar to the following.
2.
3. 4. 5. 6. 7.
On the OLE DB tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query. SQL Query SELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID ORDER BY CompanyName, OrderDate
8.
Click OK to save the data source and return to the report design surface.
2. 3.
4. 5. 6. 7. 8. 9.
Name: ghCompanies BackColor: LemonChiffon CanShrink: True DataField: CompanyName GroupKeepTogether: All KeepTogether: True
3.
In the Report Explorer, expand the Fields node, then the Bound node. Drag the following field onto
Field
Name: ghOrders BackColor: LightYellow CanShrink: True DataField: OrderDate GroupKeepTogether: All KeepTogether: True
6.
Drag the following fields and controls onto ghOrders and set the properties as indicated. ghOrders controls Control DataField Size TextBox OrderDate 1, 0.198 in TextBox RequiredDate 1, 0.198 in TextBox ShippedDate 1, 0.198 in Label Label Label 1, 0.198 in 1, 0.198 in 0.65, 0.198 Miscellaneous Location OutputFormat = MM/dd/yy 1.13, 0 in OutputFormat = MM/dd/yy 3.5, 0 in OutputFormat = MM/dd/yy 5.5, 0 in Alignment = Right Ordered: Font Style = Bold 0, 0 in Required: Font Style = Bold 2.5, 0 in in Shipped: Font Style = Bold 4.8, 0 in Text
7. 8.
Change the CanShrink property of the detail section to True. Drag the following control onto the detail section and set the properties as indicated. Detail section control Control ReportName Name Size Location Subreport C:\full project path\rptSub.rpx SubReport1 6.5, 1 in 0, 0 in Note: The RPX will be saved to this path later.
3.
Add four label controls to ghOrderDetails and set the properties as indicated. ghOrderDetails labels Font Style Text Alignment Location Bold Product Name 0, 0 Bold Quantity Right 3.25, 0 Bold Unit Price Right 4.4, 0 Bold Discount Right 5.5, 0
4.
Add four line controls to ghOrderDetails and set the properties as indicated. ghOrderDetails line controls Name X1 X2 Y1 Y2
6.
In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the properties as indicated. Detail section fields Field Size Alignment OutputFormat Location ProductName 3.15, 0.198 in Left 0, 0 in Quantity 1, 0.198 in Right 3.25, 0 in Products.UnitPrice 1, 0.198 in Right Currency 4.4, 0 in Discount 1, 0.198 in Right Percentage 5.5, 0 in
7.
Add four line controls to the detail section and set the properties as follows (or copy and paste them from ghOrderDetails): Detail section lines Name X1 X2 Y1 Y2 Line5 3.2 3.2 0 0.2 Line6 4.3 4.3 0 0.2 Line7 5.45 5.45 0 0.2 Line8 0 6.5 0.2 0.2
3.
Embed script to set the data source for the main report and pass data into the subreport.
The following example shows what the script looks like. To write the script in Visual Basic.NET Visual Basic.NET script. Paste in the script editor window. 'Retrieve the database path from the ActiveReports installation Private Function getDatabasePath() As String Dim regKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine regKey = regKey.CreateSubKey("SOFTWARE\\GrapeCity\\ActiveReports 6\\SampleDB") getDatabasePath = CType(regKey.GetValue(""), String) End Function 'Create a generic report Dim rptSub As DataDynamics.ActiveReports.ActiveReport Public Sub ActiveReport_ReportStart() 'Create a new instance of the generic report
rptSub = new DataDynamics.ActiveReports.ActiveReport() 'Load the rpx file into the generic report rptSub.LoadLayout(CType(rpt.Sections("Detail1").Controls("SubReport1"), DataDynamics.ActiveReports.Sub 'Connect data to the main report Dim dbPath As String = getDatabasePath() Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + dbPath + "\\NWIND.mdb" Dim sqlString As String = "Select * from orders inner join customers on orders.customerid = customers. Dim ds As new DataDynamics.ActiveReports.DataSources.OleDBDataSource() ds.ConnectionString = connString ds.SQL = sqlString rpt.DataSource = ds End Sub
Public Sub Detail1_Format() Dim rptSubCtl As DataDynamics.ActiveReports.SubReport = CType(rpt.Sections("Detail1").Controls("SubRep Dim childDataSource As New DataDynamics.ActiveReports.DataSources.OleDBDataSource() childDataSource.ConnectionString = CType(rpt.DataSource, DataDynamics.ActiveReports.DataSources.OleDBD 'Set a parameter in the SQL query childDataSource.SQL = "Select * from [order details] inner join products on [order details].productid 'Pass the data to the subreport rptSub.DataSource = childDataSource 'Display rptSub in the subreport control rptSubCtl.Report = rptSub End Sub To write the script in C# C# code. Paste in the script editor window. //Retrieve the database path from the ActiveReports installation private string getDatabasePath() { Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine; regKey = regKey.CreateSubKey("SOFTWARE\\GrapeCity\\ActiveReports 6\\SampleDB"); return ((string)(regKey.GetValue(""))); }
//'Create a generic report DataDynamics.ActiveReports.ActiveReport rptSub = DataDynamics.ActiveReports.ActiveReport(); public void ActiveReport_ReportStart() { //Create a new instance of the generic report rpt = new DataDynamics.ActiveReports.ActiveReport(); //Load the rpx file into the generic report rptSub.LoadLayout(((DataDynamics.ActiveReports.SubReport)rpt.Sections["detail"].Controls["subReport1"] //Connect data to the main report string dbPath = getDatabasePath(); string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + dbPath + "\\NWIND.mdb"; string sqlString = "Select * from orders inner join customers on orders.customerid = customers.custome DataDynamics.ActiveReports.DataSources.OleDBDataSource ds = new DataDynamics.ActiveReports.DataSources ds.ConnectionString = connString; ds.SQL = sqlString; rpt.DataSource = ds; }
public void detail_Format() { DataDynamics.ActiveReports.SubReport rptSubCtl = ((DataDynamics.ActiveReports.SubReport) rpt.Sections[ DataDynamics.ActiveReports.DataSources.OleDBDataSource childDataSource = new DataDynamics.ActiveReport childDataSource.ConnectionString = ((DataDynamics.ActiveReports.DataSources.OleDBDataSource)rpt.DataSo //Set a parameter in the SQL query childDataSource.SQL = "Select * from [order details] inner join products on [order details].productid //Pass the data to the subreport rptSub.DataSource = childDataSource; //Display rptSub in the subreport control rptSubCtl.Report = rptSub; }
To write the code to load the saved RPX into the ActiveReports viewer
1. 2. Double-click the title bar of the Windows Form containing the viewer to create a Form_Load event. Add code to load the RPX into a generic ActiveReport and display it in the viewer.
The following example shows what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the form load event. Dim rpt As New DataDynamics.ActiveReports.ActiveReport() rpt.LoadLayout("C:\MyProjectPath\rptMain.rpx") rpt.Run() Me.Viewer1.Document = rpt.Document To write the code in C# C# code. Paste INSIDE the form load event. DataDynamics.ActiveReports.ActiveReport rpt = new DataDynamics.ActiveReports.ActiveReport(); rpt.LoadLayout(@"C:\MyProjectPath\rptMain.rpx"); rpt.Run(); viewer1.Document = rpt.Document;
Adding controls to the form Adding code to import the toolbox library Adding an OnExit method Adding code to create a data toolbox group Adding code to set up the toolbox, menus, tool strips and status bar Adding code to display the selected object in the status bar
When you have finished this walkthrough, you will have a working end-user report designer that looks like the following.
Designer
arDesigner
ReportExplorer
SplitContainer1 Panel2
arReportExplorer
Anchor = Top, Bottom, Left, Right; None Resize and move as necessary. ReportDesigner = arDesigner; None Anchor = Top, Right; Resize and move as necessary.
4. 5.
Select arDesigner and in the Properties window, drop down the PropertyGrid property and select arPropertyGrid. With the controls added in the correct order and all of the above properties set, the form looks similar to the following:
The following examples show what the code looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste ABOVE the formDesigner class. 'Visual Basic 'Add the following Imports statements Imports DataDynamics.ActiveReports Imports DataDynamics.ActiveReports.Design Imports DataDynamics.ActiveReports.Design.Toolbox To write the code in C# C# code. Paste ABOVE the formDesigner class. //C# //Add using using using the following using statements DataDynamics.ActiveReports; DataDynamics.ActiveReports.Design; DataDynamics.ActiveReports.Design.Toolbox;
The following examples show what the code looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the formDesigner class. 'Visual Basic Private Sub OnExit(ByVal sender As Object, ByVal e As EventArgs) Close() End Sub To write the code in C# C# code. Paste INSIDE the formDesigner class.
The following examples show what the code looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the formDesigner class.
Private Sub LoadTools(ByVal arToolbox As DataDynamics.ActiveReports.Design.Toolbox.Toolbox) 'Add Data Providers Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.DataSet)), "Dat Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.DataView)), "Da Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.OleDb.OleDbConn Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.OleDb.OleDbData Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.Odbc.OdbcConnec Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.Odbc.OdbcDataAd Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.SqlClient.SqlCo Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.SqlClient.SqlDa End Sub To write the code in C# C# code. Paste INSIDE the formDesigner class.
private void LoadTools(DataDynamics.ActiveReports.Design.Toolbox.Toolbox arToolbox) { //Add Data Providers this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.DataSet)), "Da this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.DataView)), "D this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.OleDb.OleDbCon this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.OleDb.OleDbDat this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.Odbc.OdbcConne this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.Odbc.OdbcDataA this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.SqlClient.SqlC this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.SqlClient.SqlD }
Set up the toolbox Set up the menu and tool strips Add an Exit command to the menu Set up the status bar
The following examples show what the code for the method looks like. To write the code in Visual Basic.NET Visual Basic.NET code. Paste INSIDE the formDesigner Load event. 'Note: Assigning the ToolBox to the designer before calling NewReport ' automatically adds the default controls to the toolbox in a group called ' "ActiveReports 6" LoadTools(arToolbox) arDesigner.Toolbox = arToolbox
' Add an Exit command to the File menu fileMenu.DropDownItems.Add(New ToolStripMenuItem("Exit", DataDynamics.ActiveReports.Design.Images.Delete Dim panel As ToolStripPanel = toolStripContainer1.TopToolStripPanel panel.Join(menuStrip, 0) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Zoom)(0), 1) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Undo)(0), 1) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Edit)(0), 1) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Report)(0), 1) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Layout)(0), 2) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Format)(0), 2) 'Set up the Status Bar Dim tsLabel1 As ToolStripStatusLabel = New ToolStripStatusLabel() tsLabel1.Spring = True tsLabel1.BorderStyle = Border3DStyle.Sunken arStatus.Items.Add(tsLabel1) To write the code in C# C# code. Paste INSIDE the formDesigner Load event. //C# //Note: Assigning the ToolBox to the designer before calling NewReport // automatically adds the default controls to the toolbox in a group called // "ActiveReports 6" LoadTools(arToolbox); arDesigner.Toolbox = arToolbox; // Add Menu and CommandBar to Form ToolStrip menuStrip = arDesigner.CreateToolStrips(DesignerToolStrips.Menu)[0]; ToolStripDropDownItem fileMenu = (ToolStripDropDownItem)menuStrip.Items[0];
// Add an Exit command to the File menu fileMenu.DropDownItems.Add(new ToolStripMenuItem("Exit", DataDynamics.ActiveReports.Design.Images.Delete ToolStripPanel panel = toolStripContainer1.TopToolStripPanel; panel.Join(menuStrip, 0); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Zoom)[0], 1); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Undo)[0], 1); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Edit)[0], 1); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Report)[0], 1); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Layout)[0], 2); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Format)[0], 2); //Set up the Status Bar ToolStripStatusLabel tsLabel1 = new ToolStripStatusLabel(); tsLabel1.Spring = true; tsLabel1.BorderStyle = Border3DStyle.Sunken; arStatus.Items.Add(tsLabel1);
'Display the current selection in the designer's status bar Dim curSelection As String = "" Dim selectionEnum As IEnumerator = Nothing If Not (arDesigner.Selection Is Nothing) Then selectionEnum = arDesigner.Selection.GetEnumerator() End If While Not (selectionEnum Is Nothing) AndAlso selectionEnum.MoveNext() If TypeOf selectionEnum.Current Is Section Then curSelection = curSelection + (CType(selectionEnum.Current, Section)).Name + ", " End If If TypeOf selectionEnum.Current Is ARControl Then curSelection = curSelection + (CType(selectionEnum.Current, ARControl)).Name + ", " End If If TypeOf selectionEnum.Current Is Field Then curSelection = curSelection + (CType(selectionEnum.Current, Field)).Name + ", " End If If TypeOf selectionEnum.Current Is Parameter Then curSelection = curSelection + (CType(selectionEnum.Current, Parameter)).Key + ", " End If If TypeOf selectionEnum.Current Is ActiveReport Then curSelection = curSelection + (CType(selectionEnum.Current, ActiveReport)).Document.Name + ", " End If End While If Me.arStatus.Created AndAlso Not (Me.arStatus.Items(0) Is Nothing) Then If Not (curSelection = "") Then Me.arStatus.Items(0).Text = "Current Selection: " + curSelection.Substring(0, curSelection.Lengt Else Me.arStatus.Items(0).Text = "No Selection" End If End If To write the code in C# 1. 2. 3. Click in the designer control on formDesigner to select arDesigner. Click on the events icon in the Properties window to display available events for the control. Double-click SelectionChanged. This creates an event-handling method for the arDesigner_SelectionChanged event.
//C# //This will display the current selection in the designer's status bar string curSelection = ""; System.Collections.IEnumerator selectionEnum = null; if(arDesigner.Selection != null) selectionEnum = arDesigner.Selection.GetEnumerator(); while(selectionEnum != null && selectionEnum.MoveNext()) { if(selectionEnum.Current is Section) curSelection = curSelection + (selectionEnum.Current as Section).Name + ", "; if(selectionEnum.Current is ARControl) curSelection = curSelection + (selectionEnum.Current as ARControl).Name + ", "; if(selectionEnum.Current is Field) curSelection = curSelection + (selectionEnum.Current as Field).Name + ", "; if(selectionEnum.Current is Parameter) curSelection = curSelection + (selectionEnum.Current as Parameter).Key + ", "; if(selectionEnum.Current is ActiveReport) curSelection = curSelection + (selectionEnum.Current as ActiveReport).Document.Name + ", "; } if(this.arStatus.Created && this.arStatus.Items[0] != null) { if(curSelection != "") this.arStatus.Items[0].Text = "Current Selection: " + curSelection.Substring(0, curSelection.Leng else this.arStatus.Items[0].Text = "No Selection";
Creating an ASP.NET Web application using ActiveReports Connecting the report to a data source Setting up a report Adding the ActiveReports WebViewer control to the Web Form Caution: The WebViewer does not support the use of Ole Objects.
To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB. You must also have access to Internet Information Services either from your computer or from the server to Configure the HTTPHandlers. When you have completed this walkthrough, you will have a report that looks similar to the following.
2. 3. 4. 5. 6.
On the "OLE DB" tab, next to Connection String, click the Build button. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path. Click OK to close the window and fill in the Connection String field. In the Query field, enter the following SQL query SQL Query SELECT * FROM Products ORDER BY CategoryID, ProductName
7.
Click OK to save the data source and return to the report design surface.
Change the BackColor property to PaleVioletRed. Change the DataField property to CategoryID. Change the GroupKeepTogether property to FirstDetail. Change the KeepTogether property to True.
3.
Add the following controls to the GroupHeader section: Group header controls Control Size Label 1, 0.198 in Label 1.1, 0.198 in Label 1, 0.198 in Label 1, 0.198 in Text Location Product Name 0, 0 Quantity Per Unit 2.5, 0 In Stock 4.4, 0 Unit Price 5.5, 0
4. 5.
In the Report Explorer, expand the Fields node, then the Bound node. Select the detail section, and in the Properties window, make the following changes:
Change the CanShrink property to True. Change the BackColor property to LightGray.
6.
Drag the following fields onto the detail section and set the properties of each textbox as indicated. Detail section fields
3. 4. 5.
HtmlViewer (default) displays the report in an HTML version of the report viewer, with page navigation and a Find function. RawHtml displays the report as one long HTML page with no viewer interface. AcrobatReader displays the report in the Adobe Reader. (The user must have the Adobe Reader installed.) FlashViewer displays the report in a Flash version of the report viewer. Important: To use the Flash Viewer, copy the ActiveRepors.FlashViewer.swf file into your project folder. This file is located in: C:\Program Files\GrapeCity\ActiveReports 6\Deployment
6.
Flash Viewer
The new FlashViewer is interactive and customizable. This walkthrough is split up into the following activities:
Creating an ASP.NET Web site using ActiveReports Adding the ActiveReports WebViewer control to the aspx page Setting up the FlashViewer Caution: The WebViewer does not support the use of Ole Objects.
To complete the walkthrough, you must have access to Internet Information Services either from your computer or from the server to Configure the HTTPHandlers. When you have completed this walkthrough, you will have a Web site that looks similar to the following.
Click the WebViewer so that it is selected in the Properties window. Expand the FlashViewerOptions property node, and click the ThemeUrl property to show the ellipsis button.
7.
Click the ellipsis button to open the Select theme file dialog.
8. 9. 10.
In the Project folders pane to the left, select the Themes folder. The included themes display in the Contents of folder pane to the right. Select a theme and click OK . Run the project to view the results.
Troubleshooting
If you run into an issue while using ActiveReports, you will probably find the solution within this section. Click any short description below to drop down the symptoms, cause, and solution. Or click a link to another section of the troubleshooting guide.
General Troubleshooting
Copy icon missing from the viewer Symptoms: The copy icon is not showing in the viewer. Cause: The ActiveReports RTF and Text export filters are not referenced in the project. The viewer has intentionally been designed not to require the export filters so no extra files are required in distribution. Solution: 1. 2. In the Solution Explorer, right click References and choose Add Reference. Select GrapeCity ActiveReports Rich Text Format (RTF) Export Component and GrapeCity ActiveReports Text Export Component and click OK. Errors after installing a new build Symptoms: When you open a project created with a previous build of ActiveReports after installing a new build, there are errors related to being unable to find the previous build. Cause: Visual Studio has a property on references called Specific Version. If this property is set to True, the project looks for the specific version that you had installed when you created the report, and throws errors when it cannot find it. Solution: For each of the ActiveReports references in the Solution Explorer, select the reference and change the Specific Version property to False in the Properties Window. Blank pages printed between pages or red line in the viewer Symptoms: Blank pages are printed between pages of the report. Cause: This problem occurs when the PrintWidth plus the left and right margins exceeds the paper width. For example, if the paper size were set to A4, the PrintWidth plus the left and right margins should not exceed 8.27"; otherwise blank pages will be printed. At run time, ActiveReports marks a page overflow by displaying a red line in the viewer at the position in which the breach has occurred. Solution: The PrintWidth can be adjusted in the report designer using either the property grid or by dragging the right edge of the report. Page margins, height, and width can be adjusted either through the print properties dialog box in the Report menu under Settings. or programmatically in the Report_Start event. Copying reports results in stacked controls Symptoms: A report file copied into a new project has all of its controls piled up at location 0, 0. Cause: The report has become disconnected from its resource file. When you set a report"s Localizable property to True, the Size and Location properties of the report"s controls are moved to the associated *.resx file, so if you copy or move the report, you must move the *.resx file along with it. Solution: When you copy a report"s *.vb or *.cs file from one project"s App_Code folder into the App_Code folder of a new project, you need to also copy its *.resx file from the original project"s App_GlobalResources folder into the new project"s App_GlobalResources folder.
Print Troubleshooting
The printing thread dies before the report finishes printing Symptoms: The printing thread dies before the report is printed. Cause: If printing is done in a separate thread and the application is shut down right after the print call, the separate thread dies before the report is printed. Solution: Set the usePrintingThread parameter of the Print() method to False to keep the printing on the same thread. //C# private void rptPrint_ReportEnd(object sender, System.EventArgs eArgs) { this.Document.Print(false, false, false); }
"Visual Basic Private Sub rptPrint_ReportEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Repor Me.Document.Print(False, False, False) End Sub The viewer shows the report on the wrong paper size Symptoms: In the viewer, the report renders to a different paper size than the one specified. Cause: ActiveReports polls the printer driver assigned to the report to check for clipping, margins, and paper sizes supported by the printer. If the paper size specified for the report is not supported by the printer, ActiveReports uses the printer's default paper size to render the report. Solution: If the report is to be printed, the printer assigned to the report must support the paper size and
Memory Troubleshooting
Symptoms: ActiveReports is consuming too much memory and the CPU usage is at 100%. The CPU usage always goes to 100% when using ActiveReports. Cause: There are several reasons why too much memory may be consumed: The report is not being disposed of properly Cause: The report is not being disposed of properly. The incorrect syntax is as follows. //C# rpt.Dispose(); rpt=null; 'Visual Basic.NET
Solution: In cases where the report is too large to run any other way, the CacheToDisk property may be set to True. This property should only be used when there is no other way to run the report to completion. Before resorting to this method, please see the Optimizing ActiveReports topic. Task manager indicates the current "working set" of the process Cause: If inflated memory usage is seen in the Task Manager it is not necessarily in use by the code. Task manager indicates the current "working set" of the process and, upon request, other processes can gain access to that memory. It is managed by the Operating System. Solution: For an example of some working set behavior anomalies (which are considered normal), create a WinForms application and run it. Look in Task Manager at the working set for that process (it should be several megabytes), then minimize and maximize the form and notice that the working set reclaims to <1MB. Obviously, the code was not using all that memory even though Task Manager showed that it was allocated to that process. Similarly, you'll see ASP.NET and other managed service processes continue to gradually grow their working set even though the managed code in that process is not using all of it. To see whether this is the case, try using the two lines of code below in a button Click event after running the project. System.Diagnostics.Process pc = System.Diagnostics.Process.GetCurrentProcess(); pc.MaxWorkingSet = pc.MinWorkingSet; If that reclaims the memory then the Operating System trimmed the working set down to the minimum amount necessary and this indicates that the extra memory was not actually in use. Note: According to Microsoft it is not necessary to call GC.Collect and it should be avoided. However, if calling GC.Collect reduces the memory leak, then this indicates that it is not a leak after all. A leak in
WebViewer Troubleshooting
The WebViewer will not print without displaying the report Symptoms: The WebViewer will not automatically print a report without displaying it. Cause: Only the new FlashViewer ViewerType of the WebViewer offers this functionality. Solution: 1. 2. 3. Set the ViewerType property to FlashViewer. Expand the FlashViewerOptions property, and expand the PrintOptions subproperty. Under the PrintOptions subproperty, set the StartPrint property to True. The report is not getting updated with new data, or the page number stays the same Symptoms: The WebViewer stays on the page number last viewed in the previous report when a user selects a new report or refreshes the current report, or new data does not display on refresh. Cause: If the control is loaded in response to a client postback, the Report property does not run the specified report. Instead it uses a previously cached copy of the report's Document in the WebCache service to supply speedy responses to clients. Solution: To force the client to use a new instance, call the ClearCachedReport method before setting the Report property. The report in the HTML viewer type does not look exactly like the other viewer types Symptoms: The report in the HTML viewer type does not look exactly like the other viewer types. Cause: The HTML format is not WYSIWYG. It does not support the following items:
Line control Control borders Shapes (other than filled rects) CrossSectionBox and CrossSectionLine controls Overlapping controls
Solution: Try to avoid using the above items in reports which are shown in HTML format. The icons are missing on my WebViewer control Symptoms: The icons are missing on my WebViewer control. Cause: The httpHandlers in the Web.config file are missing or referencing the wrong version. Solution: Ensure that the following HTTP Handler code is in the Web.config file and that the version is current.
********** ActiveReports HttpHandler Configuration ********** --> <add verb="*" path="*.rpx" type="DataDynamics.ActiveReports.Web.Handlers.RpxHand <add verb="*" path="*.ActiveReport" type="DataDynamics.ActiveReports.Web.Handler <add verb="*" path="*.ArCacheItem" type="DataDynamics.ActiveReports.Web.Handlers </httpHandlers> "Error Creating Control - Webviewer" Symptoms: "Error Creating Control - Webviewer" appears on the WebForm in place of the WebViewer control. Cause: There is a version conflict within the project. Solution: 1. Open the ASPX page and look in the Source view for a line that looks similar to the following and remove it:
Export Troubleshooting
If you run into an issue while using ActiveReports exports, you will probably find the solution within this section. Click any short description below to drop down the symptoms, cause, and solution.
Maximum worksheet size: 65,536 rows by 256 columns Maximum column width: 255 characters Maximum row height: 409 points Maximum length of cell contents (text): 32,767 characters. Only 1,024 display in a cell; all 32,767 display in the formula bar.
Solution: Use the Export(document,filePath,pageRange) or Export (document,outputStream,pageRange) method to export ranges of pages into separate Excel documents. Export fails sporadically in memory stream Symptoms: When using a memory stream, the Excel export sporadically fails. Cause: Internet Explorer requires a "content-disposition" header in the response. Solution: Use code like the following before creating the export. Paste this code Response.ContentType = "application/x-msexcel"; Response.AddHeader("content-disposition","attachment; filename=MyXLS.XLS"); Response.AddHeader("content-disposition","inline;filename=MyXLS.xls"); The export does not look like the original Symptoms: The exported Excel file does not look exactly like the original report. Cause: The Excel export is not WYSIWYG. It does not support the following items:
Line control
Borders on controls with angled text Shapes (other than filled rects) Overlapping controls
Solution: Try to avoid using the above items in reports which will be exported to Excel.
Line control Control borders Shapes (other than filled rects) Overlapping controls
Solution: Try to avoid using the above items in reports which will be exported to HTML.
For Acrobat 5, clear the following options in the Print dialog: 1. 2. 3. Shrink oversized pages to paper size Expand small pages to paper size Auto-rotate and center pages The WebViewer shows blank PDF reports Symptoms: In the WebViewer, reports render correctly with the HTML viewer type but they show up blank with the AcrobatReader viewer type on the production Web server.
Line controls Backcolor Shape controls Overlapping controls Control borders (except for borders on the RichTextBox control, which are supported) Angled text
Solution: Try to avoid using the above items in reports which will be exported to RTF.
Index
3D Charts, 102-110 3D Pie Chart, 321-323 Access the Chart Wizard and Data Source, 219 -220 Accessibility, 158-161 ActiveReports and the Web, 52 ActiveReports Designer, 35 ActiveReports Editions, 9-10 ActiveReports for .NET 2.0 Side-by-Side Installation, 20 ActiveReports License Agreement, 12-13 ActiveReports Templates, 34 ActiveReports Toolbox Controls, 40-41 ActiveReports User Guide, 1 Add Annotations, 194-196 Add Bookmarks, 210-212 Add Code to Layouts Using Script, 239-243 Add Designer ToolStrips (Pro Edition), 245-246 Add Field Expressions, 175-176 Add Hyperlinks, 191-193 Add Parameters, 228 -231 Add Report Links to Web Forms (Pro Edition), 247 Adding ActiveReports Controls, 32 Adding an ActiveReport to a Project, 33 Address Labels, 308-310 Annotations, 194-196 Annual Report Sample, 285-286 Area Chart, 96-101 Bar Chart, 96-101 Barcode, 187-190 Basic Data Bound Reports, 303 -304 Basic Spreadsheet with SpreadBuilder, 332-334 Basic XML-Based Reports (RPX), 305-307 Bezier Chart, 96-101 Bind Reports to a Data Source, 167 -170 Bookmarks, 210-212 Bound Data Sample, 287-288 Bubble Chart, 111-113 CacheToDisk and Resource Storage, 157 Calculated Fields , 178 Candle Chart, 114-120 Category Selection Sample, 289-290 Change Ruler Measurements, 184 -185 Changes from Previous Versions, 25