c 1 report designer manual 2005

108
User’s Guide Designer Edition

Upload: rafael-polanco

Post on 27-Dec-2015

75 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: c 1 Report Designer Manual 2005

User’s Guide

Designer Edition

Page 2: c 1 Report Designer Manual 2005

Copyright © 1987-2005 ComponentOne LLC. All rights reserved.

Corporate Headquarters ComponentOne LLC 4516 Henry Street Suite 500 Pittsburgh, PA 15213 USA

Internet: [email protected]

Web site: http://www.componentone.com

Sales

E-mail: [email protected]

Telephone: 1.800.858.2739 or 1.412.681.4343 (Pittsburgh, PA USA Office)

Technical Support See Technical Support in this manual for information on obtaining technical support.

Trademarks ComponentOne ReportDesigner Control and the ComponentOne ReportDesigner Control logo are trademarks, and ComponentOne is a registered trademark of ComponentOne LLC. All other trademarks used herein are the properties of their respective owners.

Warranty ComponentOne warrants that the original CD (or diskettes) are free from defects in material and workmanship, assuming normal use, for a period of 90 days from the date of purchase. If a defect occurs during this time, you may return the defective CD (or disk) to ComponentOne, along with a dated proof of purchase, and ComponentOne will replace it at no charge. After 90 days, you can obtain a replacement for a defective CD (or disk) by sending it and a check for $25 (to cover postage and handling) to ComponentOne. Except for the express warranty of the original CD (or disks) set forth here, ComponentOne makes no other warranties, express or implied. Every attempt has been made to ensure that the information contained in this manual is correct as of the time it was written. We are not responsible for any errors or omissions. ComponentOne’s liability is limited to the amount you paid for the product. ComponentOne is not liable for any special, consequential, or other damages for any reason.

Copying and Distribution While you are welcome to make backup copies of the software for your own use and protection, you are not permitted to make copies for the use of anyone else. We put a lot of time and effort into creating this product, and we appreciate your support in seeing that it is used by licensed users only. Please read License Agreement and Licensing sections in this manual before copying and redistributing any ComponentOne ReportDesigner Control files.

Page 3: c 1 Report Designer Manual 2005

· iii

Table of Contents Table of Contents .......................................................................................... iii Welcome to the ComponentOne C1ReportDesigner Control .....................................1

Adding the C1ReportDesigner Component to the Toolbox............................................ 2 END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE........ 2 Licensing FAQs........................................................................................................... 8 Redistributable Files .................................................................................................. 11 Technical Support...................................................................................................... 12 Namespaces .............................................................................................................. 12

Overview..................................................................................................... 15 C1ReportDesigner Control Samples ........................................................................... 15 Using the C1ReportDesigner Control ......................................................................... 15

Object Reference ........................................................................................... 43 C1ReportDesigner Control......................................................................................... 43 ClipboardHandler Class ............................................................................................. 77 UndoStack Class........................................................................................................ 81 Grid Class ................................................................................................................. 85 Ruler Class ................................................................................................................ 88 HitTestInfo Structure ................................................................................................. 91 Enumerations ............................................................................................................ 95 Event Argument classes ............................................................................................. 98 Event Handler Delegates............................................................................................ 99

Index .........................................................................................................103

Page 4: c 1 Report Designer Manual 2005
Page 5: c 1 Report Designer Manual 2005

Welcome to the ComponentOne C1ReportDesigner Control · 1

Welcome to the ComponentOne C1ReportDesigner Control

The C1ReportDesigner is a Windows Forms control that provides the ability to design and edit report definitions that can be used with the C1Report and C1WebReport controls.

The C1ReportDesigner control displays reports in design mode, and allows users to drag, copy, and resize report fields and sections. The control also provides an unlimited undo/redo stack and a selection mechanism designed for use with the PropertyGrid control that ships with .NET.

You can use the C1ReportDesigner control to incorporate some report design features into your applications, or you can write your own full-fledged report designer application. We include full source code to the Report Designer application that ships with the C1Report component and uses the C1ReportDesigner control extensively.

Writing your own customized report designer is useful in many situations:

• You may want to integrate the designer tightly into your application, rather than running a separate application. (For example, see the report designer in Microsoft Access).

• You may want to customize the data sources available to the user, or the types of fields that can be added to the report. (For example, you may want to use custom data source objects defined by your application).

• You may want to provide a menu of stock report definitions that makes sense in the scope of your application and allows users to customize some aspects of each stock report. (For example, see the printing options in Microsoft Outlook).

• You may want to write a better, more powerful report designer application than the one you use now, that makes it easier to do things that are important to you or to your co-workers. (For example, add groups of fields to the report).

ComponentOne has a user-friendly distribution policy. We want every programmer to obtain a copy of C1ReportDesigner Control to try for as long as they wish. Those who like the product and find it useful may buy a license for a reasonable price. The only restriction is that unlicensed copies of C1ReportDesigner will display a ComponentOne banner every time they are loaded to remind developers to license the product.

We are confident that you'll like ComponentOne C1ReportDesigner. If you have any suggestions or ideas for new features that you'd like to see included in a future version, or ideas about new components, please call us or write:

Corporate Headquarters

ComponentOne LLC 4516 Henry Street Suite 500 Pittsburgh, PA 15213 USA 412.681.4343 412.681.4384 (Fax)

http://www.componentone.com

Page 6: c 1 Report Designer Manual 2005

2 · Welcome to the ComponentOne C1ReportDesigner Control

Adding the C1ReportDesigner Component to the Toolbox After installing C1ReportDesigner on your computer, you need to add the C1ReportDesigner component to the Visual Studio Toolbox:

Open the Visual Studio IDE (Microsoft Development Environment). Make sure the Toolbox is visible (select Toolbox in the View menu if necessary). Right-click the Toolbox to open the toolbox context menu.

If you want C1ReportDesigner components to appear on their own tab in the Toolbox, select Add Tab from the context menu and type in the tab name, for example, “C1ReportDesigner”. Select the tab where you want the components to appear. Right-click and select Customize Toolbox… from the context menu. The Customize Toolbox dialog box will open.

In the Customize Toolbox dialog box, go to the .NET Framework Components tab. Sort the list by Namespace (click the Namespace column header) and check the check boxes for all components belonging to namespace C1.Win.C1ReportDesigner. Note that there may be more than one component for each namespace.

END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE

IMPORTANT-READ CAREFULLY: This End User License Agreement (this "EULA") contains the terms and conditions regarding your use of the SOFTWARE (as defined below). This EULA contains material limitations to your rights in that regard. You should read this EULA carefully and treat it as valuable property.

I. THIS EULA.

1. Software Covered by this EULA. This EULA governs your use of the ComponentOne, LLC ("C1") software product(s) enclosed or otherwise accompanied herewith (individually and collectively, the "SOFTWARE"). The term "SOFTWARE" includes, to the extent provided by C1: 1) any revisions, updates and/or upgrades thereto; 2) any data, image or executable files, databases, data engines, computer software, or similar items customarily used or distributed with computer software products; 3) anything in any form whatsoever intended to be used with or in conjunction with the SOFTWARE; and 4) any associated media, documentation (including physical, electronic and on-line) and printed materials (the "Documentation").

2. This EULA is a Legally Binding Agreement Between You and C1. If you are acting as an agent of a company or another legal person, such as an officer or other employee acting for your employer, then "you" and "your" mean your principal, the entity or other legal person for whom you are acting. However, importantly, even if you are acting as an agent for another, you may still be personally liable for violation of federal and State laws, such as copyright infringement.

This EULA is a legally binding agreement between you and C1. You intend to be legally bound to this EULA to the same extent as if C1 and you physically signed this EULA. By installing, copying, or otherwise using the SOFTWARE, you agree to be bound by the terms and conditions contained in this EULA. If you do not agree to all of the terms and conditions contained in this EULA, you may not install or use the SOFTWARE. If, for whatever reason, installation has begun or has been completed, you should cancel installation or un-install the SOFTWARE, as the case may be. (You may click on the "exit" button or its equivalent to immediately abort installation.) If you do not agree to all of these terms and conditions, then you must promptly return the SOFTWARE to the place of business from which you obtained it in accordance with any return policies of such place of business. Return policies may vary between or among resellers, and you must comply with your particular reseller's return policies as agreed at the point of purchase. If the place of business from which you purchased the SOFTWARE does not honor a complete refund for a period of thirty (30) days from the date of proof of purchase, then you may return the SOFTWARE directly to C1 for a period of thirty (30) days from the date of your purchase. To return the product directly to C1, you must obtain

Page 7: c 1 Report Designer Manual 2005

END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 3

a C1 Return Authorization Number by contacting C1, and you must forward all items purchased, including the proof of purchase, directly to C1. The return must be postage-prepaid, and post-marked within thirty (30) days from the proof of purchase, time being of the essence. The return option to C1 is only available to the original purchaser of an unopened factory packaged item.

II. YOUR LICENSE TO DEVELOP AND TO DISTRIBUTE.

As provided in more detail below, this EULA grants you two licenses: 1) a license to use the SOFTWARE to develop other software products (the "Development License"); and 2) a license to use and/or distribute the Developed Software (the "Distribution License"). Both of these licenses (individually and collectively, the "Licenses") are explained and defined in more detail below.

1. Definitions. The following terms have the respective meanings as used in this EULA:

"Network Server" means a computer with one or more computer central processing units (CPU's) that operates for the purpose of serving other computers logically or physically connected to it, including, but not limited to, other computers connected to it on an internal network, intranet or the Internet. "Web Server" means a type of Network Server that serves other computers more particularly connected to it over an intranet or the Internet.

"Developed Software" means those computer software products that are developed by or through the use of the SOFTWARE. "Developed Web Server Software" means those Developed Software products that reside logically or physically on at least one Web Server and are operated (meaning the computer software instruction set is carried out) by the Web Server's central processing unit(s) (CPU). "Developed Legacy Software" means those Developed Software products that are not Developed Web Server Software, including, for example, stand-alone applications and applications accessed by a file server only. "Redistributable Files" means the SOFTWARE files or other portions of the SOFTWARE that are provided by C1 and are identified as such in the Documentation for distribution by you with the Developed Software. "Developer" means a human being or any other automated device using the SOFTWARE in accordance with the terms and conditions of this EULA.

"Developer Seat License" means that each Developer using or otherwise accessing the programmatic interface or the SOFTWARE must obtain the right to do so by purchasing a separate End User License.

“Source Code” shall mean computer software code or programs in human readable format, such as a printed listing of such a program written in a high-level computer language. The term "Source Code" includes, but is not limited to, documents and materials in support of the development effort of the SOFTWARE, such as flow charts, pseudo code and program notes.

2. Your Development License. You are hereby granted a limited, royalty-free, non-exclusive right to use the SOFTWARE to design, develop, and test Developed Software, on the express condition that, and only for so long as, you fully comply with all terms and conditions of this EULA.

The SOFTWARE is licensed to you on a Developer Seat License basis.

The Developer Seat License means that you may perform an installation of the SOFTWARE for use in designing, testing and creating Developed Software by a single Developer on one or more computers, each with a single set of input devices, so long as such computer/computers is/are used only by one single Developer at any given time and not concurrently. Conversely, you may not install or use the SOFTWARE on a computer that is a network server or a computer at which the SOFTWARE is used by more than one Developer. You may not network the SOFTWARE or any component part of it, where it is or may be used by more than one Developer unless you purchase an additional Development License for each Developer. You must purchase another separate license to the SOFTWARE in order to add additional developer seats, whether the additional developers are accessing the SOFTWARE in a stand-alone environment or on a computer network.

Page 8: c 1 Report Designer Manual 2005

4 · Welcome to the ComponentOne C1ReportDesigner Control

In all cases, you may not use C1's name, logo, or trademarks to market your Developed Software without the express written consent of C1; (b) you must include the following C1 copyright notice in your Developed Software documentation and/or in the "About Box" of your Developed Software, and wherever the copyright/rights notice is located in the Developed Software (“Portions Copyright © ComponentOne, LLC 1991-2002. All Rights Reserved.”); (c) agree to indemnify, hold harmless, and defend C1, its suppliers and resellers, from and against any claims or lawsuits, including attorney's fees that may arise from the use or distribution of your Developed Software; (d) you may use the SOFTWARE only to create Developed Software that is significantly different than the SOFTWARE.

3. Your Distribution License.

License to Distribute Developed Software. Subject to the terms and conditions in this EULA, you are granted the license to use and to distribute Developed Software on a royalty-free basis, provided that the Developed Software incorporates the SOFTWARE as an integral part of the Developed Software in machine-language compiled format (customarily an ".exe", or ".dll", etc.). You may not distribute, bundle, wrap or subclass the SOFTWARE as Developed Software which, when used in a "designtime" development environment, exposes the programmatic interface of the SOFTWARE. You may distribute, on a royalty-free basis, Redistributable Files with Developed Software only.

4. Specific Product Limitations. Notwithstanding anything in this EULA to the contrary, if the license you have purchased is for any of the following products, then the following additional limitations will apply:

a. ComponentOne Reports for .NET Designer Edition. ComponentOne Reports for .NET Designer Edition includes at least: 1) one dynamic link library (c1.win.c1reportdesigner.dll) file known as C1ReportDesigner Component, 2) one executable (ReportDesigner.exe) file known as C1ReportDesigner Application and, 3) the Source Code of the C1ReportDesigner Application. The C1ReportDesigner Component is subject to the general terms and restrictions set forth in this EULA. The C1ReportDesigner Application is an executable file used to design and prepare reports; the C1ReportDesigner Application may be distributed, free of royalties, only in conjunction with the Developed Software.

Subject to the terms and conditions in this EULA, C1 hereby grants you the right to use the C1ReportDesigner Application Source Code. You are hereby also granted the right to modify such Source Code and to create derivative works that are based on the licensed Source Code. You may distribute the derivative works that you develop, solely in object code format and exclusively in conjunction with and/or as a part of the Developed Software. You are expressly not granted the right to distribute, disclose or otherwise make available to any third party the licensed Source Code, any modified version, derivative work, or any portion thereof, in source code format.

C1 shall retain all right, title and interest in and to the licensed Source Code, and all C1 updates, modifications or enhancements thereof. Nothing herein shall be deemed to transfer any ownership or title rights in and to the licensed Source Code from C1 to you.

SOURCE CODE IS LICENSED TO YOU AS IS. C1 DOES NOT AND SHALL NOT PROVIDE YOU WITH ANY TECHNICAL SUPPORT FOR YOUR SOURCE CODE LICENSE.

b. VSView Reporting Edition. VSView Reporting Edition includes at least one executable file listed as “VSRptX.exe” (where X indicates the version number i.e.7,8, etc.), known as “Designer.” The file "VSRptX.exe”, or any upgrade or future versions of the Designer, are subject to the restrictions set forth in this EULA and may not be distributed with your Developed Software or in any other way.

c. Doc-to-Help and ComponentOne Natural Search. You may use Doc-To-Help to create online help, manuals or other documentation in electronic or printed format (the "Output Documents").

Page 9: c 1 Report Designer Manual 2005

END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 5

You may distribute and incorporate in such Output Documents those files identified in the documentation as Redistributable Files. Except for those specific Redistributable Files, you MAY NOT distribute the SOFTWARE, in any format, to others.

d. Studio Products. You may not share the component parts of the Studio Products licensed to you with other Developers, nor may you allow the use and/or installation of such components by other Developers.

e. ComponentOne Response and SOAP Channel. ComponentOne Response is intended to be installed on a Network Server. C1 grants to you the following rights to the SOFTWARE: a) Installation: You may install one copy of the SOFTWARE on a single Network Server; b) Use: When installed and initialized, the SOFTWARE creates a database file which contains the embodiment of a solution knowledge base (the database hereinafter referred to as the "Knowledge Base").

You may use the SOFTWARE to create Knowledge Bases on one Network Server only. To create or to operate Knowledge Bases in more than one Network Server, you must purchase one additional SOFTWARE license for each additional Network Server.

5. Updates/Upgrades; Studio Subscription. Subject to the terms and conditions of this EULA, the Licenses are perpetual. Updates and upgrades to the SOFTWARE may be provided by C1 from time-to-time, and, if so provided by C1, are provided upon the terms and conditions offered at that time by C1 in its sole discretion. C1 may provide updates and upgrades to the SOFTWARE for free or for any charge, at any time or never, and through its chosen manner of access and distribution, all in C1's sole and complete discretion.

C1 licenses certain of its separately-licensed products bundled together in a product suite, called the C1 "Studio" product line (the "Studio Products"). The exact separately-licensed products that are bundled into the Studio Products may change from time-to-time in C1's sole discretion. If the SOFTWARE is identified as a C1 "Studio" product, then the SOFTWARE is one of the Studio Products. The SOFTWARE and the Studio Products are revised from time-to-time (meaning, for example, revised with updates, upgrades and, in the case of Studio products, possibly changes to which specific products are included in the bundle). For you to be entitled to receive any such revisions to the SOFTWARE or the Studio Products, as the case may be, you must have a valid SOFTWARE license or a valid Studio subscription. The original purchaser of the SOFTWARE or of a Studio product receives a one-year subscription from the date of purchase of the SOFTWARE. After one year, the Studio subscription and/or the SOFTWARE license must be renewed to continue to be entitled to receive the SOFTWARE and/or the Studio Products revisions as the case may be.

6. Serial Number. Within the packaging of the SOFTWARE, a unique serial number (the "Serial Number") is included, which allows for the registration of the SOFTWARE. The Serial Number is subject to the restrictions set forth in this EULA and may not be disclosed or distributed either with your Developed Software or in any other way. The disclosure or distribution of the Serial Number shall constitute a breach of this EULA, the effect of which shall be the automatic termination and revocation of all the rights granted herein.

7. Evaluation Copy. If you are using an "evaluation copy" or similar version, specifically designated as such by C1 on its website or otherwise, then the Licenses are limited as follows: a) you are granted a license to use the SOFTWARE for a period of thirty (30) days counted from the day of installation (the "Evaluation Period"); b) upon completion of the Evaluation Period, you shall either i) delete the SOFTWARE from the computer containing the installation, or you may ii) contact C1 or one of its authorized dealers to purchase a license of the SOFTWARE, which is subject to the terms and limitations contained herein; and c) any Developed Software may not be distributed or used for any commercial purpose.

Page 10: c 1 Report Designer Manual 2005

6 · Welcome to the ComponentOne C1ReportDesigner Control

III. INTELLECTUAL PROPERTY.

1. Copyright. You agree that all right, title, and interest in and to the SOFTWARE (including, but not limited to, any images, photographs, animations, video, audio, music, text, and “applets” incorporated into the SOFTWARE), and any copies of the SOFTWARE, and any copyrights and other intellectual properties therein or related thereto are owned exclusively by C1, except to the limited extent that C1 may be the rightful license holder of certain third-party technologies incorporated into the SOFTWARE. The SOFTWARE is protected by copyright laws and international treaty provisions. The SOFTWARE is licensed to you, not sold to you. C1 reserves all rights not otherwise expressly and specifically granted to you in this EULA.

2. Backups. You may either: (a) copy the SOFTWARE solely for backup or archival purposes; or (b) install the SOFTWARE on a single computer, provided you keep the original solely for backup or archival purposes. Notwithstanding the foregoing, you may not copy the Documentation.

3. General Limitations. You may not reverse engineer, decompile, or disassemble the SOFTWARE, except and only to the extent that applicable law expressly permits such activity notwithstanding this limitation.

4. Software Transfers. You may not rent or lease the SOFTWARE. You may transfer the SOFTWARE to another computer, provided that it is completely removed from the computer from which it was transferred. You may permanently transfer all of your rights under the EULA, provided that you retain no copies, that you transfer all the SOFTWARE (including all component parts, the media and printed materials, any dates, upgrades, this EULA and, if applicable, the Certificate of Authenticity), and that the recipient agrees to the terms and conditions of this EULA as provided herein. If the SOFTWARE is an update or upgrade, any transfer must include all prior versions of the SOFTWARE.

5. Termination. Without prejudice to any other rights it may have, C1 may terminate this EULA and the Licenses if you fail to comply with the terms and conditions contained herein. In such an event, you must destroy all copies of the SOFTWARE and all of its component parts.

6. Export Restrictions. You acknowledge that the SOFTWARE is of U.S. origin. You acknowledge that the license and distribution of the SOFTWARE is subject to the export control laws and regulations of the United States of America, and any amendments thereof, which restrict exports and re-exports of software, technical data, and direct products of technical data, including services and Developed Software. You agree that you will not export or re-export the SOFTWARE or any Developed Software, or any information, documentation and/or printed materials related thereto, directly or indirectly, without first obtaining permission to do so as required from the United States of America Department of Commerce's Bureau of Export Administration ("BXA"), or other appropriate governmental agencies, to any countries, end-users, or for any end-uses that are restricted by U.S. export laws and regulations, and any amendments thereof, which include, but are not limited to, the following:

Restricted Countries: Restricted Countries currently include, but are not necessarily limited to Cuba, Iran, Iraq, Libya, Montenegro, North Korea, Serbia, Sudan, and Syria.

Restricted End-Users: Any End-User whom you know or have reason to know will use SOFTWARE or Developed Software in the design, development, or production of missiles and missile technology, nuclear weapons and weapons technology, or chemical and biological weapons. Any national of any of the Restricted Countries, wherever located, who intends to transmit or transport the SOFTWARE or Developed Software to one of the Restricted Countries.

Restricted End-Uses: Any use of SOFTWARE and Developed Software related to the design, development, or production of missiles and missile technology, nuclear weapons and weapons technology, or chemical and biological weapons.

Page 11: c 1 Report Designer Manual 2005

END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 7

These restrictions change from time to time. You represent and warrant that neither the BXA nor any other United States federal agency has suspended, revoked or denied your export privileges. C1 acknowledges that it shall use reasonable efforts to supply you with all reasonably necessary information regarding the SOFTWARE and its business to enable you to fully comply with the provisions of this Section. If you have any questions regarding your obligations under United States of America export regulations, you should contact the Bureau of Export Administration, United States Department of Commerce, Exporter Counseling Division, Washington DC. U.S.A. (202) 482-4811, http://www.bxa.doc.gov.

7. U.S. Government Restricted Rights. The SOFTWARE and documentation are provided with RESTRICTED RIGHTS. For solicitations issued before December 1, 1995, by the United States of America, its agencies and/or instrumentalities (the "Government"), other than the Department of Defense, the use, duplication or disclosure of the software and documentation provided to the Government under this EULA shall be subject to the RESTRICTED RIGHTS as set forth in subparagraphs (c)(1) and (2) of the Commercial Computer Software - Restricted Rights clause at 48 CFR ch.1 52.227-19. For solicitations issued before September 29, 1995, by the Department of Defense, the use, duplication or disclosure of the software and documentation provided under this EULA shall be subject to the RESTRICTED RIGHTS as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at 48 CFR ch.2 252.227-7013. You will comply with any requirements of the Government to obtain such RESTRICTED RIGHTS protection, including without limitation, the placement of any restrictive legends on the SOFTWARE, and any license agreement used in connection with the distribution of the SOFTWARE. Manufacturer is ComponentOne, LLC, 4516 Henry Street, Suite 501, Pittsburgh, Pennsylvania 15213 USA. For solicitations issued by the Government on or after December 1, 1995 and the Department of Defense on or after September 29, 1995, the only rights provided in the software and documentation provided herein shall be those contained in this EULA. Under no circumstances shall C1 be obligated to comply with any Governmental requirements regarding the submission of or the request for exemption from submission of cost or pricing data or cost accounting requirements. For any distribution of the SOFTWARE that would require compliance by C1 with the Government's requirements relating to cost or pricing data or cost accounting requirements, you must obtain an appropriate waiver or exemption from such requirements for the benefit of C1 from the appropriate Government authority before the distribution and/or license of the SOFTWARE to the Government.

IV. WARRANTIES AND REMEDIES.

1. Limited Warranty. C1 warrants that the original media, if any, are free from defects for ninety (90) days from the date of delivery of the SOFTWARE. EXCEPT AS OTHERWISE PROVIDED IN THE PRECEDING SENTENCE, AND TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, C1 EXPRESSLY DISCLAIMS ANY WARRANTY FOR THE SOFTWARE, DOCUMENTATION AND ANYTHING ELSE PROVIDED BY C1 HEREBY AND C1 PROVIDES THE SAME IN “AS IS” CONDITION WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE AND DOCUMENTATION REMAINS WITH YOU. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE OTHERS WHICH VARY FROM STATE TO STATE.

2. Limited Remedy. C1's entire liability and your exclusive remedy under this EULA shall be, at C1's sole option, either (a) return of the price paid for the SOFTWARE; (b) repair the SOFTWARE through updates distributed online or otherwise in C1's discretion; or (c) replace the SOFTWARE with SOFTWARE that substantially performs as described in the SOFTWARE documentation, provided that you return the SOFTWARE in the same manner as provided in Section I.2 for return of the SOFTWARE for non-acceptance of this EULA. Any media for any repaired or replacement SOFTWARE will be warranted for the remainder of the original warranty period or thirty (30) days, whichever is longer. THESE REMEDIES ARE NOT AVAILABLE OUTSIDE OF THE UNITED

Page 12: c 1 Report Designer Manual 2005

8 · Welcome to the ComponentOne C1ReportDesigner Control

STATES OF AMERICA. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL C1 BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFIT, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF C1 HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES IN CERTAIN CASES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.

V. MISCELLANEOUS.

1. This is the Entire Agreement. This EULA (including any addendum or amendment to this EULA included with the SOFTWARE) is the final, complete and exclusive statement of the entire agreement between you and C1 relating to the SOFTWARE. This EULA supersedes any prior and contemporaneous proposals, purchase orders, advertisements, and all other communications in relation to the subject matter of this EULA, whether oral or written. No terms or conditions, other than those contained in this EULA, and no other understanding or agreement which in any way modifies these terms and conditions, shall be binding upon the parties unless entered into in writing executed between the parties, or by other non-oral manner of agreement whereby the parties objectively and definitively act in a manner to be bound (such as by continuing with an installation of the SOFTWARE, "clicking-through" a questionnaire, etc.) Employees, agents and other representatives of C1 are not permitted to orally modify this EULA.

2. You Indemnify C1. . You agree to indemnify, hold harmless, and defend C1 and its suppliers and resellers from and against any and all claims or lawsuits, including attorney's fees, which arise out of or result from your breach of any of the terms and conditions of this EULA.

3. Interpretation of this EULA. If for any reason a court of competent jurisdiction finds any provision of this EULA, or any portion thereof, to be unenforceable, that provision of this EULA will be enforced to the maximum extent permissible so as to effect the intent of the parties, and the remainder of this EULA will continue in full force and effect. Formatives of defined terms shall have the same meaning of the defined term. Failure by either party to enforce any provision of this EULA will not be deemed a waiver of future enforcement of that or any other provision. Except as otherwise required or superseded by law, this EULA is governed by the laws of the Commonwealth of Pennsylvania, without regard to its conflict of laws principles. The parties consent to the personal jurisdiction and venue of the Commonwealth of Pennsylvania, in the County of Allegheny, and agree that any legal proceedings arising out of this EULA shall be conducted solely in such Commonwealth. If the SOFTWARE was acquired outside the United States, then local law may apply.

Licensing FAQs This section describes the main technical aspects of licensing. It may help the user to understand and resolve licensing problems he may experience when using ComponentOne .NET and ASP.NET products.

What is Licensing? Licensing is a mechanism used to protect intellectual property by ensuring that users are authorized to use software products.

Licensing is not only used to prevent illegal distribution of software products. Many software vendors, including ComponentOne, use licensing to allow potential users to test products before they decide to purchase them.

Without licensing, this type of distribution would not be practical for the vendor or convenient for the user. Vendors would either have to distribute evaluation software with limited functionality, or shift the burden of

Page 13: c 1 Report Designer Manual 2005

Licensing FAQs · 9

managing software licenses to customers, who could easily forget that the software being used is an evaluation version and has not been purchased.

How does Licensing Work? ComponentOne uses a licensing model based on the standard set by Microsoft, which works with all types of components.

When a user decides to purchase a product, he receives an installation program and a Serial Number. During the installation process, the user is prompted for the serial number that is saved on the system. (Users can also enter the serial number by clicking the "License" button on the About Box of any ComponentOne product.)

When a licensed component is added to a form or web page, Visual Studio asks the newly created component for licensing information. The component looks for licensing information stored in the system and generates a key, which Visual Studio saves in two files:

1. a "<projectName>.licenses" resource file which contains the actual key and

2. a "licenses.licx" file that contains references to those resources.

These files are automatically added to the project.

Note that the licenses.licx file is usually not shown in the Solution Explorer; it appears if you press the "Show All Files" button in the Solution Explorer's toolbox, or select "Project | Show All Files" from Visual Studio's main menu.

Later, when the component is created at run time, it gets passed the key that was created at design time and can decide whether to simply accept the key, to throw an exception and fail altogether, or to display some information reminding the user that the software has not been licensed.

All ComponentOne products are designed to display licensing information if the product is not licensed. None will throw licensing exceptions and prevent applications from running.

Common Scenarios

Creating components at design time This is the most common scenario and also the simplest: the user adds one or more controls to the form, the licensing information is stored in the licenses.licx file, and the component works.

Note that the mechanism is exactly the same for Windows Forms and Web Forms (ASP.NET) projects.

Creating components at run time This is also a fairly common scenario. You do not need an instance of the component on the form, but would like to create one or more instances at run time.

In this case, the project will not contain a licenses.licx file (or the file will not contain an appropriate key for the component) and therefore licensing will fail.

To fix this problem, add an instance of the component to a form in the project. This will create the licenses.licx file and things will then work as expected. (The component can be removed from the form after the licenses.licx file has been created).

Inheriting from licensed components If a component that inherits from a licensed component is created, the licensing information to be stored in the form is still needed. This can be done in two ways:

1. Add a LicenseProvider attribute to the component.

Page 14: c 1 Report Designer Manual 2005

10 · Welcome to the ComponentOne C1ReportDesigner Control

This will mark the component as licensed. When a component is added to a form, Visual Studio will create and manage the licenses.licx file, and the base class will handle the licensing process as usual. No additional work is needed. For example:

[LicenseProvider(typeof(LicenseProvider))] class MyGrid: C1.Win.C1FlexGrid.C1FlexGrid { // ... }

2. Add an instance of the base component to the form.

This will embed the licensing information into the licenses.licx file as in the previous scenario, and the base component will find it and use it. As before, the extra instance can be deleted after the licenses.licx file has been created.

Using licensed components in console applications When building console applications, there are no forms to add components to, and therefore Visual Studio won't create a licenses.licx file.

In these cases, create a temporary Windows Forms application and add all the desired licensed components to a form. Then close the Windows Forms application and copy the licenses.licx file into the console application project.

Make sure the licensex.licx file is configured as an embedded resource. To do this, right-click the licenses.licx file in the Solution Explorer window and select Properties. In the property window, set the "Build Action" property to "Embedded Resource".

Using licensed components in Visual C++ applications It seems there is a bug in VC++ 2003. The licenses.licx is ignored during the build process, therefore the licensing information is not included in VC++ applications.

To fix this problem, extra steps must be taken to compile the licensing resources and link them to the project. Note the following:

1. Build the C++ project as usual. This should create an exe file and also a licenses.licx file with licensing information in it.

2. Copy the licenses.licx file from the app directory to the target folder (Debug or Release).

3. Copy the C1Lc.exe utility and the licensed dlls to the target folder. (Don't use the standard lc.exe, it has bugs.)

4. Use C1Lc.exe to compile the licenses.licx file. The command line should look like this:

c1lc /target:MyApp.exe /complist:licenses.licx /i:C1.Win.C1FlexGrid.dll

5. Link the licenses into the project. To do this, go back to Visual Studio, right-click the project, select properties, and go to the Linker/Command Line option. Enter the following:

/ASSEMBLYRESOURCE:Debug\MyApp.exe.licenses

6. Rebuild the executable to include the licensing information in the application.

Troubleshooting We try very hard to make the licensing mechanism as unobtrusive as possible, but problems may occur for a number of reasons.

Below is a description of the most common problems and their solutions.

Page 15: c 1 Report Designer Manual 2005

Redistributable Files · 11

I have a licensed version of a ComponentOne product but I still get the splash screen when I run my project.

If this happens, there must be a problem with the licenses.licx file in the project. It either doesn't exist, contains wrong information, or is not configured correctly.

First, try a full rebuild ("Rebuild All" from the Visual Studio Build menu). This will usually rebuild the correct licensing resources.

If that fails, follow these steps:

1. Open the project and go to the Solution Explorer window.

2. Click the "Show All Files" button on the top of the window.

3. Find the licenses.licx file and delete it.

4. Close the project and reopen it.

5. Open the main form and add an instance of each licensed control.

6. Check the Solution Explorer window, there should be a licenses.licx file there.

7. Rebuild the project using the "Rebuild All" option (not just "Rebuild").

I have a licensed version of a ComponentOne product on my web server but the components still behave as unlicensed.

There is no need to install any licenses on machines used as servers and not used for development.

The components must be licensed on the development machine, therefore the licensing information will be saved into the executable (exe or dll) when the project is built. After that, the application can be deployed on any machine, including web servers.

I downloaded a new build of a component that I have purchased, and now I'm getting the splash screen when I build my projects.

Make sure that the license key is still valid. If you licensed the component over a year ago, your subscription may have expired. In this case, you have two options:

Option 1 - Renew your subscription to get a new license key.

If you choose this option, you will receive a new key that you can use to license the new components (from the installation utility or directly from the About Box).

The new subscription will entitle you to a full year of upgrades and to download the latest maintenance builds directly from http://prerelease.componentone.com/.

Option 2 – Continue to use the components you have.

Subscriptions expire, products do not. You can continue to use the components you received or downloaded while your subscription was valid.

Redistributable Files ComponentOne ReportDesigner Control is developed and published by ComponentOne LLC. You may use it to develop applications in conjunction with Microsoft Visual Studio or any other programming environment that enables the user to use and integrate the control(s). You may also distribute, free of royalties, the following Redistributable Files with any such application you develop to the extent that they are used separately on a single CPU on the client/workstation side of the network:

Page 16: c 1 Report Designer Manual 2005

12 · Welcome to the ComponentOne C1ReportDesigner Control

• C1.Win.C1ReportDesigner.dll

Site licenses are available for groups of multiple developers. Please contact [email protected] for details.

Technical Support ComponentOne C1ReportDesigner is developed and supported by ComponentOne LLC, a company formed by the merger of APEX Software Corporation and VideoSoft. You can obtain technical support using any of the following methods:

ComponentOne Web site The ComponentOne Web site at www.componentone.com provides a wealth of information and software downloads for C1ReportDesigner users, including:

• Descriptions of the various support options available through the ComponentOne Service Team.

• Answers to frequently asked questions (FAQ's) about our products, organized by functionality. Please consult the FAQ's before contacting us directly, as this can save you time and also introduce you to other useful information pertaining to our products.

• Free product updates, which provide you with bug fixes and new features.

Internet e-mail For technical support through the Internet, e-mail us at:

[email protected]

To help us provide you with the best support, please include the following information when contacting ComponentOne:

• Your ComponentOne product serial number.

• The version and name of your operating system.

• Your development environment and its version.

For more information on technical support, go to:

www.componentone.com/support

Peer-to-Peer newsgroup ComponentOne also sponsors peer-to-peer newsgroups for users. ComponentOne does not offer formal technical support in this newsgroup, but instead sponsors it as a forum for users to post and answer each other's questions regarding our products. However, ComponentOne may monitor the newsgroups to ensure accuracy of information and provide comments when necessary. You can access the newsgroup from the ComponentOne Web site at www.componentone.com/newsgroups.

Namespaces Namespaces organize the objects defined in an assembly. Assemblies can contain multiple namespaces, which can in turn contain other namespaces. Namespaces prevent ambiguity and simplify references when using large groups of objects such as class libraries.

Page 17: c 1 Report Designer Manual 2005

Namespaces · 13

The general namespace for ComponentOne Windows products is C1.Win. The namespace for the C1ReportDesigner component is C1.Win.C1ReportDesigner. The following code fragment shows how to declare a C1ReportDesigner component using the fully qualified name for this class:

• Visual Basic

Dim c1rpt As C1.Win.C1ReportDesigner.C1ReportDesigner

• C#

C1.Win.C1ReportDesigner.C1ReportDesigner c1rpt;

• Delphi

c1rpt: C1.Win.C1ReportDesigner.C1ReportDesigner;

Namespaces address a problem sometimes known as namespace pollution, in which the developer of a class library is hampered by the use of similar names in another library. These conflicts with existing components are sometimes called name collisions.

For example, if you create a new class named ClipboardHandler, you can use it inside your project without qualification. However, the C1ReportDesigner assembly also implements a class called ClipboardHandler. So, if you want to use the C1ReportDesigner class in the same project, you must use a fully qualified reference to make the reference unique. If the reference is not unique, Visual Studio .NET produces an error stating that the name is ambiguous. The following code snippet demonstrates how to declare these objects:

• Visual Basic

' Define a new ClipboardHandler object (custom ClipboardHandler class) Dim MyClipboard as ClipboardHandler ' Define a new C1ReportDesigner.ClipboardHandler object. Dim ReportDesignerClip as _ C1.Win.C1ReportDesigner.ClipboardHandler

• C#

// Define a new ClipboardHandler object (custom ClipboardHandler class) MyClipboard ClipboardHandler; // Define a new C1ReportDesigner.ClipboardHandler object. ReportDesignerClip C1.Win.C1ReportDesigner.ClipboardHandler;

• Delphi

// Define a new ClipboardHandler object (custom ClipboardHandler class) var MyClipboard: ClipboardHandler; // Define a new C1ReportDesigner.ClipboardHandler object. var ReportDesignerClip: C1.Win.C1ReportDesigner.ClipboardHandler;

Fully qualified names are object references that are prefixed with the name of the namespace where the object is defined. You can use objects defined in other projects if you create a reference to the class (by choosing Add Reference from the Project menu) and then use the fully qualified name for the object in your code.

Fully qualified names prevent naming conflicts because the compiler can always determine which object is being used. However, the names themselves can get long and cumbersome. To get around this, you can use the Imports statement (using in C#) to define an alias — an abbreviated name you can use in place of a fully qualified name. For example, the following code snippet creates aliases for two fully qualified names, and uses these aliases to define two objects:

Page 18: c 1 Report Designer Manual 2005

14 · Welcome to the ComponentOne C1ReportDesigner Control

• Visual Basic

Imports C1ClipboardHandler = C1.Win.C1ReportDesigner.ClipboardHandler Imports MyClipboard = MyProject.ClipboardHandler Dim c1 As C1ClipboardHandler Dim c2 As MyClipboard

• C#

using C1ClipboardHandler = C1.Win.C1ReportDesigner.ClipboardHandler; using MyClipboard = MyProject.ClipboardHandler; C1ClipboardHandler c1; MyClipboard c2;

• Delphi

uses C1.Win.C1ReportDesigner.ClipboardHandler, MyProject.ClipboardHandler; c2: MyClipboard; c1: C1ClipboardHandler;

If you use the Imports statement without an alias, you can use all the names in that namespace without qualification provided they are unique to the project.

Page 19: c 1 Report Designer Manual 2005

C1ReportDesigner Control Samples · 15

Overview To use the C1ReportDesigner control, simply drag it onto a form, add a C1Report component that will contain the report you want to edit, and set the Report property in the designer control.

When you run the project, you will see the report definition in design mode. The user will be able to select, move, and resize the report fields and sections. Any changes made through the designer will be reflected in the report definition stored in the C1Report component. You can save the report at any time using the C1Report Save method, or preview it using the C1Report Document property and a preview control.

To build a complete designer, you will have to add other UI elements:

• A PropertyGrid control attached to the designer selection, so the user can change field and section properties.

• A DataSource selection mechanism so the user can edit and change the report data source.

• A Group Editor dialog box if you want to allow the user to create, remove, and edit report groups.

• A Wizard to create new reports.

• The usual file and editing commands so users can load and save reports, use the clipboard, and access the undo/redo mechanism built into the C1ReportDesigner control.

Most of these elements are optional and may be omitted depending on your needs. The Report Designer application source code implements all of these, and you can use the source code as a basis for your implementation.

C1ReportDesigner Control Samples Please be advised that this ComponentOne software title is accompanied by various sample projects and/or demos, which may or not make use of other ComponentOne development tools. While the sample projects and/or demos included with the software are used to demonstrate and highlight the product’s features, and how the control may be integrated with the rest of the ComponentOne product line, some of the controls used in the demo/sample project may not be included with the purchase of certain individual products.

Visual Basic and C# Samples

ReportDesignerApp This sample uses the C1ReportDesigner and C1Report controls.

ReportDesignerDemo This sample uses the C1ReportDesigner, C1Report, and C1PrintPreview controls.

Using the C1ReportDesigner Control This section describes how to implement a simple report designer using the C1ReportDesigner control (See the ReportDesigner Demo; the project is written in C#, but implementing it in VB would be just as easy).

The purpose of the sample designer is to illustrate how the C1ReportDesigner control integrates with a designer application. It supports loading and saving files with multiple reports, editing and previewing reports, adding and removing reports from the file, and report editing with undo/redo and clipboard support.

Page 20: c 1 Report Designer Manual 2005

16 · Overview

Most designer applications based on the C1ReportDesigner control will have features similar to the ones described here. If you follow these steps, you will become familiar with all the basic features of the C1ReportDesigner control.

The sample designer does not provide some advanced capabilities such as import/export, data source selection/editing, and group editing. All these features are supported by the full version of the C1ReportDesigner application, and you can refer to the source code for details on how to implement them.

The following sections describe the step-by-step implementation of the sample designer.

Step 1: Create and populate the main form The sample designer consists of a single form with the following main components on it:

Control Name Description

_list ListBox control with a list of reports currently loaded.

_c1ppv C1PrintPreview control for previewing the reports.

_c1rd C1ReportDesigner control for designing and editing reports.

_ppg PropertyGrid control for editing properties of objects selected in the designer.

_tb ToolBox control with buttons for each command.

_c1r C1Report component used for rendering reports into the _c1ppv control.

The form contains a few other controls such as labels, panels and splitters, which are used to improve the layout. Here's what the form should look like:

Page 21: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 17

The toolbar control _tb appears along the top of the form. On the left, the report list _list appears above the property grid _ppg. On the right, the report designer control _c1rd fills the client area of the form. The preview control _c1ppv is invisible in design mode. In preview mode, it becomes visible and hides the report designer.

The toolbar contains 14 buttons. If you are creating the project from scratch, don't worry about the images at this point. Just add 14 buttons to the _tb control and set their names as each command is implemented.

Step 2: Add class variables and constants The simple designer uses the following class variables:

• Visual Basic

' fields Private Property FileName String' name of the current file End Property Private Property Dirty As Boolean' current file has changed End Property ' title to display in the form caption private const String _appName = "C1ReportDesigner Demo"

• C#

// fields private string _fileName; // name of the current file private bool _dirty; // current file has changed // title to display in the form caption private const string _appName = "C1ReportDesigner Demo";

• Delphi

// fields var _dirty: Boolean; // name of the current file _fileName: string; // current file has changed //title to display in the form caption const string _appName = 'C1ReportDesigner Demo';

Step 3: Add code to update the User Interface The simple designer has buttons that may be enabled or disabled, depending on whether the clipboard and undo buffer are empty, whether a file is loaded, etc. All this functionality is implemented in a single method, called UpdateUI.

UpdateUI is called often to make sure the UI reflects the state of the application. The first call should be made in response to the Form_Load event, to initialize to toolbar and form caption. The code follows. After pasting this into the project, remember to set the names of the buttons in the toolbar control to match the ones used in the UpdateUI routine.

• Visual Basic

' update UI on startup to show form title and disable clipboard and ' undo/redo buttons Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) UpdateUI() End Sub Private Sub UpdateUI() ' update caption Text = (_fileName <> Nothing And _fileName.Length > 0)

Page 22: c 1 Report Designer Manual 2005

18 · Overview

? String.Format("{0} - [{1}] {2}", _appName, _fileName, _dirty? "*": "") Dim _appName As : ' push/release design/preview mode buttons Dim design As Boolean = _c1rd.Visible And _c1rd.Report <> Nothing _btnDesign.Pushed = design _btnPreview.Pushed = Not design ' enable/disable buttons _btnCut.Enabled = design And _c1rd.ClipboardHandler.CanCut _btnCopy.Enabled = design And _c1rd.ClipboardHandler.CanCut _btnPaste.Enabled = design And _c1rd.ClipboardHandler.CanPaste _btnUndo.Enabled = design And _c1rd.UndoStack.CanUndo _btnRedo.Enabled = design And _c1rd.UndoStack.CanRedo Dim reportSelected As Boolean = design And _list.SelectedItem <> Nothing _btnAddReport.Enabled = _c1rd.Visible _btnDelReport.Enabled = reportSelected _btnAddField.Enabled = reportSelected _btnAddLabel.Enabled = reportSelected End Sub

• C#

// update UI on startup to show form title and disable clipboard and // undo/redo buttons private void Form1_Load(object sender, System.EventArgs e) { UpdateUI(); } private void UpdateUI() { // update caption Text = (_fileName != null && _fileName.Length > 0) ? string.Format("{0} - [{1}] {2}", _appName, _fileName, _dirty? "*": "") : _appName; // push/release design/preview mode buttons bool design = _c1rd.Visible && _c1rd.Report != null; _btnDesign.Pushed = design; _btnPreview.Pushed = !design; // enable/disable buttons _btnCut.Enabled = design && _c1rd.ClipboardHandler.CanCut; _btnCopy.Enabled = design && _c1rd.ClipboardHandler.CanCut; _btnPaste.Enabled = design && _c1rd.ClipboardHandler.CanPaste; _btnUndo.Enabled = design && _c1rd.UndoStack.CanUndo; _btnRedo.Enabled = design && _c1rd.UndoStack.CanRedo; bool reportSelected = design && _list.SelectedItem != null; _btnAddReport.Enabled = _c1rd.Visible; _btnDelReport.Enabled = reportSelected; _btnAddField.Enabled = reportSelected; _btnAddLabel.Enabled = reportSelected; }

• Delphi

// update UI on startup to show form title and disable clipboard and // undo/redo buttons procedure Form1_Load(sender: System.Object; e: System.EventArgs); begin

Page 23: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 19

UpdateUI; end; procedure UpdateUI; var design: Boolean; reportSelected: Boolean; begin // update caption if (_fileName <> nil) and (_fileNaSelf.Length > 0) then Text := System.String.Format('{0} - [{1}] {2}', _appName, _fileName, _dirty?'*':'') else Text := _appName; // push/release design/preview mode buttons design := _c1rd.Visible And (_c1rd.Report <> nil); _btnDesign.Pushed := design; _btnPreview.Pushed := Not design; // enable/disable buttons _btnCut.Enabled := design And _c1rd.ClipboardHandler.CanCut; _btnCopy.Enabled := design And _c1rd.ClipboardHandler.CanCut; _btnPaste.Enabled := design And _c1rd.ClipboardHandler.CanPaste; _btnUndo.Enabled := design And _c1rd.UndoStack.CanUndo; _btnRedo.Enabled := design And _c1rd.UndoStack.CanRedo; reportSelected := design And _list.SelectedItem <> nil; _btnAddReport.Enabled := _c1rd.Visible; _btnDelReport.Enabled := reportSelected; _btnAddField.Enabled := reportSelected; _btnAddLabel.Enabled := reportSelected; end;

Notice how UpdateUI uses the CanCut, CanPaste, CanUndo, and CanRedo properties to enable and disable toolbar buttons.

Step 4: Add code to handle the toolbar commands Here is the code that handles clicks on the toolbar buttons and dispatches them to the appropriate handlers.

• Visual Basic

' handle clicks on toolbar buttons Private Property sender,() As _tb_ButtonClick(object End Property Private Function e)() As ToolBarButtonClickEventArgs ' design/preview mode If e.Button = _btnDesign Then SetDesignMode(True) End If If e.Button = _btnPreview Then SetDesignMode(False) End If ' file commands If e.Button = _btnNew Then NewFile() End If If e.Button = _btnOpen Then OpenFile() End If If e.Button = _btnSave Then SaveFile()

Page 24: c 1 Report Designer Manual 2005

20 · Overview

End If ' allow user to undo clipboard operations If e.Button = _btnCut Or e.Button = _btnPaste Then _c1rd.UndoStack.SaveState() End If ' clipboard If e.Button = _btnCut Then _c1rd.ClipboardHandler.Cut() End If If e.Button = _btnCopy Then _c1rd.ClipboardHandler.Copy() End If If e.Button = _btnPaste Then _c1rd.ClipboardHandler.Paste() End If ' undo/redo If e.Button = _btnUndo Then _c1rd.UndoStack.Undo() End If If e.Button = _btnRedo Then _c1rd.UndoStack.Redo() End If ' add/remove reports If e.Button = _btnAddReport Then NewReport() End If If e.Button = _btnDelReport Then DeleteReport() End If ' add fields ' (just set create info and wait for CreateField event from designer) If e.Button = _btnAddField Then _c1rd.CreateFieldInfo = e.Button End If If e.Button = _btnAddLabel Then _c1rd.CreateFieldInfo = e.Button End If End Function

• C#

// handle clicks on toolbar buttons private void _tb_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { // design/preview mode if (e.Button == _btnDesign) SetDesignMode(true); if (e.Button == _btnPreview) SetDesignMode(false); // file commands if (e.Button == _btnNew) NewFile(); if (e.Button == _btnOpen) OpenFile(); if (e.Button == _btnSave) SaveFile(); // allow user to undo clipboard operations if (e.Button == _btnCut || e.Button == _btnPaste) _c1rd.UndoStack.SaveState(); // clipboard

Page 25: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 21

if (e.Button == _btnCut) _c1rd.ClipboardHandler.Cut(); if (e.Button == _btnCopy) _c1rd.ClipboardHandler.Copy(); if (e.Button == _btnPaste) _c1rd.ClipboardHandler.Paste(); // undo/redo if (e.Button == _btnUndo) _c1rd.UndoStack.Undo(); if (e.Button == _btnRedo) _c1rd.UndoStack.Redo(); // add/remove reports if (e.Button == _btnAddReport) NewReport(); if (e.Button == _btnDelReport) DeleteReport(); // add fields // (just set create info and wait for CreateField event from designer) if (e.Button == _btnAddField) _c1rd.CreateFieldInfo = e.Button; if (e.Button == _btnAddLabel) _c1rd.CreateFieldInfo = e.Button; }

• Delphi

// handle clicks on toolbar buttons procedure _tb_ButtonClick (sender: System.Object; e: ToolBarButtonClickEventArgs); begin // design/preview mode if e.Button = _btnDesign then begin SetDesignMode(True); end; if e.Button = _btnPreview then begin SetDesignMode(False); end; // file commands if e.Button = _btnNew then begin NewFile; end; if e.Button = _btnOpen then begin OpenFile; end; if e.Button = _btnSave then begin SaveFile; end; // allow user to undo clipboard operations if e.Button = _btnCut Or e.Button = _btnPaste then begin _c1rd.UndoStack.SaveState; end; // clipboard if e.Button = _btnCut then begin _c1rd.ClipboardHandler.Cut; end; if e.Button = _btnCopy then begin _c1rd.ClipboardHandler.Copy; end; if e.Button = _btnPaste then

Page 26: c 1 Report Designer Manual 2005

22 · Overview

begin _c1rd.ClipboardHandler.Paste; end; // undo/redo if e.Button = _btnUndo then begin _c1rd.UndoStack.Undo; end; if e.Button = _btnRedo then begin _c1rd.UndoStack.Redo; end; // add/remove reports if e.Button = _btnAddReport then begin NewReport; end; if e.Button = _btnDelReport then begin DeleteReport; end; // add fields // (just set create info and wait for CreateField event from designer) if e.Button = _btnAddField then begin _c1rd.CreateFieldInfo := e.Button; end; if e.Button = _btnAddLabel then begin _c1rd.CreateFieldInfo := e.Button; end; end;

This routine dispatches about half of the commands to specialized handlers. These will be described later. The other half (clipboard, undo/redo) is handled directly by the C1ReportDesigner control.

Note that before calling the Cut and Paste methods, the code calls the SaveState method to save the current state of the report. This allows the user to undo and redo clipboard operations. In general, your code should always call SaveState before making changes to the report.

Step 5: Implement the SetDesignMode method The simple designer has two modes, report design and preview. When the user selects a new report or clicks the design button on the toolbar, the application shows the designer control. When the user clicks the preview button, the application renders the current report into the preview control and shows the result.

Here is the code in the SetDesignMode method:

• Visual Basic

Private Sub SetDesignMode(ByVal design As Boolean) ' show/hide preview/design panes _c1rd.Visible = design _c1ppv.Visible = Not design ' no properties in preview mode If Not design Then _lblPropGrid.Text = "Properties" _ppg.SelectedObject = Nothing End If

Page 27: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 23

' attach copy of the report to preview control ' (so changes caused by script aren't saved) If Not design Then _c1ppv.Document = Nothing _c1r.CopyFrom(_c1rd.Report) Cursor = Cursors.WaitCursor _c1r.Render() If _c1r.PageImages.Count > 0 Then _c1ppv.Document = _c1r.Document End If Cursor = Cursors.Default End If / done, update UI UpdateUI() End Sub

• C#

private void SetDesignMode( bool design) { // show/hide preview/design panes _c1rd.Visible = design; _c1ppv.Visible = ! design; // no properties in preview mode if (! design ) { _lblPropGrid.Text = "Properties"; _ppg.SelectedObject = null; } // attach copy of the report to preview control // (so changes caused by script aren//t saved) if (! design ) { _c1ppv.Document = null; _c1r.CopyFrom(_c1rd.Report); Cursor = Cursors.WaitCursor; _c1r.Render(); if ( _c1r.PageImages.Count > 0 ) { _c1ppv.Document = _c1r.Document; } Cursor = Cursors.Default; } / done, update UI; UpdateUI(); }

• Delphi

procedure SetDesignMode(design: Boolean); begin // show/hide preview/design panes _c1rd.Visible := design; _c1ppv.Visible := not design; // no properties in preview mode if Not design then begin _lblPropGrid.Text := 'Properties'; _ppg.SelectedObject := nil; end; // attach copy of the report to preview control // (so changes caused by script aren // t saved)

Page 28: c 1 Report Designer Manual 2005

24 · Overview

if not design then begin _c1ppv.Document := nil; _c1r.CopyFrom(_c1rd.Report); Cursor := Cursors.WaitCursor; _c1r.Render; if _c1r.PageImages.Count > 0 then begin _c1ppv.Document := _c1r.Document; end; Cursor := Cursors.Default; end; // done, update UI; UpdateUI; end;

Switching to design mode is easy, all you have to do is show the designer and hide the preview control. Switching to preview mode is a little more involved because it also requires rendering the report.

Note that the report is copied to a separate C1Report control before being rendered. This is necessary because reports may contain script code that changes the report definition (field colors, visibility, etc.), and we don't want those changes applied to the report definition.

Step 6: Implement the File support methods The simple designer has three commands that support files: New, Open, and Save. Their implementation is simple.

NewFile clears the class variables, report list, preview and designer controls, and then updates the UI.

• Visual Basic

Private Sub NewFile() _fileName = "" _dirty = False _list.Items.Clear() _c1ppv.Document = Nothing _c1rd.Report = Nothing UpdateUI() End Sub

• C#

private void NewFile() { _fileName = ""; _dirty = false; _list.Items.Clear(); _c1ppv.Document = null; _c1rd.Report = null; UpdateUI(); }

• Delphi

procedure Class1.NewFile; begin _fileName := ''; _dirty := False; _list.Items.Clear; _c1ppv.Document := nil; _c1rd.Report := nil; UpdateUI; end;

Page 29: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 25

OpenFile prompts the user for a report definition file to open, then uses the C1Report component to retrieve a list of report names in the selected file. Each report is loaded into a new C1Report component, which is added to the report list (_list control).

Instead of adding the C1Report components directly to the list box, the code uses a ReportHolder wrapper class. The only function of the ReportHolder class is to override the ToString method so the list box shows the report names.

• Visual Basic

Public Sub OpenFile() ' get name of file to open Dim dlg As New OpenFileDialog dlg.FileName = "*.xml" dlg.Title = "Open Report Definition File" If dlg.ShowDialog() <> DialogResult.OK Then Return End If ' check selected file Dim reports() As String = Nothing Try reports = _c1r.GetReportInfo(dlg.FileName) End Try If reports = Nothing Or reports.Length = 0 Then MessageBox.Show("Invalid (or empty) report definition file") Return End If ' clear list NewFile() ' load new file Cursor = Cursors.WaitCursor _fileName = dlg.FileName Dim reportName As String For Each reportName In reports Dim rpt As C1Report = New C1Report() rpt.Load(_fileName, reportName) _list.Items.Add(New ReportHolder(rpt)) Next Cursor = Cursors.Default ' select first report _list.SelectedIndex = 0 } ' ReportHolder class ' Helper class used to store reports in listboxes. The main thing ' it does is override the ToString() method to render the report name. Public Class ReportHolder Public ReadOnly Report As C1Report Public Sub New(ByVal report As C1Report) Report = report End Sub Overrides Public Function ToString() As String Dim s As String = Report.ReportName Return(s <> Nothing And s.Length > 0)? s: "Unnamed Report" End Function End Class

Page 30: c 1 Report Designer Manual 2005

26 · Overview

• C#

public void OpenFile() { // get name of file to open OpenFileDialog dlg = new OpenFileDialog(); dlg.FileName = "*.xml"; dlg.Title = "Open Report Definition File"; if (dlg.ShowDialog() != DialogResult.OK) return; // check selected file string[] reports = null; try { reports = _c1r.GetReportInfo(dlg.FileName); } catch {} if (reports == null || reports.Length == 0) { MessageBox.Show("Invalid (or empty) report definition file"); return; } // clear list NewFile(); // load new file Cursor = Cursors.WaitCursor; _fileName = dlg.FileName; foreach (string reportName in reports) { C1Report rpt = new C1Report(); rpt.Load(_fileName, reportName); _list.Items.Add(new ReportHolder(rpt)); } Cursor = Cursors.Default; // select first report _list.SelectedIndex = 0; } /// ReportHolder class /// Helper class used to store reports in listboxes. The main thing /// it does is override the ToString() method to render the report name. public class ReportHolder { public readonly C1Report Report; public ReportHolder(C1Report report) { Report = report; } override public string ToString() { string s = Report.ReportName; return (s != null && s.Length > 0)? s: "Unnamed Report"; } }

• Delphi

procedure OpenFile; var dlg: OpenFileDialog; reports: array of string;

Page 31: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 27

reportName: string; rpt: C1Report; begin // get name of file to open dlg := OpenFileDialog.Create; dlg.FileName := '*.xml'; dlg.Title := 'Open Report Definition File'; if dlg.ShowDialog <> System.Windows.Forms.DialogResult.OK then exit; // check selected file reports := nil; try reports := _c1r.GetReportInfo(dlg.FileName); except end; if (reports = nil) or (Length(reports) = 0) then begin MessageBox.Show('Invalid (or empty) report definition file'); exit; end; // clear list NewFile; // load new file Cursor := Cursors.WaitCursor; _fileName := dlg.FileName; for i := 0 to High(reports) do begin reportName := reports[i]; rpt := C1Report.Create; rpt.Load(_fileName, reportName); _list.Items.Add(ReportHolder.Create(rpt)); end; Cursor := Cursors.Default; // select first report _list.SelectedIndex := 0; end; // ReportHolder class // Helper class used to store reports in listboxes. The main thing // it does is override the ToString() method to render the report name. ReportHolder = class public Report: C1Report; constructor Create(AReport: C1Report); function ToString(): string; override; end; constructor ReportHolder.Create(AReport: C1Report); begin inherited Create; Report := AReport; end; function ReportHolder.ToString(): string; begin if (Report.ReportName <> nil) and (Report.ReportName.Length > 0) then Result := Report.ReportName else Result := 'Unnamed Report'; end;

Page 32: c 1 Report Designer Manual 2005

28 · Overview

Finally, the SaveFile method prompts the user for a file name and uses an XmlWriter to save each report into the new file using C1Report's Save method.

• Visual Basic

Public Sub SaveFile() ' get name of file to save Dim dlg As New SaveFileDialog() dlg.FileName = _fileName dlg.Title = "Save Report Definition File" If dlg.ShowDialog() <> DialogResult.OK Then Return End If ' save file Dim w As New XmlTextWriter(dlg.FileName, System.Text.Encoding.Default) w.Formatting = Formatting.Indented w.Indentation = 2 w.WriteStartDocument() ' write all reports to it Cursor = Cursors.WaitCursor w.WriteStartElement("Reports") Dim rh As ReportHolder For Each rh In _list.Items rh.Report.Save(rh.Report.ReportName) Next rh w.WriteEndElement() Cursor = Cursors.Default ' close the file w.Close() ' and be done _fileName = dlg.FileName _dirty = False UpdateUI() End Sub 'SaveFile

• C#

public void SaveFile() { // get name of file to save SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = _fileName; dlg.Title = "Save Report Definition File"; if (dlg.ShowDialog() != DialogResult.OK) return; // save file XmlTextWriter w = new XmlTextWriter(dlg.FileName, System.Text.Encoding.Default); w.Formatting = Formatting.Indented; w.Indentation = 2; w.WriteStartDocument(); // write all reports to it Cursor = Cursors.WaitCursor; w.WriteStartElement("Reports"); foreach (ReportHolder rh in _list.Items) rh.Report.Save(rh.Report.ReportName); w.WriteEndElement(); Cursor = Cursors.Default;

Page 33: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 29

// close the file w.Close(); // and be done _fileName = dlg.FileName; _dirty = false; UpdateUI(); }

• Delphi

procedure SaveFile; var dlg: SaveFileDialog; w: XmlTextWriter; rh: ReportHolder; i: Integer; begin dlg := SaveFileDialog.Create(); w := XmlTextWriter.Create(dlg.FileName, System.Text.Encoding.Default); // get name of file to save dlg.FileName := _fileName; dlg.Title := 'Save Report Definition File'; if dlg.ShowDialog <> System.Windows.Forms.DialogResult.OK then exit; // save file w.Formatting := Formatting.Indented; w.Indentation := 2; w.WriteStartDocument; // write all reports to it Cursor := Cursors.WaitCursor; w.WriteStartElement('Reports'); for i := 0 to _list.Items.Count - 1 do begin rh := ReportHolder(_list.Items[i]); rh.Report.Save(rh.Report.ReportName); end; w.WriteEndElement; Cursor := Cursors.Default; // close the file w.Close; // and be done _fileName := dlg.FileName; _dirty := False; UpdateUI; end;

Step 7: Hook up the controls The next step is to add the event handlers that hook up all the controls together.

Here is the handler for the SelectedIndexChanged event of the _list control. When the user selects a new report from the list, the code displays it in design mode:

• Visual Basic

' a new report was selected: switch to design mode and show it Private Sub _list_SelectedIndexChanged(sender As Object, e As System.EventArgs) ' switch to design mode SetDesignMode(True)

Page 34: c 1 Report Designer Manual 2005

30 · Overview

' attach selected report to designer and preview controls _c1rd.Report = Nothing _c1ppv.Document = Nothing If Not (_list.SelectedItem Is Nothing) Then _c1rd.Report = CType(_list.SelectedItem, ReportHolder).Report End If End Sub '_list_SelectedIndexChanged

• C#

// a new report was selected: switch to design mode and show it private void _list_SelectedIndexChanged(object sender, System.EventArgs e) { // switch to design mode SetDesignMode(true); // attach selected report to designer and preview controls _c1rd.Report = null; _c1ppv.Document = null; if (_list.SelectedItem != null) _c1rd.Report = ((ReportHolder)_list.SelectedItem).Report; }

• Delphi

// a new report was selected: switch to design mode and show it procedure _list_SelectedIndexChanged(sender: System.Object; e: System.EventArgs); begin // switch to design mode SetDesignMode(True); // attach selected report to designer and preview controls _c1rd.Report := nil; _c1ppv.Document := nil; if _list.SelectedItem <> nil then begin _c1rd.Report := (_list.SelectedItem as ReportHolder).Report; end; end;

The designer uses a property grid control (_ppg) to expose the properties of the report elements selected in the designer. This is done by setting the SelectedObject property of the property of the property grid control in response to the control fires a SelectionChanged event.

When the user selects a report section or a field in the designer control, it fires the SelectionChanged event. The event handler inspects the new selection and assigns it to the property grid control. This is a powerful mechanism. The selection can be a single report field, a group of fields, a section, or the whole report.

• Visual Basic

' the selection changed, need to update property grid and show the ' properties of the selected object Private Sub _c1rd_SelectionChanged(sender As Object, e As System.EventArgs) Dim sel As Object() = _c1rd.SelectedFields If sel.Length > 0 Then _lblPropGrid.Text = "Field Properties" _ppg.SelectedObjects = sel Else If Not (_c1rd.SelectedSection Is Nothing) Then _lblPropGrid.Text = "Section Properties" _ppg.SelectedObject = _c1rd.SelectedSection

Page 35: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 31

Else If Not (_c1rd.Report Is Nothing) Then _lblPropGrid.Text = "Report Properties" _ppg.SelectedObject = _c1rd.Report ' nothing selected Else _lblPropGrid.Text = "Properties" _ppg.SelectedObject = Nothing End If End If End If ' done UpdateUI() End Sub '_c1rd_SelectionChanged

• C#

// the selection changed, need to update property grid and show the // properties of the selected object private void _c1rd_SelectionChanged(object sender, System.EventArgs e) { object[] sel = _c1rd.SelectedFields; if (sel.Length > 0) { _lblPropGrid.Text = "Field Properties"; _ppg.SelectedObjects = sel; } else if (_c1rd.SelectedSection != null) { _lblPropGrid.Text = "Section Properties"; _ppg.SelectedObject = _c1rd.SelectedSection; } else if (_c1rd.Report != null) { _lblPropGrid.Text = "Report Properties"; _ppg.SelectedObject = _c1rd.Report; } else // nothing selected { _lblPropGrid.Text = "Properties"; _ppg.SelectedObject = null; } // done UpdateUI(); }

• Delphi

// the selection changed, need to update property grid and show the // properties of the selected object procedure Class1._c1rd_SelectionChanged(sender: System.Object; e: System.EventArgs); var sel: array of System.Object; begin sel := _c1rd.SelectedFields; if (sel.Length > 0) then begin _lblPropGrid.Text := 'Field Properties'; _ppg.SelectedObjects := sel; end else if (_c1rd.SelectedSection <> nil) then begin

Page 36: c 1 Report Designer Manual 2005

32 · Overview

_lblPropGrid.Text := 'Section Properties'; _ppg.SelectedObject := _c1rd.SelectedSection; end else if (_c1rd.Report <> nil) then begin _lblPropGrid.Text := 'Report Properties'; _ppg.SelectedObject := _c1rd.Report; end else // nothing selected begin _lblPropGrid.Text := 'Properties'; _ppg.SelectedObject := nil; end; // done UpdateUI; end;

Here are the handlers for the PropertyValueChanged event of the _ppg control and the ValuesChanged event of the _c1rd control.

The property grid (_ppg) displays the properties of the object selected in the designer (_c1rd). When the user changes the properties of an object using the grid, the designer needs to be notified so it can update the display. Conversely, when the user edits an object using the designer, the grid needs to be notified and update its display.

• Visual Basic

' when a value changes in the property window, refresh the designer ' to show the changes Private Sub _ppg_PropertyValueChanged(s As Object, e As PropertyValueChangedEventArgs) _c1rd.Refresh() _dirty = True UpdateUI() End Sub '_ppg_PropertyValueChanged ' when properties of the selected objects change in the designer, ' update the property window to show the changes Private Sub _c1rd_ValuesChanged(sender As Object, e As System.EventArgs) _ppg.Refresh() _dirty = True UpdateUI() End Sub '_c1rd_ValuesChanged

• C#

// when a value changes in the property window, refresh the designer // to show the changes private void _ppg_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { _c1rd.Refresh(); _dirty = true; UpdateUI(); } // when properties of the selected objects change in the designer, // update the property window to show the changes private void _c1rd_ValuesChanged(object sender, System.EventArgs e) { _ppg.Refresh();

Page 37: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 33

_dirty = true; UpdateUI(); }

• Delphi

// when a value changes in the property window, refresh the designer // to show the changes procedure Class1._ppg_PropertyValueChanged(s: System.Object; e: PropertyValueChangedEventArgs); begin _c1rd.Refresh; _dirty := True; UpdateUI; End; // when properties of the selected objects change in the designer, // update the property window to show the changes procedure Class1._c1rd_ValuesChanged(sender: System.Object; e: System.EventArgs); begin _ppg.Refresh; _dirty := True; UpdateUI; end;

Step 8: Add code to create and remove reports Removing reports from the list is easy. The DeleteReport method simply removes the selected item from the report list, clears the Report property of the designer control, then makes a new selection if the list is not empty:

• Visual Basic

' remove current report from the list Private Sub DeleteReport() ' a report must be selected Dim index As Integer = _list.SelectedIndex If index < 0 Then Return End If ' remove report from the designer and from the list _c1rd.Report = Nothing _list.Items.RemoveAt(index) ' select another report if we can If index > _list.Items.Count - 1 Then index = _list.Items.Count - 1 End If If index > - 1 Then _list.SelectedIndex = index End If ' done _dirty = True UpdateUI() End Sub 'DeleteReport

• C#

// remove current report from the list private void DeleteReport() { // a report must be selected int index = _list.SelectedIndex; if (index < 0) return;

Page 38: c 1 Report Designer Manual 2005

34 · Overview

// remove report from the designer and from the list _c1rd.Report = null; _list.Items.RemoveAt(index); // select another report if we can if (index > _list.Items.Count-1) index = _list.Items.Count-1; if (index > -1) _list.SelectedIndex = index; // done _dirty = true; UpdateUI(); }

• Delphi

// remove current report from the list procedure DeleteReport; var index: Integer; begin // a report must be selected index := _list.SelectedIndex; if index < 0 then begin exit; end; // remove report from the designer and from the list _c1rd.Report := nil; _list.Items.RemoveAt(index); // select another report if we can if index > _list.Items.Count - 1 then index := _list.Items.Count - 1; if index > - 1 then _list.SelectedIndex := index; // done _dirty := True; UpdateUI; end;

The AddReport method is a little more complex. In the full-fledged report designer, this command invokes a wizard that allows the user to select a data source, grouping options, layout, and style. When implementing your designer, you can use the wizard code as-is or customize it to suit your needs.

Rather than just creating a blank new report, the simple designer prompts the user for an mdb file, selects the first table it can find, then the first five fields, and creates a report based on that. Here is the code:

• Visual Basic

Private Sub NewReport() ' select a data source (just mdb files in this sample) Dim dlg As New OpenFileDialog() dlg.FileName = "*.mdb" dlg.Title = "Select report data source" If dlg.ShowDialog() <> DialogResult.OK Then Return End If ' select first table from data source Dim connString As String = String.Format ' Dim tableName As String = GetFirstTable(connString) If tableName Is Nothing Or tableName.Length = 0 Then End If If (True) Then

Page 39: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 35

MessageBox.Show("Failed to retrieve data from the selected source.") Return End If ' create new report Dim rpt As New C1Report() rpt.ReportName = tableName ' set data source rpt.DataSource.ConnectionString = connString rpt.DataSource.RecordSource = tableName ' add a title field Dim s As Section = rpt.Sections(SectionTypeEnum.Header) s.Visible = True s.Height = 600 Dim f As Field = s.Fields.Add("TitleField", tableName, 0, 0, 4000, 600) f.Font.Bold = True f.Font.Size = 24 f.ForeColor = Color.Navy ' add up to 5 calculated fields Dim fieldNames As String() = rpt.DataSource.GetDBFieldList(True) Dim cnt As Integer = Math.Min(5, fieldNames.Length) ' add a page header s = rpt.Sections(SectionTypeEnum.PageHeader) s.Visible = True s.Height = 400 Dim rc As New Rectangle(0, 0, 1000, CInt(s.Height)) Dim i As Integer For i = 0 To cnt - 1 Next i If (True) Then f = s.Fields.Add("TitleField", fieldNames(i), rc) f.Font.Bold = True rc.Offset(rc.Width, 0) End If ' add detail section s = rpt.Sections(SectionTypeEnum.Detail) s.Visible = True s.Height = 300 rc = New Rectangle(0, 0, 1000, CInt(s.Height)) Dim i As Integer For i = 0 To cnt - 1 Next i If (True) Then f = s.Fields.Add("TitleField", fieldNames(i), rc) f.Calculated = True rc.Offset(rc.Width, 0) End If ' add new report to the list and select it _list.Items.Add(New ReportHolder(rpt)) _list.SelectedIndex = _list.Items.Count - 1 ' done _dirty = True UpdateUI() End Sub 'NewReport

Page 40: c 1 Report Designer Manual 2005

36 · Overview

• C#

private void NewReport() { // select a data source (just mdb files in this sample) OpenFileDialog dlg = new OpenFileDialog(); dlg.FileName = "*.mdb"; dlg.Title = "Select report data source"; if (dlg.ShowDialog() != DialogResult.OK) return; // select first table from data source string connString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", dlg.FileName); string tableName = GetFirstTable(connString); if (tableName == null || tableName.Length == 0) { MessageBox.Show("Failed to retrieve data from the selected source."); return; } // create new report C1Report rpt = new C1Report(); rpt.ReportName = tableName; // set data source rpt.DataSource.ConnectionString = connString; rpt.DataSource.RecordSource = tableName; // add a title field Section s = rpt.Sections[SectionTypeEnum.Header]; s.Visible = true; s.Height = 600; Field f = s.Fields.Add("TitleField", tableName, 0, 0, 4000, 600); f.Font.Bold = true; f.Font.Size = 24; f.ForeColor = Color.Navy; // add up to 5 calculated fields string[] fieldNames = rpt.DataSource.GetDBFieldList(true); int cnt = Math.Min(5, fieldNames.Length); // add a page header s = rpt.Sections[SectionTypeEnum.PageHeader]; s.Visible = true; s.Height = 400; Rectangle rc = new Rectangle(0, 0, 1000, (int)s.Height); for (int i = 0; i < cnt; i++) { f = s.Fields.Add("TitleField", fieldNames[i], rc); f.Font.Bold = true; rc.Offset(rc.Width, 0); } // add detail section s = rpt.Sections[SectionTypeEnum.Detail]; s.Visible = true; s.Height = 300; rc = new Rectangle(0, 0, 1000, (int)s.Height); for (int i = 0; i < cnt; i++) { f = s.Fields.Add("TitleField", fieldNames[i], rc);

Page 41: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 37

f.Calculated = true; rc.Offset(rc.Width, 0); } // add new report to the list and select it _list.Items.Add(new ReportHolder(rpt)); _list.SelectedIndex = _list.Items.Count-1; // done _dirty = true; UpdateUI(); }

• Delphi

procedure NewReport; var dlg: OpenFileDialog; connString: string; tableName: string; rpt: C1Report; s: Section; f: Field; fieldNames: array of string; cnt: Integer; rc: Rectangle; i: Integer; i: Integer; begin // select a data source (just mdb files in this sample) dlg := OpenFileDialog.Create; dlg.FileName := '*.mdb'; dlg.Title := 'Select report data source'; if dlg.ShowDialog <> System.Windows.Forms.DialogResult.OK then exit; // select first table from data source connString := System.String.Format(('Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};', dlg.FileName); tableName := GetFirstTable(connString); if (tableName = nil) or (tableName.Length = 0) then begin MessageBox.Show('Failed to retrieve data from the selected source.'); exit; end; // create new report rpt := C1Report.Create; rpt.ReportName := tableName; // set data source rpt.DataSource.ConnectionString := connString; rpt.DataSource.RecordSource := tableName; // add a title field s := rpt.Sections(SectionTypeEnum.Header); s.Visible := True; s.Height := 600; f := s.Fields.Add('TitleField', tableName, 0, 0, 4000, 600); f.Font.Bold := True; f.Font.Size := 24; f.ForeColor := Color.Navy;

Page 42: c 1 Report Designer Manual 2005

38 · Overview

// add up to 5 calculated fields fieldNames := rpt.DataSource.GetDBFieldList(True); cnt := Math.Min(5, fieldNames.Length); // add a page header s := rpt.Sections(SectionTypeEnum.PageHeader); s.Visible := True; s.Height := 400; rc := Rectangle.Create(0, 0, 1000, Integer(s.Height)); for i = 0 to cnt - 1 do begin f := s.Fields.Add('TitleField', fieldNames[i], rc); f.Font.Bold := True; rc.Offset(rc.Width, 0); end; // add detail section s := rpt.Sections(SectionTypeEnum.Detail); s.Visible := True; s.Height := 300; rc := Rectangle.Create(0, 0, 1000, CInt(s.Height)); for i = 0 to cnt - 1 do begin f := s.Fields.Add('TitleField', fieldNames[i], rc); f.Calculated := True; rc.Offset(rc.Width, 0); end; // add new report to the list and select it _list.Items.Add(ReportHolder.Create(rpt)); _list.SelectedIndex := _list.Items.Count - 1; // done _dirty := True; UpdateUI; end;

The code uses a helper function GetFirstTable that opens a connection, retrieves the db schema, and returns the name of the first table it finds.

• Visual Basic

Private Function GetFirstTable(connString As String) As String Dim tableName As String = Nothing Dim conn As New OleDbConnection(connString) Try ' get schema conn.Open() Dim dt As DataTable = conn.GetOleDbSchemaTable( OleDbSchemaGuid.Tables, Nothing) Dim dr As DataRow For Each dr In dt.Rows ' check the table type Dim type As String = dr("TABLE_TYPE").ToString().ToUpper() If type = "TABLE" Or type = "VIEW" Or type = "LINK" Then ' get the table name tableName = dr("TABLE_NAME").ToString() End If Next dr ' done conn.Close() Catch End Try

Page 43: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 39

' return the first table we found Return tableName End Function 'GetFirstTable

• C#

private string GetFirstTable(string connString) { string tableName = null; OleDbConnection conn = new OleDbConnection(connString); try { // get schema conn.Open(); DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); foreach (DataRow dr in dt.Rows) { // check the table type string type = dr["TABLE_TYPE"].ToString().ToUpper(); if (type != "TABLE" && type != "VIEW" && type != "LINK") continue; // get the table name tableName = dr["TABLE_NAME"].ToString(); break; } // done conn.Close(); } catch {} // return the first table we found return tableName; }

• Delphi

function GetFirstTable(connString: String): string; var tableName: String; conn: OleDbConnection; dt: DataTable; dr: DataRow; t: String; i: Integer; begin conn := OleDbConnection.Create(connString); tableName := nil; try // get schema conn.Open; dt := conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, nil); for i := 0 to dt.Rows.Count - 1 do begin dr := dt.Rows[i]; // check the table type t := dr['TABLE_TYPE'].ToString.ToUpper; if (t <> 'TABLE') and (t <> 'VIEW') and (t <> 'LINK') then continue; // get the table name

Page 44: c 1 Report Designer Manual 2005

40 · Overview

tableName := dr['TABLE_NAME'].ToString; break; end; // done conn.Close; except end; // return the first table we found Result := tableName; end;

Step 9: Add code to create fields The simple designer is almost done. The only missing thing is the code used to create new fields in the report.

If you look at the code we are using for the toolbar event handler, you will see that it set the CreateFieldInfo property on the designer and says to wait for the CreateField event from the designer. Here is the code:

• Visual Basic

' handle clicks on toolbar buttons Private Sub _tb_ButtonClick(sender As Object, e As ToolBarButtonClickEventArgs) ' … ' add fields ' (just set create info and wait for CreateField event from designer) If e.Button = _btnAddField Then _c1rd.CreateFieldInfo = e.Button End If If e.Button = _btnAddLabel Then _c1rd.CreateFieldInfo = e.Button End If End Sub '_tb_ButtonClick

• C#

// handle clicks on toolbar buttons private void _tb_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { // … // add fields // (just set create info and wait for CreateField event from designer) if (e.Button == _btnAddField) _c1rd.CreateFieldInfo = e.Button; if (e.Button == _btnAddLabel) _c1rd.CreateFieldInfo = e.Button; }

• Delphi

// handle clicks on toolbar buttons procedure Class1._tb_ButtonClick(sender: System.Object; e: ToolBarButtonClickEventArgs); begin // add fields // (just set create info and wait for CreateField event from designer) if (e.Button = _btnAddField) then _c1rd.CreateFieldInfo := e.Button; if (e.Button = _btnAddLabel) then _c1rd.CreateFieldInfo := e.Button; end;

Page 45: c 1 Report Designer Manual 2005

Using the C1ReportDesigner Control · 41

The CreateFieldInfo property can be set to any non-null object to indicate to the designer that you want to create a new field. The designer doesn't know what type of field you want to create or how you want to initialize it, so it tracks the mouse and allows the user to draw the field outline on a section. It then fires the CreateField event passing the information you need to create the field yourself.

Here is how the simple designer handles the CreateField event:

• Visual Basic

Dim _ctr As Integer = 0 Private Sub _c1rd_CreateField(sender As Object, e As C1.Win.C1ReportDesigner.CreateFieldEventArgs) ' save undo info _c1rd.UndoStack.SaveState() ' add label field Dim fieldName As String = String.Format("NewField{0}", ++ _ctr) 'ToDo: Unsupported operator 'ToDo: ++ operator not supported within expressions Dim fieldText As String = fieldName Dim f As Field = e.Section.Fields.Add(fieldName, fieldText, e.FieldBounds) ' if this is a calculated field, ' change the Text and Calculated properties If e.CreateFieldInfo = _btnAddField Then Dim fieldNames As String() = _c1rd.Report.DataSource.GetDBFieldList(True) If fieldNames.Length > 0 Then f.Text = fieldNames(0) f.Calculated = True End If End If End Sub '_c1rd_CreateField

• C#

int _ctr = 0; private void _c1rd_CreateField(object sender, C1.Win.C1ReportDesigner.CreateFieldEventArgs e) { // save undo info _c1rd.UndoStack.SaveState(); // add label field string fieldName = string.Format("NewField{0}", ++_ctr); string fieldText = fieldName; Field f = e.Section.Fields.Add(fieldName, fieldText, e.FieldBounds); // if this is a calculated field, // change the Text and Calculated properties if (e.CreateFieldInfo == _btnAddField) { string[] fieldNames = _c1rd.Report.DataSource.GetDBFieldList(true); if (fieldNames.Length > 0) { f.Text = fieldNames[0]; f.Calculated = true; } } }

Page 46: c 1 Report Designer Manual 2005

42 · Overview

• Delphi

procedure _c1rd_CreateField(sender: System.Object; e: C1.Win.C1ReportDesigner.CreateFieldEventArgs); var fieldName: string; fieldText: string; f: Field; fieldNames: array of string; begin // save undo info _c1rd.UndoStack.SaveState; // add label field Inc(_ctr); fieldName := System.String.Format('NewField{0}', System.Object(_ctr)); // ToDo: Unsupported operator // ToDo: ++ operator not supported within expressions fieldText := fieldName; f := e.Section.Fields.Add(fieldName, fieldText, e.FieldBounds); // if this is a calculated field, // change the Text and Calculated properties if e.CreateFieldInfo = _btnAddField then begin fieldNames := _c1rd.Report.DataSource.GetDBFieldList(True); if fieldNames.Length > 0 then begin f.Text := fieldNames[0]; f.Calculated := True; end; end; end;

Note how the code starts by calling the SaveState method on the designer, so the user can undo the field creation.

After that, the field is created, and the CreateFieldInfo parameter is used to customize the new field and make it behave as a label or as a calculated field.

That concludes the simple designer application. It doesn't qualify as a powerful designer, but it is a good introduction to the operation of the C1ReportDesigner control, and should give you some ideas and make it easier to understand how the full-fledged C1ReportDesigner application works.

Page 47: c 1 Report Designer Manual 2005

C1ReportDesigner Control · 43

Object Reference C1ReportDesigner Control

The C1ReportDesigner is a Windows Forms control that provides the ability to design and edit report definitions that can be used with the C1Report, C1WebReport, and VSReport controls.

To use the C1ReportDesigner control, drag it onto a new or existing form, add a C1Report component that will contain the report you want to edit, and set the Report property in the designer control. Then add all the other UI elements your application needs.

C1ReportDesigner Members C1ReportDesigner Public Properties

AllowInPlaceEditing Gets or sets whether the user should be able to edit the Text property of selected fields but typing directly into the designer.

AutoAdjustReportDimensions Gets or sets whether the control should automatically adjust the report dimensions after fields are moved.

AutoScroll Gets or sets whether the control should scroll automatically when the user drags the mouse near the edges.

BackColor Gets or sets the background color of the control.

BackColorEmpty Gets or sets the background color for the empty area.

BackColorSection Gets or sets the background color of the Section headers.

BorderStyleSection Gets or sets the border style for the Section headers.

ClipboardHandler Gets the ClipboardHandler object used for clipboard operations.

ColorFieldEdge Gets or sets the color of the edge drawn around the report fields.

ColorReportEdge Gets or sets the color of the edge drawn around the work area.

CreateFieldInfo Gets or sets an object that contains information about a field to be created by the designer.

Cursor Gets or sets the cursor that is displayed when the mouse pointer is over the control.

ForeColor Gets or sets the foreground color of the control.

ForeColorGroup Gets or sets the color used to paint the Group information.

ForeColorSection Gets or sets the color used to paint the Section names.

Grid Gets the Grid object that controls the grid appearance and behavior.

Page 48: c 1 Report Designer Manual 2005

44 · Object Reference

Locked Gets or sets whether the fields are locked in the designer.

Report Gets or sets the C1Report control that contains the report being edited.

Ruler Gets the Ruler object that controls the ruler appearance.

SelectedFields Gets or sets the report fields that are currently selected in the editor.

SelectedSection Gets the report section that is currently selected in the editor.

UndoStack Gets the undo stack object used for undo/redo operations.

C1ReportDesigner Public Instance Methods

HitTest Gets a HitTestInfo object that describes the contents of the control at a given position on the screen.

Refresh Repaints the designer and adjusts report and section dimensions to fit fields.

ToPixelsX Convert pixels to twips.

ToPixelsY Convert pixels to twips.

ToTwipsX Convert twips to pixels.

ToTwipsY Convert twips to pixels.

C1ReportDesigner Public Events

CreateField Fired when the user marks the location of a new field using the mouse, after the CreateFieldInfo property was set to a non-null value.

DeleteField Fired before the user deletes the selected fields.

MoveCopyFields Fired before the user moves or copies fields with the mouse.

RenderField Fired before a field is rendered by the designer.

RenderSectionHeader Fired before a section header is rendered by the designer.

ReportChanged Fired when a new report is assigned to the control (see the Report property).

ResizeFieldSection Fired before the user resizes fields, sections (height), or the report (width) with the mouse.

SelectionChanged Fired when fields are selected or de-selected.

ValuesChanged Fired when the report changes (e.g., fields are moved/resized or copied with the mouse).

Page 49: c 1 Report Designer Manual 2005

AllowInPlaceEditing Property · 45

C1ReportDesigner Properties

AllowInPlaceEditing Property Gets or sets whether the user should be able to edit the Text property of selected fields but typing directly into the designer.

Syntax

[VB]

Public Property AllowInPlaceEditing As Boolean

[C#]

public bool AllowInPlaceEditing {get; set;}

[Delphi]

property AllowInPlaceEditing: Boolean;

Remarks

If this property is set to true, then the user can select field objects in the designer and type text directly into them. The text is assigned to the field's Text property. If the property is set to false, then the user must edit the field text using a property grid control attached to the field.

See Also

C1ReportDesigner Control (page 43)

AutoAdjustReportDimensions Property Gets or sets whether the control should automatically adjust the report dimensions after fields are moved.

Syntax

[VB]

Public Property AutoAdjustReportDimensions As AutoAdjustEnum

[C#]

public AutoAdjustEnum AutoAdjustReportDimensions {get; set;}

[Delphi]

property AutoAdjustReportDimensions: AutoAdjustEnum;

Remarks

If this property is set to true and the user drags a field beyond the edge of the report, the report width is adjusted so the field will fit.

Possible values are members of the AutoAdjustEnum enumeration:

Member Name Description

Both Adjusts the height and width of the report.

None No adjustments

ReportWidth Adjusts the width of the report.

Page 50: c 1 Report Designer Manual 2005

46 · Object Reference

Member Name Description

SectionHeight Adjusts the height of the specified section.

See Also

C1ReportDesigner Control (page 43)

AutoScroll Property Gets or sets whether the control should scroll automatically when the user drags the mouse near the edges.

Syntax

[VB]

Public Property AutoScroll As Boolean

[C#]

public bool AutoScroll {get; set;}

[Delphi]

property AutoScroll: Boolean;

Remarks

If this property is set to true and the user drags the mouse near the edge of the control (while moving or resizing fields), the control will scroll automatically to bring the area being worked on into view.

See Also

C1ReportDesigner Control (page 43)

BackColor Property Gets or sets the background color of the control.

Syntax

[VB]

Public Property BackColor As Color

[C#]

public Color BackColor {get; set;}

[Delphi]

property BackColor: Color;

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

Page 51: c 1 Report Designer Manual 2005

BackColorEmpty Property · 47

BackColorEmpty Property Gets or sets the background color for the empty area.

Syntax

[VB]

Public Property BackColorEmpty As Color

[C#]

public Color BackColorEmpty {get; set;}

[Delphi]

property BackColorEmpty: Color;

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

BackColorSection Property Gets or sets the background color of the Section headers.

Syntax

[VB]

Public Property BackColorSection As Color

[C#]

public Color BackColorSection {get; set;}

[Delphi]

property BackColorSection: Color;

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

BorderStyleSection Property Gets or sets the border style for the Section headers.

Syntax

[VB]

Public Property BorderStyleSection As Border3DStyle

[C#]

public Border3DStyle BorderStyleSection {get; set;}

Page 52: c 1 Report Designer Manual 2005

48 · Object Reference

[Delphi]

property BorderStyleSection: Border3DStyle;

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

ClipboardHandler Property Gets the ClipboardHandler object used for clipboard operations.

Syntax

[VB]

Public Property ClipboardHandler As ClipboardHandler

[C#]

public ClipboardHandler ClipboardHandler {get;}

[Delphi]

property ClipboardHandler: ClipboardHandler;

Remarks

The ClipboardHandler object provides support for standard Cut/Copy/Paste/Delete operations for report fields using the system clipboard.

See Also

C1ReportDesigner Control (page 43)

ColorReportEdge Property Gets or sets the color of the edge drawn around the work area.

Syntax

[VB]

Public Property ColorReportEdge As Color

[C#]

public Color ColorReportEdge {get; set;}

[Delphi]

property ColorReportEdge: Color;

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

Page 53: c 1 Report Designer Manual 2005

ColorFieldEdge Property · 49

ColorFieldEdge Property Gets or sets the color of the edge drawn around the report fields.

Syntax

[VB]

Public Property ColorFieldEdge As Color

[C#]

public Color ColorFieldEdge {get; set;}

[Delphi]

property ColorFieldEdge: Color;

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

CreateFieldInfo Property Gets or sets an object that contains information about a field to be created by the designer.

Syntax

[VB]

Public Property CreateFieldInfo As Object

[C#]

public object CreateFieldInfo {get; set;}

[Delphi]

property CreateFieldInfo: Object;

Remarks

When you set this object to a non-null value, the designer assumes you want to create a new field. It will change the mouse cursor into a cross-hair and will allow the user to mark the position of the new field on the report.

When the user concludes the mouse operation, the control fires the CreateField event. At this point, the event handler can refer to the CreateInfoProperty and use the information in the event parameters to create a new field and initialize it. (See the sample designer application for more details).

Example

The C1ReportDesigner application has a toolbar that is used for creating new fields. The toolbar contains buttons for several different types of fields. When a button is clicked, the application stores a reference to the button that was clicked in the CreateFieldInfo property and waits for the CreateField event. When the user moves the mouse over the designer, the cursor changes into a crosshair to indicate to the user that he can mark the location for the new field. When the user is done marking the location of the new field, the control fires the CreateField event and the application uses the information in the event parameters to create the field.

Here is a simplified version of the code in the C1ReportDesigner:

Page 54: c 1 Report Designer Manual 2005

50 · Object Reference

• Visual Basic

Private Sub _tbCreate_ButtonClick(sender As Object, e As ToolBarButtonClickEventArgs) ' save type of field to create and wait for the CreateField event _designer.CreateFieldInfo = e.Button End Sub '_tbCreate_ButtonClick ' user is creating a field with the mouse ' (in response to setting the _designer.CreateFieldInfo property) Private Sub _designer_CreateField(sender As Object, e As CreateFieldEventArgs) ' save undo info _designer.UndoStack.SaveState() ' create new field in this section Dim fldName As String = GetUniqueFieldName() Dim fields As FieldCollection = e.Section.Fields Dim field As Field = fields.Add(fldName, Nothing, e.FieldBounds) ' set new field properties based on CreateFieldInfo Dim btn As Object = e.CreateFieldInfo If btn = _btnLabel Then field.Text = field.Name field.Calculated = False Else If btn = _btnPageBreak Then field.ForcePageBreak = ForcePageBreakEnum.After field.Calculated = False Else If btn = _btnRectangle Then field.BorderStyle = BorderStyleEnum.Solid field.Calculated = False Else Debug.Assert(False, "Unknown field creator object") End If End If End If ' select the new field, zap creator _designer.CreateFieldInfo = Nothing _designer.SelectedFields = New Field() {field} End Sub '_designer_CreateField

• C#

private void _tbCreate_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { // save type of field to create and wait for the CreateField event _designer.CreateFieldInfo = e.Button; } // user is creating a field with the mouse // (in response to setting the _designer.CreateFieldInfo property) private void _designer_CreateField(object sender, CreateFieldEventArgs e) { // save undo info _designer.UndoStack.SaveState(); // create new field in this section string fldName = GetUniqueFieldName(); FieldCollection fields = e.Section.Fields; Field field = fields.Add(fldName, null, e.FieldBounds);

Page 55: c 1 Report Designer Manual 2005

CreateFieldInfo Property · 51

// set new field properties based on CreateFieldInfo object btn = e.CreateFieldInfo; if (btn == _btnLabel) { field.Text = field.Name; field.Calculated = false; } else if (btn == _btnPageBreak) { field.ForcePageBreak = ForcePageBreakEnum.After; field.Calculated = false; } else if (btn == _btnRectangle) { field.BorderStyle = BorderStyleEnum.Solid; field.Calculated = false; } else { Debug.Assert(false, "Unknown field creator object"); } // select the new field, zap creator _designer.CreateFieldInfo = null; _designer.SelectedFields = new Field[] { field }; }

• Delphi

procedure Class1._tbCreate_ButtonClick(sender: System.Object; e: ToolBarButtonClickEventArgs); begin // save type of field to create and wait for the CreateField event _designer.CreateFieldInfo := e.Button; end; // user is creating a field with the mouse // (in response to setting the _designer.CreateFieldInfo property) procedure Class1._designer_CreateField(sender: System.Object; e: CreateFieldEventArgs); var btn: System.Object; field: Field; fields: FieldCollection; fldName: string; flds: array of fields; begin // save undo info _designer.UndoStack.SaveState; // create new field in this section fldName := GetUniqueFieldName; fields := e.Section.Fields; field := fields.Add(fldName, nil, e.FieldBounds); // set new field properties based on CreateFieldInfo btn := e.CreateFieldInfo; if (btn = _btnLabel) then begin field.Text := field.Name; field.Calculated := False; end else if (btn = _btnPageBreak) then

Page 56: c 1 Report Designer Manual 2005

52 · Object Reference

begin field.ForcePageBreak := ForcePageBreakEnum.After; field.Calculated := False; end else if (btn = _btnRectangle) then begin field.BorderStyle := BorderStyleEnum.Solid; field.Calculated := False; end else Debug.Assert(False, 'Unknown field creator object'); // select the new field, zap creator _designer.CreateFieldInfo := nil;

SetLength(flds, 1); flds[0] := field;

_designer.SelectedFields := flds; end;

See Also

C1ReportDesigner Control (page 43)

Cursor Property Gets or sets the cursor that is displayed when the mouse pointer is over the control.

Syntax

[VB]

Public Property Cursor As Cursor

[C#]

public Cursor Cursor {get; set;}

[Delphi]

property Cursor: Cursor;

See Also

C1ReportDesigner Control (page 43)

ForeColor Property Gets or sets the foreground color of the control.

Syntax

[VB]

Public Property ForeColor As Color

[C#]

public Color ForeColor {get; set;}

[Delphi]

property ForeColor: Color;

Page 57: c 1 Report Designer Manual 2005

ForeColorGroup Property · 53

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

ForeColorGroup Property Gets or sets the color used to paint the Group information.

Syntax

[VB]

Public Property ForeColorGroup As Color

[C#]

public Color ForeColorGroup {get; set;}

[Delphi]

property ForeColorGroup: Color;

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

ForeColorSection Property Gets or sets the color used to paint the Section names.

Syntax

[VB]

Public Property ForeColorSection As Color

[C#]

public Color ForeColorSection {get; set;}

[Delphi]

property ForeColorSection: Color;

Remarks

This property only affects the appearance of the designer control, and has no effect on the report definition.

See Also

C1ReportDesigner Control (page 43)

Page 58: c 1 Report Designer Manual 2005

54 · Object Reference

Grid Property Gets the Grid object that controls the grid appearance and behavior.

Syntax

[VB]

Public Property Grid As Grid

[C#]

public Grid Grid {get;}

[Delphi]

property Grid: Grid;

Remarks

The Grid object is documented below. It allows you to control the appearance (visibility, colors, units) and behavior (snapping) of the design grid.

See Also

C1ReportDesigner Control (page 43)

Locked Property Gets or sets whether the fields are locked in the designer.

Syntax

[VB]

Public Property Locked As Boolean

[C#]

public bool Locked {get; set;}

[Delphi]

property Locked: Boolean;

Remarks

This property works as a global toggle and affects all fields in the report. You cannot lock some fields and leave others unlocked.

See Also

C1ReportDesigner Control (page 43)

Report Property Gets or sets the C1Report control that contains the report being edited.

Syntax

[VB]

Public Property Report As C1Report

Page 59: c 1 Report Designer Manual 2005

Report Property · 55

[C#]

public C1Report Report {get; set;}

[Delphi]

property Report: C1Report;

Remarks

This is the main property in the control. To edit a report, you have to load it into a C1Report component and connect the component to the designer using the Report property. Any changes made to the report via the designer are applied to the report in the C1Report component. To save the changes, you should call the Save method in the C1Report component.

Example

The C1ReportDesigner application allows the user to load a report definition file, then creates a separate C1Report component for each report in the file. The C1Report components are stored in a list (the one you see on the left of the main form). When the user selects a report from the list, the report is displayed in the designer control using the following code:

• Visual Basic

Private Sub _reportList_SelectedIndexChanged(sender As Object, e As System.EventArgs) ' make sure we're in design view ReportDesignMode = True ' reset any create field information _designer.CreateFieldInfo = Nothing ' assign selected report to designer component Dim rw As ReportItem = _reportList.SelectedItem If rw Is Nothing Then designer.Report = Nothing Else designer.Report = rw._report End If ' update UI UpdateUI() End Sub '_reportList_SelectedIndexChanged

• C#

private void _reportList_SelectedIndexChanged(object sender, System.EventArgs e) { // make sure we're in design view ReportDesignMode = true; // reset any create field information _designer.CreateFieldInfo = null; // assign selected report to designer component ReportItem rw = _reportList.SelectedItem; _designer.Report = (rw != null)? rw._report: null; // update UI UpdateUI(); }

Page 60: c 1 Report Designer Manual 2005

56 · Object Reference

• Delphi

procedure Class1._reportList_SelectedIndexChanged(sender: System.Object; e: System.EventArgs); var rw: ReportItem; begin // make sure we're in design view ReportDesignMode := True; // reset any create field information _designer.CreateFieldInfo := nil; // assign selected report to designer component rw := _reportList.SelectedItem;

if rw <> null then _designer.Report := rw.Report else

_ designer.Report := nil; // update UI UpdateUI; end;

See Also

C1ReportDesigner Control (page 43)

Ruler Property Gets the Ruler object that controls the ruler appearance.

Syntax

[VB]

Public Property Ruler As Ruler

[C#]

public Ruler Ruler {get;}

[Delphi]

property Ruler: Ruler;

Remarks

The Ruler object is documented below. It allows you to control the appearance (colors, fonts, border style) of the ruler in the designer control.

The Ruler object only affects the appearance of the designer control, and has no effect on the report definition. The spacing of the marks on the ruler is determined by the Grid.Units property.

See Also

C1ReportDesigner Control (page 43)

Page 61: c 1 Report Designer Manual 2005

SelectedFields Property · 57

SelectedFields Property Gets or sets the report fields that are currently selected in the editor.

Syntax

[VB]

Public Property SelectedFields As Field

[C#]

public Field[] SelectedFields {get; set;}

[Delphi]

property SelectedFields: Field;

Remarks

This property exposes the selected fields, usually for editing with a PropertyGrid control.

This is one of the most important properties in the designer control. The designer control exposes a design pane that allows users to select, move, resize, copy, and delete fields. It also manages user selections, which are exposed through the SelectedFields and SelectedSection properties. The control does not provide any means for editing most field and section properties (e.g. BackColor, ForeColor, Visible, etc.). For this, the application should use a PropertyGrid control connected to the current selection, and it should update the property grid in response to events that indicate the selection has changed.

When several fields are selected, the last one in the selection is highlighted in a different color and is referred to as the reference field. When multiple fields are to be aligned or resized, the reference field provides the position and size to be used for the others. The second example below illustrates this.

Example

The code below shows how the C1ReportDesigner application manages the connection between the PropertyGrid and the objects selected in the designer. The connection is made through the designer's SelectionChanged event. Depending on the selection, the grid shows the properties of the selected fields, the selected section, or the whole report.

• Visual Basic

' selection changed, update property grid Private Sub _designer_SelectionChanged(sender As Object, e As System.EventArgs) ' show field properties Dim sel As Object() = _designer.SelectedFields If sel.Length > 0 Then _propLabel.Text = " Field Properties" _propGrid.SelectedObjects = sel ' show section properties Else If Not (_designer.SelectedSection Is Nothing) Then _propLabel.Text = " Section Properties" _propGrid.SelectedObject = _designer.SelectedSection ' show report properties Else If Not (_designer.Report Is Nothing) Then _propLabel.Text = " Report Properties" _propGrid.SelectedObject = _designer.Report ' nothing to show...

Page 62: c 1 Report Designer Manual 2005

58 · Object Reference

Else _propLabel.Text = " Properties" _propGrid.SelectedObject = Nothing End If End If End If ' update UI (_menus, toolbars, etc.) _designer.CreateFieldInfo = Nothing UpdateUI() End Sub '_designer_SelectionChanged

• C#

// selection changed, update property grid private void _designer_SelectionChanged(object sender, System.EventArgs e) { // show field properties object[] sel = _designer.SelectedFields; if (sel.Length > 0) { _propLabel.Text = " Field Properties"; _propGrid.SelectedObjects = sel; } // show section properties else if (_designer.SelectedSection != null) { _propLabel.Text = " Section Properties"; _propGrid.SelectedObject = _designer.SelectedSection; } // show report properties else if (_designer.Report != null) { _propLabel.Text = " Report Properties"; _propGrid.SelectedObject = _designer.Report; } // nothing to show... else { _propLabel.Text = " Properties"; _propGrid.SelectedObject = null; } // update UI (_menus, toolbars, etc.) _designer.CreateFieldInfo = null; UpdateUI(); }

• Delphi

// selection changed, update property grid procedure Class1._designer_SelectionChanged(sender: System.Object; e: System.EventArgs); var // show field properties sel: array of System.Object; begin sel := _designer.SelectedFields; if (Length(sel) > 0) then begin _propLabel.Text := ' Field Properties'; _propGrid.SelectedObjects := sel;

Page 63: c 1 Report Designer Manual 2005

SelectedFields Property · 59

end // show section properties else if (_designer.SelectedSection <> nil) then begin _propLabel.Text := ' Section Properties'; _propGrid.SelectedObject := _designer.SelectedSection; end // show report properties else if (_designer.Report <> nil) then begin _propLabel.Text := ' Report Properties'; _propGrid.SelectedObject := _designer.Report; end // nothing to show... else begin _propLabel.Text := ' Properties'; _propGrid.SelectedObject := nil; end; // update UI (_menus, toolbars, etc.) _designer.CreateFieldInfo := nil; UpdateUI; end;

The SelectedFields property is also useful for implementing commands that act on a field or group of fields. For example, the C1ReportDesigner application has commands that allow the user to align the selected fields. The code below shows how you might implement some of these commands (note that the last field in the selection is used as a reference for aligning the others):

• Visual Basic

' format toolbar Private Sub _tbFormat_ButtonClick(sender As Object, e As ToolBarButtonClickEventArgs) ' get ready to work Dim sel As Field() = _designer.SelectedFields Debug.Assert((sel.Length > 0)) ' get reference field (last in the selection) Dim refFld As Field = CType(sel((sel.Length - 1)), Field) ' save undo info _designer.UndoStack.SaveState() ' align fields If e.Button = _btnAlignLeft Then Dim i As Integer For i = 0 To sel.Length - 1 sel(i).Left = refFld.Left Next i Else If e.Button = _btnAlignCenter Then Dim mid As Double = refFld.Left + refFld.Width / 2 Dim i As Integer For i = 0 To sel.Length - 1 sel(i).Left = mid - sel(i).Width / 2 Next i Else

Page 64: c 1 Report Designer Manual 2005

60 · Object Reference

If e.Button = _btnAlignRight Then Dim right As Double = refFld.Left + refFld.Width Dim i As Integer For i = 0 To sel.Length - 1 sel(i).Left = right - sel(i).Width Next i Else If e.Button = _btnAlignTop Then Dim i As Integer For i = 0 To sel.Length - 1 sel(i).Top = refFld.Top Next i Else If e.Button = _btnAlignMiddle Then Dim mid As Double = refFld.Top + refFld.Height / 2 Dim i As Integer For i = 0 To sel.Length - 1 sel(i).Top = mid - sel(i).Height / 2 Next i Else If e.Button = _btnAlignBottom Then Dim bottom As Double = refFld.Top + refFld.Height Dim i As Integer For i = 0 To sel.Length - 1 sel(i).Top = bottom - sel(i).Height Next i End If End If ' show the changes End If End If End If End If _designer.Refresh() UpdateUI() End Sub '_tbFormat_ButtonClick

• C#

// format toolbar private void _tbFormat_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { // get ready to work Field[] sel = _designer.SelectedFields; Debug.Assert(sel.Length > 0); // get reference field (last in the selection) Field refFld = (Field)sel[sel.Length-1]; // save undo info _designer.UndoStack.SaveState(); // align fields if (e.Button == _btnAlignLeft) { for (int i = 0; i < sel.Length; i++) sel[i].Left = refFld.Left; } else if (e.Button == _btnAlignCenter) { double mid = refFld.Left + refFld.Width/2; for (int i = 0; i < sel.Length; i++) sel[i].Left = mid - sel[i].Width/2; } else if (e.Button == _btnAlignRight)

Page 65: c 1 Report Designer Manual 2005

SelectedFields Property · 61

{ double right = refFld.Left + refFld.Width; for (int i = 0; i < sel.Length; i++) sel[i].Left = right - sel[i].Width; } else if (e.Button == _btnAlignTop) { for (int i = 0; i < sel.Length; i++) sel[i].Top = refFld.Top; } else if (e.Button == _btnAlignMiddle) { double mid = refFld.Top + refFld.Height/2; for (int i = 0; i < sel.Length; i++) sel[i].Top = mid - sel[i].Height/2; } else if (e.Button == _btnAlignBottom) { double bottom = refFld.Top + refFld.Height; for (int i = 0; i < sel.Length; i++) sel[i].Top = bottom - sel[i].Height; } // show the changes _designer.Refresh(); UpdateUI(); }

• Delphi

// format toolbar procedure _tbFormat_ButtonClick(sender: System.Object; e: ToolBarButtonClickEventArgs); var sel: array of Field; refFld: Field; i: Integer; right, mid: double; begin // get ready to work sel := _designer.SelectedFields; Debug.Assert(sel.Length > 0); // get reference field (last in the selection) refFld := Field(sel[sel.Length - 1]); // save undo info _designer.UndoStack.SaveState; // align fields If e.Button = _btnAlignLeft Then for i := 0 To sel.Length - 1 do sel[i].Left := refFld.Left else If e.Button = _btnAlignCenter Then mid := refFld.Left + refFld.Width / 2; for i := 0 to sel.Length - 1 do sel[i].Left = mid - sel[i].Width / 2 Else If e.Button = _btnAlignRight Then right := refFld.Left + refFld.Width; for i := 0 to sel.Length - 1 do sel[i].Left := right - sel[i].Width Else If e.Button = _btnAlignTop Then

Page 66: c 1 Report Designer Manual 2005

62 · Object Reference

for i := 0 to sel.Length - 1 do sel[i].Top := refFld.Top Else If e.Button = _btnAlignMiddle Then mid := refFld.Top + refFld.Height / 2; for i := 0 to sel.Length - 1 do sel[i].Top := mid - sel[i].Height / 2 Else If e.Button = _btnAlignBottom Then bottom := refFld.Top + refFld.Height; for i := 0 to sel.Length - 1 do sel[i].Top = bottom - sel[i].Height _designer.Refresh; UpdateUI; end; //_tbFormat_ButtonClick

See Also

C1ReportDesigner Control (page 43)

SelectedSection Property Gets the report section that is currently selected in the editor.

Syntax

[VB]

Public Property SelectedSection As Section

[C#]

public Section SelectedSection {get;}

[Delphi]

property SelectedSection: Section;

Remarks

This property exposes the section for editing with a PropertyGrid control (when the SelectedFields property returns an empty array).

For an example, see the SelectedFields property.

See Also

C1ReportDesigner Control (page 43)

SelectedFields Property (page 57)

UndoStack Property Gets the undo stack object used for undo/redo operations.

Syntax

[VB]

Public Property UndoStack As UndoStack

[C#]

public UndoStack UndoStack {get;}

Page 67: c 1 Report Designer Manual 2005

UndoStack Property · 63

[Delphi]

property UndoStack: UndoStack;

Remarks

The UndoStack object is documented below. It allows you to save the state of the designer and restore it on demand.

Note: The UndoStack is also used internally by the designer control. For example, when the user moves a group of fields with the mouse, the control automatically saves the state of the report before the change so it can be undone.

Before changing the report using code, you should also save the state of the control by calling the UndoStack.SaveState() method.

Example

The code below shows how you should use the UndoStack.SaveState method to save the report state before performing clipboard operations such as Cut, Paste, and Delete:

• Visual Basic

' handle clipboard commands (for reports and fields) Private Sub HandleClipboard(cmd As ToolBarButton) ' save undo state for all but copy If cmd <> _btnCopy Then _designer.UndoStack.SaveState() _dirty = True End If ' execute command Dim clip As ClipboardHandler = _designer.ClipboardHandler If cmd = _btnCut Then clip.Cut() End If If cmd = _btnCopy Then clip.Copy() End If If cmd = _btnPaste Then clip.Paste() End If If cmd = _btnDelete Then clip.Delete() End If ' update UI when done UpdateUI() End Sub 'HandleClipboard

• C#

// handle clipboard commands (for reports and fields) private void HandleClipboard(ToolBarButton cmd) { // save undo state for all but copy if (cmd != _btnCopy) { _designer.UndoStack.SaveState(); _dirty = true; } // execute command ClipboardHandler clip = _designer.ClipboardHandler; if (cmd == _btnCut) clip.Cut(); if (cmd == _btnCopy) clip.Copy();

Page 68: c 1 Report Designer Manual 2005

64 · Object Reference

if (cmd == _btnPaste) clip.Paste(); if (cmd == _btnDelete) clip.Delete(); // update UI when done UpdateUI(); }

• Delphi

// handle clipboard commands (for reports and fields) procedure Class1.HandleClipboard(cmd: ToolBarButton); var clip: ClipboardHandler; begin // save undo state for all but copy if (cmd <> _btnCopy) then begin _designer.UndoStack.SaveState; _dirty := True; end; // execute command clip := _designer.ClipboardHandler; if (cmd = _btnCut) then clip.Cut; if (cmd = _btnCopy) then clip.Copy; if (cmd = _btnPaste) then clip.Paste; if (cmd = _btnDelete) then clip.Delete; // update UI when done UpdateUI; end;

Note that after performing the action, the code calls the UpdateUI method. This method is implemented by the application to update the enabled state of several UI elements and indicate to the user whether he can perform operations such as Undo/Redo, Cut/Copy/Paste, etc. Here is a simple implementation of a UpdateUI method in a report designer application:

• Visual Basic

' update UI (_menus, toolbars, etc.) Private Sub UpdateUI() _btnUndo.Enabled = _designer.UndoStack.CanUndo _btnRedo.Enabled = _designer.UndoStack.CanRedo _btnCut.Enabled = _btnCopy.Enabled = _btnDelete.Enabled = _designer.ClipboardHandler.CanCut _btnPaste.Enabled = _designer.ClipboardHandler.CanPaste End Sub

• C#

// update UI (_menus, toolbars, etc.) private void UpdateUI() { _btnUndo.Enabled = _designer.UndoStack.CanUndo; _btnRedo.Enabled = _designer.UndoStack.CanRedo; _btnCut.Enabled = _btnCopy.Enabled =

Page 69: c 1 Report Designer Manual 2005

HitTest Method · 65

_btnDelete.Enabled = _designer.ClipboardHandler.CanCut; _btnPaste.Enabled = _designer.ClipboardHandler.CanPaste; }

• Delphi

// update UI (_menus, toolbars, etc.) procedure Class1.UpdateUI; begin _btnUndo.Enabled := _designer.UndoStack.CanUndo; _btnRedo.Enabled := _designer.UndoStack.CanRedo; _btnPaste.Enabled := _designer.ClipboardHandler.CanPaste; _btnCut.Enabled := _designer.ClipboardHandler.CanCut; _btnCopy.Enabled := _btnCut.Enabled; _btnDelete.Enabled := _btnCut.Enabled; end;

See Also

C1ReportDesigner Control (page 43)

C1ReportDesigner Methods

HitTest Method Gets a HitTestInfo object that describes the contents of the control at a given position on the screen.

Syntax

[VB]

Public Function HitTest(x As Integer, y As Integer) As HitTestInfo

[C#]

public HitTestInfo HitTest ( int x , int y )

[Delphi]

function HitTest(x: Integer; y: Integer): HitTestInfo;

Remarks

The HitTestInfo object is documented below. It allows you to determine whether a given point (e.g. mouse position) is over a report element (field/section) or other parts of the designer (rulers, section headers, empty area, resizing edges, etc.).

Example

The code below shows how the C1ReportDesigner application uses the HitTest method to handle right-clicks on the report designer. The code checks to see if the click was on a field, and changes the selection and context menu accordingly:

• Visual Basic

' handle context-sensitive designer menu Private Sub _designerMenu_Popup(ByVal sender As Object, ByVal e As System.EventArgs) ' make sure the designer has the focus _designer.Focus() ' get field under the mouse Dim pt As Point = _designer.PointToClient(Control.MousePosition) Dim hti As HitTestInfo = _designer.HitTest(pt.X,pt.Y)

Page 70: c 1 Report Designer Manual 2005

66 · Object Reference

Dim f As Field = hti.Field ' no field there? clear selection If f Is Nothing Then _designer.SelectedFields = Nothing End If ' field not in selection? then select it If Not f Is Nothing Then Dim selected As Boolean = False Dim sf As Field For Each sf In _designer.SelectedFields If sf <> f Then continue End If selected = True Exit For Next If Not selected Then f End If End If ' show cut/copy/delete only when a field was clicked _menuCopyField.Visible = _menuCutField.Visible = _menuDeleteField.Visible = (f <> Nothing) End Sub

• C#

// handle context-sensitive designer menu private void _designerMenu_Popup(object sender, System.EventArgs e) { // make sure the designer has the focus _designer.Focus(); // get field under the mouse Point pt = _designer.PointToClient(Control.MousePosition); HitTestInfo hti = _designer.HitTest(pt.X, pt.Y); Field f = hti.Field; // no field there? clear selection if (f == null) _designer.SelectedFields = null; // field not in selection? then select it if (f != null) { bool selected = false; foreach (Field sf in _designer.SelectedFields) { if (sf != f) continue; selected = true; break; } if (!selected) _designer.SelectedFields = new Field[] { f }; } // show cut/copy/delete only when a field was clicked _menuCopyField.Visible =

Page 71: c 1 Report Designer Manual 2005

HitTest Method · 67

_menuCutField.Visible = _menuDeleteField.Visible = (f != null); }

• Delphi

// handle context-sensitive designer menu procedure _designerMenu_Popup(sender: System.Object; e: System.EventArgs); var pt: Point; hti: HitTestInfo; f: Field; selected: Boolean; sf: Field; i: Integer; flds: array of field; begin // make sure the designer has the focus _designer.Focus; // get field under the mouse pt := _designer.PointToClient(Control.MousePosition); hti := _designer.HitTest(pt.X,pt.Y); f := hti.Field; // no field there? clear selection if f = nil then begin _designer.SelectedFields := nil; end else begin // field not in selection? then select it selected := False; for i := 0 to _designer.SelectedFields.Count - 1 do begin sf := _designer.SelectedFields[i]; if (sf <> f) then continue; selected := true; break; end; if not selected then begin SetLength(flds, 1); flds[0] := f; _designer.SelectedFields := flds; end; end; // show cut/copy/delete only when a field was clicked _menuCopyField.Visible := f <> nil; _menuCutField.Visible := f <> nil; _menuDeleteField.Visible := f <> nil; end;

See Also

C1ReportDesigner Control (page 43)

Page 72: c 1 Report Designer Manual 2005

68 · Object Reference

Refresh Method Repaints the designer and adjusts report and section dimensions to fit fields.

Syntax

[VB]

Public Sub Refresh()

[C#]

public void Refresh ( )

[Delphi]

procedure Refresh;

Remarks

Use this method when you change field properties, create new fields or change report/section dimensions outside the designer, to ensure that the report and sections are wide enough to accommodate the new fields.

Example

The example below shows the event handler for the PropertyGrid control that is bound to the designer selection. When the user changes a field, section, or report property using the designer, the application calls the Refresh method so the changes will be visible in the designer.

• Visual Basic

' property value changed, update designer Private Sub _propGrid_PropertyValueChanged(s As Object, e As PropertyValueChangedEventArgs) ' show changes in the designer _designer.Refresh() ' remember the document is dirty If Not _dirty Then _dirty = True UpdateUI() End If End Sub '_propGrid_PropertyValueChanged

• C#

// property value changed, update designer private void _propGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { // show changes in the designer _designer.Refresh(); // remember the document is dirty if (!_dirty) { _dirty = true; UpdateUI(); } }

Page 73: c 1 Report Designer Manual 2005

ToPixelsX Method · 69

• Delphi

// property value changed, update designer procedure Class1._propGrid_PropertyValueChanged(s: System.Object; e: PropertyValueChangedEventArgs); begin // show changes in the designer _designer.Refresh; // remember the document is dirty if (not _dirty) begin _dirty := true; UpdateUI; end; end;

See Also

C1ReportDesigner Control (page 43)

ToPixelsX Method Convert pixels to twips.

Syntax

[VB]

Public Function ToPixelsX(twip As Double) As Integer

[C#]

public int ToPixelsX (Double twip )

[Delphi]

function ToPixelsX(twip: Double): Integer;

Remarks

These methods are useful to translate mouse/screen coordinates (expressed in pixels) into report coordinates (expressed in twips).

See Also

C1ReportDesigner Control (page 43)

ToPixelsY Method Convert pixels to twips.

Syntax

[VB]

Public Function ToPixelsY(twip As Double) As Integer

[C#]

public int ToPixelsY (Double twip )

[Delphi]

function ToPixelsY(twip: Double): Integer;

Page 74: c 1 Report Designer Manual 2005

70 · Object Reference

Remarks

These methods are useful to translate mouse/screen coordinates (expressed in pixels) into report coordinates (expressed in twips).

See Also

C1ReportDesigner Control (page 43)

ToTwipsX Method Convert twips to pixels.

Syntax

[VB]

Public Function ToTwipsX(pixels As Integer) As Double

[C#]

public Double ToTwipsX ( int pixels )

[Delphi]

function ToTwipsX(pixels: Integer): Double;

Remarks

These methods are useful to translate report coordinates (expressed in twips) into mouse/screen coordinates (expressed in pixels).

See Also

C1ReportDesigner Control (page 43)

ToTwipsY Method Convert twips to pixels.

Syntax

[VB]

Public Function ToTwipsY(pixels As Integer) As Double

[C#]

public Double ToTwipsY ( int pixels )

[Delphi]

function ToTwipsY(pixels: Integer): Double;

Remarks

These methods are useful to translate report coordinates (expressed in twips) into mouse/screen coordinates (expressed in pixels).

See Also

C1ReportDesigner Control (page 43)

Page 75: c 1 Report Designer Manual 2005

CreateField Event · 71

C1ReportDesigner Events

CreateField Event Fired when the user marks the location of a new field using the mouse, after the CreateFieldInfo property was set to a non-null value.

Syntax

[VB]

Public Event CreateField(sender As Object, e As CreateFieldEventArgs) As CreateFieldEventHandler

[C#]

public event CreateFieldEventHandler CreateField

[Delphi]

property CreateField: CreateFieldEventHandler;

Remarks

Note: This event tells the handler that the user wants to create a field, and the parameters describe the new field's section and position. It is up to the event handler to actually create the new field and initialize its properties.

For an example, see the CreateFieldInfo property.

See Also

C1ReportDesigner Control (page 43)

CreateFieldInfo Property (page 49)

DeleteField Event Fired before the user deletes the selected fields.

Syntax

[VB]

Public Event DeleteField(sender As Object, e As DeleteFieldEventArgs) As DeleteFieldEventHandler

[C#]

public event DeleteFieldEventHandler DeleteField

[Delphi]

property DeleteField: DeleteFieldEventHandler;

Remarks

The event handler can examine the current selection and determine whether the user is allowed to delete the fields.

See Also

C1ReportDesigner Control (page 43)

Page 76: c 1 Report Designer Manual 2005

72 · Object Reference

MoveCopyFields Event Fired before the user moves or copies fields with the mouse.

Syntax

[VB]

Public Event MoveCopyFields(sender As Object, e As MoveCopyFieldsEventArgs) As MoveCopyFieldsEventHandler

[C#]

public event MoveCopyFieldsEventHandler MoveCopyFields

[Delphi]

property MoveCopyFields: MoveCopyFieldsEventHandler;

Remarks

The event handler can examine the current selection and determine whether the user is allowed to move and/or copy the fields.

See Also

C1ReportDesigner Control (page 43)

RenderField Event Fired before a field is rendered by the designer.

Syntax

[VB]

Public Event RenderField(sender As Object, e As RenderFieldEventArgs) As RenderFieldEventHandler

[C#]

public event RenderFieldEventHandler RenderField

[Delphi]

property RenderField: RenderFieldEventHandler;

Remarks

The event handler can change the text that is displayed by the designer (the designer shows the field's Text property by default).

See Also

C1ReportDesigner Control (page 43)

Page 77: c 1 Report Designer Manual 2005

RenderSectionHeader Event · 73

RenderSectionHeader Event Fired before a section header is rendered by the designer.

Syntax

[VB]

Public Event RenderSectionHeader(sender As Object, e As RenderSectionHeaderEventArgs) As RenderSectionHeaderEventHandler

[C#]

public event RenderSectionHeaderEventHandler RenderSectionHeader

[Delphi]

property RenderSectionHeader: RenderSectionHeaderEventHandler;

Remarks

The event handler can change the text displayed for the section and group information.

See Also

C1ReportDesigner Control (page 43)

ReportChanged Event Fired when a new report is assigned to the control (see the Report property).

Syntax

[VB]

Public Event ReportChanged(sender As Object, e As EventArgs) As EventHandler

[C#]

public event EventHandler ReportChanged

[Delphi]

property ReportChanged: EventHandler;

See Also

C1ReportDesigner Control (page 43)

ResizeFieldSection Event Fired before the user resizes fields, sections (height), or the report (width) with the mouse.

Syntax

[VB]

Public Event ResizeFieldSection(sender As Object, e As ResizeFieldSectionEventArgs) ResizeFieldSectionEventHandler

[C#]

public event ResizeFieldSectionEventHandler ResizeFieldSection

Page 78: c 1 Report Designer Manual 2005

74 · Object Reference

[Delphi]

property ResizeFieldSection: ResizeFieldSectionEventHandler;

See Also

C1ReportDesigner Control (page 43)

SelectionChanged Event Fired when fields are selected or de-selected.

Syntax

[VB]

Public Event SelectionChanged(sender As Object, e As EventArgs) As EventHandler

[C#]

public event EventHandler SelectionChanged

[Delphi]

property SelectionChanged: EventHandler;

Remarks

This event is mainly used to refresh the PropertyGrid controls attached to the selection.

For an example, see the SelectedFields property.

See Also

C1ReportDesigner Control (page 43)

ValuesChanged Event Fired when the report changes (e.g. fields are moved/resized or copied with the mouse).

Syntax

[VB]

Public Event ValuesChanged(sender As Object, e As EventArgs) As EventHandler

[C#]

public event EventHandler ValuesChanged

[Delphi]

property ValuesChanged: EventHandler;

Example

The code below shows how a typical application would handle the ValuesChanged event to refresh the property grid (so it displays the new values) and to mark the current report definition document as dirty (to indicate the document has changed and needs to be saved).

• Visual Basic

Private Sub _designer_ValuesChanged(sender As Object, e As System.EventArgs) _dirty = True _propGrid.Refresh()

Page 79: c 1 Report Designer Manual 2005

CreateFieldEventArgs class · 75

_designer.CreateFieldInfo = Nothing UpdateUI() End Sub '_designer_ValuesChanged

• C#

private void _designer_ValuesChanged(object sender, System.EventArgs e) { _dirty = true; _propGrid.Refresh(); _designer.CreateFieldInfo = null; UpdateUI(); }

• Delphi

procedure Class1._designer_ValuesChanged(sender: System.Object; e: System.EventArgs); begin _dirty := True; _propGrid.Refresh; _designer.CreateFieldInfo := nil; UpdateUI; end;

See Also

C1ReportDesigner Control (page 43)

C1ReportDesigner Event Arguments

CreateFieldEventArgs class Syntax

[VB]

Public Class CreateFieldEventArgs

[C#]

public class CreateFieldEventArgs : EventArgs

[Delphi]

type CreateFieldEventArgs: class(EventArgs);

Members

public readonly Section Section Section where the new field should be created.

public readonly Rectangle ClientBounds Rectangle where the new field should be created, in client coordinates (pixels).

public readonly Rectangle FieldBounds Rectangle where the new field should be created, in report coordinates (twips).

public readonly object CreateFieldInfo Object set by the caller with additional information about the new field (same as CreateFieldInfo property).

Page 80: c 1 Report Designer Manual 2005

76 · Object Reference

DeleteFieldEventArgs class Syntax

[VB]

Public Class DeleteFieldEventArgs

[C#]

public class DeleteFieldEventArgs : EventArgs

[Delphi]

type DeleteFieldEventArgs: class(EventArgs);

Members

public bool Cancel Set to true to cancel the operation.

MoveCopyFieldEventArgs class Syntax

[VB]

Public Class MoveCopyFieldsEventArgs

[C#]

public class MoveCopyFieldsEventArgs : EventArgs

[Delphi]

type MoveCopyFieldsEventArgs: class(EventArgs);

Members

public bool AllowMove Set to false to prevent the user from moving the field.

public bool AllowCopy Set to false to prevent the user from copying the field.

ResizeFieldSectionEventArgs class Syntax

[VB]

Public Class ResizeFieldSectionEventArgs

[C#]

public class ResizeFieldSectionEventArgs : EventArgs

[Delphi]

type ResizeFieldSectionEventArgs: class(EventArgs);

Page 81: c 1 Report Designer Manual 2005

ClipboardHandler Class · 77

Members

public readonly HitTestInfo HitTestInfo HitTestInfo object containing information about the field or section being resized.

public bool Cancel Set to true to cancel the operation.

ClipboardHandler Class The ClipboardHandler object provides clipboard support for the C1ReportDesigner control. It manages copying and pasting report fields to and from the clipboard.

Example

The example below shows how you can use the ClipboardHandler class to provide clipboard commands in your report designer application:

• Visual Basic

' handle clipboard commands (for reports and fields) Private Sub HandleClipboard(ByVal cmd As ToolBarButton) ' save undo state for all but copy If cmd <> _btnCopy Then _designer.UndoStack.SaveState() _dirty = True End If ' execute command Dim clip As ClipboardHandler = _designer.ClipboardHandler If cmd = _btnCut Then clip.Cut() End If If cmd = _btnCopy Then clip.Copy() End If If cmd = _btnPaste Then clip.Paste() End If If cmd = _btnDelete Then clip.Delete() End If ' update UI when done UpdateUI() End Sub ' update UI (_menus, toolbars, etc.) Private Sub UpdateUI() _btnUndo.Enabled = _designer.UndoStack.CanUndo _btnRedo.Enabled = _designer.UndoStack.CanRedo _btnCut.Enabled = _btnCopy.Enabled = _btnDelete.Enabled = _designer.ClipboardHandler.CanCut _btnPaste.Enabled = _designer.ClipboardHandler.CanPaste End Sub

• C#

// handle clipboard commands (for reports and fields) private void HandleClipboard(ToolBarButton cmd) {

Page 82: c 1 Report Designer Manual 2005

78 · Object Reference

// save undo state for all but copy if (cmd != _btnCopy) { _designer.UndoStack.SaveState(); _dirty = true; } // execute command ClipboardHandler clip = _designer.ClipboardHandler; if (cmd == _btnCut) clip.Cut(); if (cmd == _btnCopy) clip.Copy(); if (cmd == _btnPaste) clip.Paste(); if (cmd == _btnDelete) clip.Delete(); // update UI when done UpdateUI(); } // update UI (_menus, toolbars, etc.) private void UpdateUI() { _btnUndo.Enabled = _designer.UndoStack.CanUndo; _btnRedo.Enabled = _designer.UndoStack.CanRedo; _btnCut.Enabled = _btnCopy.Enabled = _btnDelete.Enabled = _designer.ClipboardHandler.CanCut; _btnPaste.Enabled = _designer.ClipboardHandler.CanPaste; }

• Delphi

// handle clipboard commands (for reports and fields) procedure Class1.HandleClipboard(cmd: ToolBarButton); var clip: ClipboardHandler; begin // save undo state for all but copy if (cmd <> _btnCopy) then begin _designer.UndoStack.SaveState; _dirty := True; end; // execute command clip := _designer.ClipboardHandler; if (cmd = _btnCut) then clip.Cut; if (cmd = _btnCopy) then clip.Copy; if (cmd = _btnPaste) then clip.Paste; if (cmd = _btnDelete) then clip.Delete; // update UI when done UpdateUI; end; // update UI (_menus, toolbars, etc.) procedure Class1.UpdateUI; begin _btnUndo.Enabled := _designer.UndoStack.CanUndo; _btnRedo.Enabled := _designer.UndoStack.CanRedo;

Page 83: c 1 Report Designer Manual 2005

CanCut Property · 79

_btnPaste.Enabled := _designer.ClipboardHandler.CanPaste; _btnCut.Enabled := _btnPaste.Enabled; _btnCopy.Enabled := _btnPaste.Enabled; end;

ClipboardHandler Members ClipboardHandler Public Properties

CanCut Determines whether the current selection can be cut/copied to the clipboard (returns true if there is at least one field selected).

CanPaste Determines whether the clipboard contains data that can be pasted into the report.

ClipboardHandler Public Instance Methods

Copy Copies the current selection to the clipboard.

Cut Cuts the current selection to the clipboard, removing all selected fields from the report.

Delete Removes all selected fields from the report.

Paste Copies a collection of fields from the clipboard to the report, adding them to the current section.

ClipboardHandler Properties

CanCut Property Determines whether the current selection can be cut/copied to the clipboard (returns true if there is at least one field selected).

Syntax

[VB]

Public Property CanCut As Boolean

[C#]

public bool CanCut {get;}

[Delphi]

property CanCut: Boolean;

Remarks

This property is useful for enabling or disabling clipboard buttons and menus on the application.

See Also

ClipboardHandler Class (page 77)

Page 84: c 1 Report Designer Manual 2005

80 · Object Reference

CanPaste Property Determines whether the clipboard contains data that can be pasted into the report.

Syntax

[VB]

Public Property CanPaste As Boolean

[C#]

public bool CanPaste {get;}

[Delphi]

property CanPaste: Boolean;

Remarks

This property is useful for enabling or disabling clipboard buttons and menus on the application.

See Also

ClipboardHandler Class (page 77)

ClipboardHandler Methods

Copy Method Copies the current selection to the clipboard.

Syntax

[VB]

Public Function Copy() As Boolean

[C#]

public bool Copy ( )

[Delphi]

function Copy: Boolean;

See Also

ClipboardHandler Class (page 77)

Cut Method Cuts the current selection to the clipboard, removing all selected fields from the report.

Syntax

[VB]

Public Function Cut() As Boolean

[C#]

public bool Cut ( )

Page 85: c 1 Report Designer Manual 2005

Delete Method · 81

[Delphi]

function Cut: Boolean;

See Also

ClipboardHandler Class (page 77)

Delete Method Removes all selected fields from the report.

Syntax

[VB]

Public Function Delete() As Boolean

[C#]

public bool Delete ( )

[Delphi]

function Delete: Boolean;

See Also

ClipboardHandler Class (page 77)

Paste Method Copies a collection of fields from the clipboard to the report, adding them to the current section.

Syntax

[VB]

Public Function Paste() As Boolean

[C#]

public bool Paste ( )

[Delphi]

function Paste: Boolean;

See Also

ClipboardHandler Class (page 77)

UndoStack Class The UndoStack object provides undo/redo services for the C1ReportDesigner control. It has methods that allow you to save and restore the state of the report being edited.

UndoStack Members

UndoStack Public Properties

CanRedo Returns true if the redo stack is not empty.

Page 86: c 1 Report Designer Manual 2005

82 · Object Reference

CanUndo Returns true if the undo stack is not empty.

Enabled Gets or sets whether the designer should save the state of the report before applying any changes (e.g., when the user moves a field with the mouse).

UndoStack Public Instance Methods

Clear Clears the undo/redo stack.

Redo Redo changes, canceling the last undo operation.

SaveState Save the current report state into the undo stack.

Undo Undo changes and restore the report to the last saved state.

UndoStack Properties

CanRedo Property Returns true if the redo stack is not empty.

Syntax

[VB]

Public Property CanRedo As Boolean

[C#]

public bool CanRedo {get;}

[Delphi]

property CanRedo: Boolean;

See Also

UndoStack Class (page 81)

CanUndo Property Returns true if the undo stack is not empty.

Syntax

[VB]

Public Property CanUndo As Boolean

[C#]

public bool CanUndo {get;}

[Delphi]

property CanUndo: Boolean;

See Also

UndoStack Class (page 81)

Page 87: c 1 Report Designer Manual 2005

Enabled Property · 83

Enabled Property Gets or sets whether the designer should save the state of the report before applying any changes (e.g., when the user moves a field with the mouse).

Syntax

[VB]

Public Property Enabled As Boolean

[C#]

public bool Enabled {get; set;}

[Delphi]

property Enabled: Boolean;

Remarks

Note: The UndoStack is enabled by default, because it provides a valuable service to users. However, if you choose not to expose its functionality (with undo/redo buttons in your app), then you should disable the UndoStack to improve efficiency.

Example

• Visual Basic

_designer.UndoStack.Enabled = True ' << more functionality, less speed _designer.UndoStack.Enabled = False ' << no undo/redo, more speed

• C#

_designer.UndoStack.Enabled = true; // << more functionality, less speed _designer.UndoStack.Enabled = false; // << no undo/redo, more speed

• Delphi

_designer.UndoStack.Enabled := True; // << more functionality, less speed _designer.UndoStack.Enabled := False; // << no undo/redo, more speed

See Also

UndoStack Class (page 81)

UndoStack Methods

Clear Method Clears the undo/redo stack.

Syntax

[VB]

Public Sub Clear()

[C#]

public void Clear ( )

Page 88: c 1 Report Designer Manual 2005

84 · Object Reference

[Delphi]

procedure Clear;

See Also

UndoStack Class (page 81)

Redo Method Redo changes, canceling the last undo operation.

Syntax

[VB]

Public Function Redo() As Boolean

[C#]

public bool Redo ( )

[Delphi]

function Redo: Boolean;

See Also

UndoStack Class (page 81)

SaveState Method Save the current report state into the undo stack.

Syntax

[VB]

Public Function SaveState() As Boolean

[C#]

public bool SaveState ( )

[Delphi]

function SaveState: Boolean;

Remarks

The designer calls this method automatically before it changes the report in any way. If your code changes the report, you should also call this method before making the changes so they can be undone.

See Also

UndoStack Class (page 81)

Page 89: c 1 Report Designer Manual 2005

Undo Method · 85

Undo Method Undo changes and restore the report to the last saved state.

Syntax

[VB]

Public Function Undo() As Boolean

[C#]

public bool Undo ( )

[Delphi]

function Undo: Boolean;

See Also

UndoStack Class (page 81)

Grid Class The Grid object controls the appearance and behavior of the design grid.

Grid Members

Grid Public Properties

ColorMajor Gets or sets the color of the major grid lines.

ColorMinor Gets or sets the color of the minor grid lines.

PixelsPerTick Gets the number of pixels between grid tick marks.

Snap Gets or sets whether mouse editing actions should snap to grid coordinates.

Units Gets or sets the grid units (metric, English, or automatic).

Visible Gets or sets whether the grid is visible.

Grid Properties

ColorMajor Property Gets or sets the color of the major grid lines.

Syntax

[VB]

Public Property ColorMajor As Color

[C#]

public Color ColorMajor {get; set;}

[Delphi]

property ColorMajor: Color;

Page 90: c 1 Report Designer Manual 2005

86 · Object Reference

See Also

Grid Class (page 85)

ColorMinor Property Gets or sets the color of the minor grid lines.

Syntax

[VB]

Public Property ColorMinor As Color

[C#]

public Color ColorMinor {get; set;}

[Delphi]

property ColorMinor: Color;

See Also

Grid Class (page 85)

PixelsPerTick Property Gets the number of pixels between grid tick marks.

Syntax

[VB]

Public Property PixelsPerTick As Point

[C#]

public Point PixelsPerTick {get;}

[Delphi]

property PixelsPerTick: Point;

See Also

Grid Class (page 85)

Snap Property Gets or sets whether mouse editing actions should snap to grid coordinates.

Syntax

[VB]

Public Property Snap As Boolean

[C#]

public bool Snap {get; set;}

Page 91: c 1 Report Designer Manual 2005

Units Property · 87

[Delphi]

property Snap: Boolean;

See Also

Grid Class (page 85)

Units Property Gets or sets the grid units (metric, English, or automatic).

Syntax

[VB]

Public Property Units As GridUnitsEnum

[C#]

public GridUnitsEnum Units {get; set;}

[Delphi]

property Units: GridUnitsEnum;

Remarks

Possible values are members of the HitHandleFlags enumeration:

Member Name Description

Auto Automatically sets the units.

English English units of measurement

Metric Metric units of measurement

See Also

Grid Class (page 85)

Visible Property Gets or sets whether the grid is visible.

Syntax

[VB]

Public Property Visible As Boolean

[C#]

public bool Visible {get; set;}

[Delphi]

property Visible: Boolean;

Page 92: c 1 Report Designer Manual 2005

88 · Object Reference

See Also

Grid Class (page 85)

Ruler Class The Ruler object controls the appearance of the rulers along the top and left-hand side of the C1ReportDesigner control.

Ruler Members

Ruler Public Properties

AllowSelection Specifies whether the ruler can be used for field selection.

BackColor Gets or sets the background color of the ruler over the printable area of the page.

BackColorEmpty Gets or sets the background color of the ruler outside the printable area of the page.

BorderStyle Gets or sets the style of the border drawn around the ruler.

Font Gets or sets the font used to paint values on the ruler.

ForeColor Gets or sets the color used to paint the tick marks and values on the ruler.

Highlight Gets or sets the color used to highlight the ruler during selection.

Visible Specifies whether the ruler should be displayed.

Ruler Properties

AllowSelection Property Specifies whether the ruler can be used for field selection.

Syntax

[VB]

Public Property AllowSelection As Boolean

[C#]

public bool AllowSelection {get; set;}

[Delphi]

property AllowSelection: Boolean;

Remarks

When this property is set to true, the user can select fields by clicking and dragging the mouse over the rulers (horizontal or vertical). While dragging the mouse, the ruler will display a selection band. When the mouse is released, any controls that touch or lie within the selection band will be selected.

Page 93: c 1 Report Designer Manual 2005

BackColor Property · 89

See Also

Ruler Class (page 88)

BackColor Property Gets or sets the background color of the ruler over the printable area of the page.

Syntax

[VB]

Public Property BackColor As Color

[C#]

public Color BackColor {get; set;}

[Delphi]

property BackColor: Color;

See Also

Ruler Class (page 88)

BackColorEmpty Property Gets or sets the background color of the ruler outside the printable area of the page.

Syntax

[VB]

Public Property BackColorEmpty As Color

[C#]

public Color BackColorEmpty {get; set;}

[Delphi]

property BackColorEmpty: Color;

See Also

Ruler Class (page 88)

BorderStyle Property Gets or sets the style of the border drawn around the ruler.

Syntax

[VB]

Public Property BorderStyle As Border3DStyle

[C#]

public Border3DStyle BorderStyle {get; set;}

Page 94: c 1 Report Designer Manual 2005

90 · Object Reference

[Delphi]

property BorderStyle: Border3DStyle;

See Also

Ruler Class (page 88)

Font Property (Ruler) Gets or sets the font used to paint values on the ruler.

Syntax

[VB]

Public Property Font As Font

[C#]

public Font Font {get; set;}

[Delphi]

property Font: Font;

See Also

Ruler Class (page 88)

ForeColor Property Gets or sets the color used to paint the tick marks and values on the ruler.

Syntax

[VB]

Public Property ForeColor As Color

[C#]

public Color ForeColor {get; set;}

[Delphi]

property ForeColor: Color;

See Also

Ruler Class (page 88)

Highlight Property Gets or sets the color used to highlight the ruler during selection.

Syntax

[VB]

Public Property Highlight As Color

[C#]

public Color Highlight {get; set;}

Page 95: c 1 Report Designer Manual 2005

Visible Property · 91

[Delphi]

property Highlight: Color;

Remarks

This property is relevant only if the AllowSelection property is set to True.

See Also

Ruler Class (page 88)

Visible Property Specifies whether the ruler should be displayed.

Syntax

[VB]

Public Property Visible As ShowRulerFlags

[C#]

public ShowRulerFlags Visible {get; set;}

[Delphi]

property Visible: ShowRulerFlags;

Remarks

Possible values are members of the ShowRulerFlags enumeration:

Member Name Description

Both Both the vertical and horizontal rulers are displayed.

Horizontal The horizontal ruler is displayed.

None No rulers are displayed.

Vertical The vertical ruler is displayed.

See Also

Ruler Class (page 88)

HitTestInfo Structure HitTestInfo Members

HitTestInfo Public Properties

Code Gets a code that determines the type of element at the given point.

Field Gets the field at the given point (or null if there is no field there).

Page 96: c 1 Report Designer Manual 2005

92 · Object Reference

HitHandleFlags Gets a set of flags that determines whether the point is on a field resizing handle (a field has eight handles, one at each corner and one along each edge).

Section Gets the section at the given point (or null if the point is outside the design area).

X Get the client coordinates of the point.

Y Get the client coordinates of the point.

HitTestInfo Properties

Code Property Gets a code that determines the type of element at the given point.

Syntax

[VB]

Public Property Code As HitCodeEnum

[C#]

public HitCodeEnum Code {get;}

[Delphi]

property Code: HitCodeEnum;

Remarks

Possible values are members of the HitCodeEnum enumeration:

Member Name Description

EdgeBottom The bottom edge of the report

EdgeRight The right edge of the report

Empty The empty design area to the right and below the report.

Field The specified field

Nowhere The upper left corner of the control.

RulerHorz The horizontal ruler

RulerVert The vertical ruler

Section The specified section

SectionBox The section box

SectionHdr The section header

SortBox The sort box

See Also

HitTestInfo Structure (page 91)

Page 97: c 1 Report Designer Manual 2005

Field Property · 93

Field Property Gets the field at the given point (or null if there is no field there).

Syntax

[VB]

Public Property Field As Field

[C#]

public Field Field {get;}

[Delphi]

property Field: Field;

See Also

HitTestInfo Structure (page 91)

HitHandleFlags Property Gets a set of flags that determines whether the point is on a field resizing handle (a field has eight handles, one at each corner and one along each edge).

Syntax

[VB]

Public Property HitHandleFlags As HitHandleFlags

[C#]

public HitHandleFlags HitHandleFlags {get;}

[Delphi]

property HitHandleFlags: HitHandleFlags;

Remarks

Possible values are members of the HitHandleFlags enumeration:

Member Name Description

Bottom The bottom edge of the field.

Center The center of the horizontal edge.

CenterV The center of the vertical edge.

Horz Any horizontal flag (Left | Center | Right)

Left The left edge of the field.

None The center of the field.

Right The right edge of the field.

Top The top edge of the field.

Vert Any vertical flag (Top | CenterV | Bottom)

Page 98: c 1 Report Designer Manual 2005

94 · Object Reference

See Also

HitTestInfo Structure (page 91)

Section Property Gets the section at the given point (or null if the point is outside the design area).

Syntax

[VB]

Public Property Section As Section

[C#]

public Section Section {get;}

[Delphi]

property Section: Section;

See Also

HitTestInfo Structure (page 91)

X Property Get the client coordinates of the point.

Syntax

[VB]

Public Property X As Integer

[C#]

public int X {get;}

[Delphi]

property X: Integer;

See Also

HitTestInfo Structure (page 91)

Y Property Get the client coordinates of the point.

Syntax

[VB]

Public Property Y As Integer

[C#]

public int Y {get;}

Page 99: c 1 Report Designer Manual 2005

AutoAdjustEnum Enumeration · 95

[Delphi]

property Y: Integer;

See Also

HitTestInfo Structure (page 91)

Enumerations AutoAdjustEnum Enumeration

Syntax

[VB]

Public enum AutoAdjustEnum

[C#]

public sealed enum AutoAdjustEnum : Enum

[Delphi]

type AutoAdjustEnum = (Both, None, ReportWidth, SectionHeight);

Remarks

Use the members of this enumeration to set the value of the AutoAdjustReportDimensions property in the C1ReportDesigner control.

Member Name Description

Both Adjusts the height and width of the report.

None No adjustments

ReportWidth Adjusts the width of the report.

SectionHeight Adjusts the height of the specified section.

GridUnitsEnum Enumeration Syntax

[VB]

Public enum GridUnitsEnum

[C#]

public sealed enum GridUnitsEnum : Enum

[Delphi]

type GridUnitsEnum = (Auto, English, Metric);

Remarks

Use the members of this enumeration to set the value of the Units property in the Grid class.

Page 100: c 1 Report Designer Manual 2005

96 · Object Reference

Member Name Description

Auto Automatically sets the units.

English English units of measurement

Metric Metric units of measurement

HitCodeEnum Enumeration Syntax

[VB]

Public enum HitCodeEnum

[C#]

public sealed enum HitCodeEnum : Enum

[Delphi]

type HitCodeEnum = (EdgeBottom, EdgeRight, Empty, Field, Nowhere, RulerHorz, RulerVert, Section, SectionBox, SectionHdr, SortBox);

Remarks

Use the members of this enumeration to set the value of the Code property in the HitTestInfo Structure (page 91.)

Member Name Description

EdgeBottom The bottom edge of the report.

EdgeRight The right edge of the report.

Empty The empty design area to the right and below the report.

Field The specified field.

Nowhere The upper left corner of the control.

RulerHorz The horizontal ruler.

RulerVert The vertical ruler.

Section The specified section.

SectionBox The section box.

SectionHdr The section header.

SortBox The sort box.

HitHandleFlags Enumeration Syntax

[VB]

Public enum HitHandleFlags

Page 101: c 1 Report Designer Manual 2005

ShowRulerFlags Enumeration · 97

[C#]

public sealed enum HitHandleFlags : Enum

[Delphi]

type HitHandleFlags = (Bottom, Center, CenterV, Horz, Left, None, Right, Top, Vert);

Remarks

Use the members of this enumeration to set the value of the HitHandleFlags property in the HitTestInfo Structure (page 91.)

Member Name Description

Bottom The bottom edge of the field.

Center The center of the horizontal edge.

CenterV The center of the vertical edge.

Horz Any horizontal flag (Left | Center | Right)

Left The left edge of the field.

None The center of the field.

Right The right edge of the field.

Top The top edge of the field.

Vert Any vertical flag (Top | CenterV | Bottom)

ShowRulerFlags Enumeration Syntax

[VB]

Public enum ShowRulerFlags

[C#]

public sealed enum ShowRulerFlags : Enum

[Delphi]

type ShowRulerFlags = (Both, Horizontal, None, Vertical);

Remarks

Use the members of this enumeration to set the value of the Visible property in the Ruler class.

Member Name Description

Both Both the vertical and horizontal rulers are displayed.

Horizontal The horizontal ruler is displayed.

None No rulers are displayed.

Vertical The vertical ruler is displayed.

Page 102: c 1 Report Designer Manual 2005

98 · Object Reference

Event Argument classes RenderFieldEventArgs class

Syntax

[VB]

Public Class RenderFieldEventArgs

[C#]

public class RenderFieldEventArgs : EventArgs

[Delphi]

type RenderFieldEventArgs: class(EventArgs);

Members

Member Description

string Text Text as string

Field Field Field as Field

See Also

RenderFieldEventHandler delegate (page 100)

RenderSectionHeaderEventArgs class Syntax

[VB]

Public Class RenderSectionHeaderEventArgs

[C#]

public class RenderSectionHeaderEventArgs : EventArgs

[Delphi]

type RenderSectionHeaderEventArgs: class(EventArgs);

Members

Member Description

string GroupDescription GroupDescription as string

string SectionDescription SectionDescription as string

Section Section Section as Section

See Also

RenderSectionHeaderEventHandler delegate (page 101)

Page 103: c 1 Report Designer Manual 2005

CreateFieldEventHandler delegate · 99

Event Handler Delegates CreateFieldEventHandler delegate

Syntax

[VB]

Public Delegate Sub CreateFieldEventHandler (object sender, EventArgs e);

[C#]

public sealed delegate CreateFieldEventHandler : MulticastDelegate

[Delphi]

type CreateFieldEventHandler = procedure(sender: Object, e: EventArgs) of object;

Arguments

Argument Description

sender The source of the event.

e A CreateFieldEventArgs object that contains the event data.

See Also

CreateField Event (page 71)

DeleteFieldEventHandler delegate Syntax

[VB]

Public Delegate Sub DeleteFieldEventHandler (object sender, EventArgs e);

[C#]

public sealed delegate DeleteFieldEventHandler : MulticastDelegate

[Delphi]

type DeleteFieldEventHandler = procedure(sender: Object, e: EventArgs) of object;

Arguments

Argument Description

sender The source of the event.

e A DeleteFieldEventArgs object that contains the event data.

See Also

DeleteField Event (page 71)

Page 104: c 1 Report Designer Manual 2005

100 · Object Reference

MoveCopyFieldsEventHandler delegate Syntax

[VB]

Public Delegate Sub MoveCopyFieldsEventHandler (object sender, MoveCopyFieldsEventArgs e);

[C#]

public sealed delegate MoveCopyFieldsEventHandler : MulticastDelegate

[Delphi]

type MoveCopyFieldsEventHandler = procedure(sender: Object, e: MoveCopyFieldsEventArgs) of object;

Arguments

Argument Description

sender The source of the event.

e A MoveCopyFieldsEventArgs object that contains the event data.

See Also

MoveCopyFields Event (page 72)

RenderFieldEventHandler delegate Syntax

[VB]

Public Delegate Sub RenderFieldEventHandler (object sender, RenderFieldEventArgs e);

[C#]

public sealed delegate RenderFieldEventHandler : MulticastDelegate

[Delphi]

type RenderFieldEventHandler = procedure(sender: Object, e: RenderFieldEventArgs) of object;

Arguments

Argument Description

sender The source of the event.

e A RenderFieldEventArgs object that contains the event data.

See Also

RenderField Event (page 72)

Page 105: c 1 Report Designer Manual 2005

RenderSectionHeaderEventHandler delegate · 101

RenderSectionHeaderEventHandler delegate Syntax

[VB]

Public Delegate Sub RenderSectionHeaderEventHandler (object sender, RenderSectionHeaderEventArgs e);

[C#]

public sealed delegate RenderSectionHeaderEventHandler : MulticastDelegate

[Delphi]

type RenderSectionHeaderEventHandler = procedure(sender: Object, e: RenderSectionHeaderEventArgs) of object;

Arguments

Argument Description

sender The source of the event.

e A RenderSectionHeaderEventArgs object that contains the event data.

See Also

RenderField Event (page 72)

ResizeFieldSectionEventHandler delegate Syntax

[VB]

Public Delegate Sub ResizeFieldSectionEventHandler (object sender, ResizeFieldSectionEventArgs e);

[C#]

public sealed delegate ResizeFieldSectionEventHandler : MulticastDelegate

[Delphi]

type ResizeFieldSectionEventHandler = procedure(sender: Object, e: ResizeFieldSectionEventArgs) of object;

Arguments

Argument Description

sender The source of the event.

e A ResizeFieldSectionEventArgs object that contains the event data.

See Also

ResizeFieldSection Event (page 73)

Page 106: c 1 Report Designer Manual 2005
Page 107: c 1 Report Designer Manual 2005

Index · 103

Index A AllowInPlaceEditing property 45 AllowSelection property 88 AutoAdjustEnum Enumeration 95 AutoAdjustReportDimensions property 45 AutoScroll property 46

B BackColor property 46, 89 BackColorEmpty property 47, 89 BackColorSection property 47 BorderStyle property 89 BorderStyleSection property 47

C CanCut property 79 CanPaste property 80 CanRedo property 82 CanUndo property 82 Clear method 83 ClipboardHandler property 48 Code property 92 ColorFieldEdge property 49 ColorMajor property 85 ColorMinor property 86 ColorReportEdge property 48 Copy method 80 CreateField event 71 CreateFieldEventArgs class 75 CreateFieldEventHandler delegate 99 CreateFieldInfo property 49 Creating components at design time 9 Creating components at run time 9 Cursor property 52 Cut method 80

D Delete method 81 DeleteField event 71 DeleteFieldEventArgs class 76 DeleteFieldEventHandler delegate 99

E Enabled property 83 Events

arguments 75

C1Report 71 handler delegates 99, 100, 101

F Field property 93 Font property 90

of Ruler 90 ForeColor property 52, 90 ForeColorGroup property 53 ForeColorSection property 53

G Grid property 54 GridUnitsEnum Enumeration 95

H Highlight property 90 HitCodeEnum Enumeration 96 HitHandleFlags Enumeration 96 HitHandleFlags property 93 HitTest method 65

I I downloaded a new build of a component that I have

purchased, and now I'm getting the splash screen when I build my projects. 11

I have a licensed version of a ComponentOne product but I still get the splash screen when I run my project. 11

I have a licensed version of a ComponentOne product on my web server but the components still behave as unlicensed. 11

Inheriting from licensed components 9

L Locked property 54

M MoveCopyFieldEventArgs class 76 MoveCopyFields event 72 MoveCopyFieldsEventHandler delegate 100

P Paste method 81 PixelsPerTick property 86

Page 108: c 1 Report Designer Manual 2005

104 · Index

R Redo method 84 Refresh method 68 RenderField event 72 RenderFieldEventArgs class 98 RenderFieldEventHandler delegate 100 RenderSectionHeader event 73 RenderSectionHeaderEventArgs class 98 RenderSectionHeaderEventHandler delegate 101 Report property 54 ReportChanged event 73 ResizeFieldSection event 73 ResizeFieldSectionEventArgs class 76 ResizeFieldSectionEventHandler delegate 101 Ruler property 56

S SaveState method 84 Section property 94 SelectedFields property 57 SelectedSection property 62 SelectionChanged event 74 ShowRulerFlags Enumeration 97 Snap property 86

T ToPixelsX method 69 ToPixelsY method 69 ToTwipsX method 70 ToTwipsY method 70

U Undo method 85 UndoStack property 62 Units property 87 Using licensed components in console applications 10 Using licensed components in Visual C++ applications 10

V ValuesChanged event 74 Visible property 87, 91

X X property 94

Y Y property 94