Sunteți pe pagina 1din 108

Users Guide

Designer Edition


Copyright 1987-2005 ComponentOne LLC. All rights reserved.


Corporate Headquarters
ComponentOne LLC
4516 Henry Street
Suite 500
Pittsburgh, PA 15213 USA
Internet: info@ComponentOne.com
Web site: http://www.componentone.com
Sales
E-mail: sales@componentone.com
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. ComponentOnes 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.





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

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

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
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.
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").
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.

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.
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
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
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 fromlicensed 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.
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:
[ Li censePr ovi der ( t ypeof ( Li censePr ovi der ) ) ]
cl ass MyGr i d: C1. Wi n. C1Fl exGr i d. C1Fl exGr i d
{
/ / . . .
}
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:
c1l c / t ar get : MyApp. exe / compl i st : l i censes. l i cx / i : C1. Wi n. C1Fl exGr i d. dl l
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. l i censes
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.
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'mgetting 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:
12 Welcome to the ComponentOne C1ReportDesigner Control

C1.Win.C1ReportDesigner.dll
Site licenses are available for groups of multiple developers. Please contact Sales@ComponentOne.com 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:
Support.Reports.NET@componentone.com
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.
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
Di mc1r pt As C1. Wi n. C1Repor t Desi gner . C1Repor t Desi gner
C#
C1. Wi n. C1Repor t Desi gner . C1Repor t Desi gner c1r pt ;
Delphi
c1r pt : C1. Wi n. C1Repor t Desi gner . C1Repor t Desi gner ;
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
' Def i ne a new Cl i pboar dHandl er obj ect ( cust omCl i pboar dHandl er cl ass)
Di mMyCl i pboar d as Cl i pboar dHandl er

' Def i ne a new C1Repor t Desi gner . Cl i pboar dHandl er obj ect .
Di mRepor t Desi gner Cl i p as _
C1. Wi n. C1Repor t Desi gner . Cl i pboar dHandl er
C#
/ / Def i ne a new Cl i pboar dHandl er obj ect ( cust omCl i pboar dHandl er cl ass)
MyCl i pboar d Cl i pboar dHandl er ;

/ / Def i ne a new C1Repor t Desi gner . Cl i pboar dHandl er obj ect .
Repor t Desi gner Cl i p C1. Wi n. C1Repor t Desi gner . Cl i pboar dHandl er ;
Delphi
/ / Def i ne a new Cl i pboar dHandl er obj ect ( cust omCl i pboar dHandl er cl ass)
var
MyCl i pboar d: Cl i pboar dHandl er ;

/ / Def i ne a new C1Repor t Desi gner . Cl i pboar dHandl er obj ect .
var
Repor t Desi gner Cl i p: C1. Wi n. C1Repor t Desi gner . Cl i pboar dHandl er ;
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:

14 Welcome to the ComponentOne C1ReportDesigner Control

Visual Basic
I mpor t s C1Cl i pboar dHandl er = C1. Wi n. C1Repor t Desi gner . Cl i pboar dHandl er
I mpor t s MyCl i pboar d = MyPr oj ect . Cl i pboar dHandl er

Di mc1 As C1Cl i pboar dHandl er
Di mc2 As MyCl i pboar d
C#
usi ng C1Cl i pboar dHandl er = C1. Wi n. C1Repor t Desi gner . Cl i pboar dHandl er ;
usi ng MyCl i pboar d = MyPr oj ect . Cl i pboar dHandl er ;

C1Cl i pboar dHandl er c1;
MyCl i pboar d c2;
Delphi
uses C1. Wi n. C1Repor t Desi gner . Cl i pboar dHandl er ,
MyPr oj ect . Cl i pboar dHandl er ;

c2: MyCl i pboar d;
c1: C1Cl i pboar dHandl er ;
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.
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 products 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.
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:

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
' f i el ds
Pr i vat e Pr oper t y Fi l eName St r i ng' name of t he cur r ent f i l e
End Pr oper t y
Pr i vat e Pr oper t y Di r t y As Bool ean' cur r ent f i l e has changed
End Pr oper t y

' t i t l e t o di spl ay i n t he f or mcapt i on
pr i vat e const St r i ng _appName = " C1Repor t Desi gner Demo"
C#
/ / f i el ds
pr i vat e st r i ng _f i l eName; / / name of t he cur r ent f i l e
pr i vat e bool _di r t y; / / cur r ent f i l e has changed

/ / t i t l e t o di spl ay i n t he f or mcapt i on
pr i vat e const st r i ng _appName = " C1Repor t Desi gner Demo" ;
Delphi
/ / f i el ds
var
_di r t y: Bool ean; / / name of t he cur r ent f i l e
_f i l eName: st r i ng; / / cur r ent f i l e has changed

/ / t i t l e t o di spl ay i n t he f or mcapt i on
const st r i ng _appName = ' C1Repor t Desi gner 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
' updat e UI on st ar t up t o show f or mt i t l e and di sabl e cl i pboar d and
' undo/ r edo but t ons
Pr i vat e Sub For m1_Load( ByVal sender As Obj ect , ByVal e As
Syst em. Event Ar gs)
Updat eUI ( )
End Sub
Pr i vat e Sub Updat eUI ( )
' updat e capt i on
Text = ( _f i l eName <> Not hi ng And _f i l eName. Lengt h > 0)
18 Overview

? St r i ng. For mat ( " {0} - [ {1}] {2}" , _appName, _f i l eName, _di r t y?
" *" : " " )
Di m_appName As :

' push/ r el ease desi gn/ pr evi ew mode but t ons
Di mdesi gn As Bool ean = _c1r d. Vi si bl e And _c1r d. Repor t <> Not hi ng
_bt nDesi gn. Pushed = desi gn
_bt nPr evi ew. Pushed = Not desi gn

' enabl e/ di sabl e but t ons
_bt nCut . Enabl ed = desi gn And _c1r d. Cl i pboar dHandl er . CanCut
_bt nCopy. Enabl ed = desi gn And _c1r d. Cl i pboar dHandl er . CanCut
_bt nPast e. Enabl ed = desi gn And _c1r d. Cl i pboar dHandl er . CanPast e
_bt nUndo. Enabl ed = desi gn And _c1r d. UndoSt ack. CanUndo
_bt nRedo. Enabl ed = desi gn And _c1r d. UndoSt ack. CanRedo

Di mr epor t Sel ect ed As Bool ean = desi gn And _l i st . Sel ect edI t em<>
Not hi ng
_bt nAddRepor t . Enabl ed = _c1r d. Vi si bl e
_bt nDel Repor t . Enabl ed = r epor t Sel ect ed
_bt nAddFi el d. Enabl ed = r epor t Sel ect ed
_bt nAddLabel . Enabl ed = r epor t Sel ect ed
End Sub
C#
/ / updat e UI on st ar t up t o show f or mt i t l e and di sabl e cl i pboar d and
/ / undo/ r edo but t ons
pr i vat e voi d For m1_Load( obj ect sender , Syst em. Event Ar gs e)
{
Updat eUI ( ) ;
}
pr i vat e voi d Updat eUI ( )
{
/ / updat e capt i on
Text = ( _f i l eName ! = nul l && _f i l eName. Lengt h > 0)
? st r i ng. For mat ( " {0} - [ {1}] {2}" , _appName, _f i l eName, _di r t y?
" *" : " " )
: _appName;

/ / push/ r el ease desi gn/ pr evi ew mode but t ons
bool desi gn = _c1r d. Vi si bl e && _c1r d. Repor t ! = nul l ;
_bt nDesi gn. Pushed = desi gn;
_bt nPr evi ew. Pushed = ! desi gn;

/ / enabl e/ di sabl e but t ons
_bt nCut . Enabl ed = desi gn && _c1r d. Cl i pboar dHandl er . CanCut ;
_bt nCopy. Enabl ed = desi gn && _c1r d. Cl i pboar dHandl er . CanCut ;
_bt nPast e. Enabl ed = desi gn && _c1r d. Cl i pboar dHandl er . CanPast e;
_bt nUndo. Enabl ed = desi gn && _c1r d. UndoSt ack. CanUndo;
_bt nRedo. Enabl ed = desi gn && _c1r d. UndoSt ack. CanRedo;

bool r epor t Sel ect ed = desi gn && _l i st . Sel ect edI t em! = nul l ;
_bt nAddRepor t . Enabl ed = _c1r d. Vi si bl e;
_bt nDel Repor t . Enabl ed = r epor t Sel ect ed;
_bt nAddFi el d. Enabl ed = r epor t Sel ect ed;
_bt nAddLabel . Enabl ed = r epor t Sel ect ed;
}
Delphi
/ / updat e UI on st ar t up t o show f or mt i t l e and di sabl e cl i pboar d and
/ / undo/ r edo but t ons
pr ocedur e For m1_Load( sender : Syst em. Obj ect ; e: Syst em. Event Ar gs) ;
begi n
Using the C1ReportDesigner Control 19

Updat eUI ;
end;

pr ocedur e Updat eUI ;
var
desi gn: Bool ean;
r epor t Sel ect ed: Bool ean;
begi n
/ / updat e capt i on
i f ( _f i l eName <> ni l ) and ( _f i l eNaSel f . Lengt h > 0) t hen
Text : = Syst em. St r i ng. For mat ( ' {0} - [ {1}] {2}' , _appName,
_f i l eName, _di r t y?' *' : ' ' )
el se
Text : = _appName;

/ / push/ r el ease desi gn/ pr evi ew mode but t ons
desi gn : = _c1r d. Vi si bl e And ( _c1r d. Repor t <> ni l ) ;
_bt nDesi gn. Pushed : = desi gn;
_bt nPr evi ew. Pushed : = Not desi gn;

/ / enabl e/ di sabl e but t ons
_bt nCut . Enabl ed : = desi gn And _c1r d. Cl i pboar dHandl er . CanCut ;
_bt nCopy. Enabl ed : = desi gn And _c1r d. Cl i pboar dHandl er . CanCut ;
_bt nPast e. Enabl ed : = desi gn And _c1r d. Cl i pboar dHandl er . CanPast e;
_bt nUndo. Enabl ed : = desi gn And _c1r d. UndoSt ack. CanUndo;
_bt nRedo. Enabl ed : = desi gn And _c1r d. UndoSt ack. CanRedo;

r epor t Sel ect ed : = desi gn And _l i st . Sel ect edI t em<> ni l ;
_bt nAddRepor t . Enabl ed : = _c1r d. Vi si bl e;
_bt nDel Repor t . Enabl ed : = r epor t Sel ect ed;
_bt nAddFi el d. Enabl ed : = r epor t Sel ect ed;
_bt nAddLabel . Enabl ed : = r epor t Sel ect ed;
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
' handl e cl i cks on t ool bar but t ons
Pr i vat e Pr oper t y sender , ( ) As _t b_But t onCl i ck( obj ect
End Pr oper t y
Pr i vat e Funct i on e) ( ) As Tool Bar But t onCl i ckEvent Ar gs
' desi gn/ pr evi ew mode
I f e. But t on = _bt nDesi gn Then
Set Desi gnMode( Tr ue)
End I f
I f e. But t on = _bt nPr evi ew Then
Set Desi gnMode( Fal se)
End I f

' f i l e commands
I f e. But t on = _bt nNew Then
NewFi l e( )
End I f
I f e. But t on = _bt nOpen Then
OpenFi l e( )
End I f
I f e. But t on = _bt nSave Then
SaveFi l e( )
20 Overview

End I f

' al l ow user t o undo cl i pboar d oper at i ons
I f e. But t on = _bt nCut Or e. But t on = _bt nPast e Then
_c1r d. UndoSt ack. SaveSt at e( )
End I f

' cl i pboar d
I f e. But t on = _bt nCut Then
_c1r d. Cl i pboar dHandl er . Cut ( )
End I f
I f e. But t on = _bt nCopy Then
_c1r d. Cl i pboar dHandl er . Copy( )
End I f
I f e. But t on = _bt nPast e Then
_c1r d. Cl i pboar dHandl er . Past e( )
End I f

' undo/ r edo
I f e. But t on = _bt nUndo Then
_c1r d. UndoSt ack. Undo( )
End I f
I f e. But t on = _bt nRedo Then
_c1r d. UndoSt ack. Redo( )
End I f

' add/ r emove r epor t s
I f e. But t on = _bt nAddRepor t Then
NewRepor t ( )
End I f
I f e. But t on = _bt nDel Repor t Then
Del et eRepor t ( )
End I f

' add f i el ds
' ( j ust set cr eat e i nf o and wai t f or Cr eat eFi el d event f r om
desi gner )
I f e. But t on = _bt nAddFi el d Then
_c1r d. Cr eat eFi el dI nf o = e. But t on
End I f
I f e. But t on = _bt nAddLabel Then
_c1r d. Cr eat eFi el dI nf o = e. But t on
End I f
End Funct i on
C#
/ / handl e cl i cks on t ool bar but t ons
pr i vat e voi d _t b_But t onCl i ck( obj ect sender ,
Tool Bar But t onCl i ckEvent Ar gs e)
{
/ / desi gn/ pr evi ew mode
i f ( e. But t on == _bt nDesi gn) Set Desi gnMode( t r ue) ;
i f ( e. But t on == _bt nPr evi ew) Set Desi gnMode( f al se) ;

/ / f i l e commands
i f ( e. But t on == _bt nNew) NewFi l e( ) ;
i f ( e. But t on == _bt nOpen) OpenFi l e( ) ;
i f ( e. But t on == _bt nSave) SaveFi l e( ) ;

/ / al l ow user t o undo cl i pboar d oper at i ons
i f ( e. But t on == _bt nCut | | e. But t on == _bt nPast e)
_c1r d. UndoSt ack. SaveSt at e( ) ;

/ / cl i pboar d
Using the C1ReportDesigner Control 21

i f ( e. But t on == _bt nCut ) _c1r d. Cl i pboar dHandl er . Cut ( ) ;
i f ( e. But t on == _bt nCopy) _c1r d. Cl i pboar dHandl er . Copy( ) ;
i f ( e. But t on == _bt nPast e) _c1r d. Cl i pboar dHandl er . Past e( ) ;

/ / undo/ r edo
i f ( e. But t on == _bt nUndo) _c1r d. UndoSt ack. Undo( ) ;
i f ( e. But t on == _bt nRedo) _c1r d. UndoSt ack. Redo( ) ;

/ / add/ r emove r epor t s
i f ( e. But t on == _bt nAddRepor t ) NewRepor t ( ) ;
i f ( e. But t on == _bt nDel Repor t ) Del et eRepor t ( ) ;

/ / add f i el ds
/ / ( j ust set cr eat e i nf o and wai t f or Cr eat eFi el d event f r om
desi gner )
i f ( e. But t on == _bt nAddFi el d) _c1r d. Cr eat eFi el dI nf o = e. But t on;
i f ( e. But t on == _bt nAddLabel ) _c1r d. Cr eat eFi el dI nf o = e. But t on;
}
Delphi
/ / handl e cl i cks on t ool bar but t ons
pr ocedur e _t b_But t onCl i ck ( sender : Syst em. Obj ect ; e:
Tool Bar But t onCl i ckEvent Ar gs) ;
begi n
/ / desi gn/ pr evi ew mode
i f e. But t on = _bt nDesi gn t hen
begi n
Set Desi gnMode( Tr ue) ;
end;
i f e. But t on = _bt nPr evi ew t hen
begi n
Set Desi gnMode( Fal se) ;
end;

/ / f i l e commands
i f e. But t on = _bt nNew t hen
begi n
NewFi l e;
end;
i f e. But t on = _bt nOpen t hen
begi n
OpenFi l e;
end;
i f e. But t on = _bt nSave t hen
begi n
SaveFi l e;
end;

/ / al l ow user t o undo cl i pboar d oper at i ons
i f e. But t on = _bt nCut Or e. But t on = _bt nPast e t hen
begi n
_c1r d. UndoSt ack. SaveSt at e;
end;

/ / cl i pboar d
i f e. But t on = _bt nCut t hen
begi n
_c1r d. Cl i pboar dHandl er . Cut ;
end;
i f e. But t on = _bt nCopy t hen
begi n
_c1r d. Cl i pboar dHandl er . Copy;
end;
i f e. But t on = _bt nPast e t hen
22 Overview

begi n
_c1r d. Cl i pboar dHandl er . Past e;
end;

/ / undo/ r edo
i f e. But t on = _bt nUndo t hen
begi n
_c1r d. UndoSt ack. Undo;
end;
i f e. But t on = _bt nRedo t hen
begi n
_c1r d. UndoSt ack. Redo;
end;

/ / add/ r emove r epor t s
i f e. But t on = _bt nAddRepor t t hen
begi n
NewRepor t ;
end;
i f e. But t on = _bt nDel Repor t t hen
begi n
Del et eRepor t ;
end;

/ / add f i el ds
/ / ( j ust set cr eat e i nf o and wai t f or Cr eat eFi el d event f r om
desi gner )
i f e. But t on = _bt nAddFi el d t hen
begi n
_c1r d. Cr eat eFi el dI nf o : = e. But t on;
end;
i f e. But t on = _bt nAddLabel t hen
begi n
_c1r d. Cr eat eFi el dI nf o : = e. But t on;
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
Pr i vat e Sub Set Desi gnMode( ByVal desi gn As Bool ean)
' show/ hi de pr evi ew/ desi gn panes
_c1r d. Vi si bl e = desi gn
_c1ppv. Vi si bl e = Not desi gn

' no pr oper t i es i n pr evi ew mode
I f Not desi gn Then
_l bl Pr opGr i d. Text = " Pr oper t i es"
_ppg. Sel ect edObj ect = Not hi ng
End I f
Using the C1ReportDesigner Control 23


' at t ach copy of t he r epor t t o pr evi ew cont r ol
' ( so changes caused by scr i pt ar en' t saved)
I f Not desi gn Then
_c1ppv. Document = Not hi ng
_c1r . CopyFr om( _c1r d. Repor t )
Cur sor = Cur sor s. Wai t Cur sor
_c1r . Render ( )
I f _c1r . PageI mages. Count > 0 Then
_c1ppv. Document = _c1r . Document
End I f
Cur sor = Cur sor s. Def aul t
End I f

/ done, updat e UI
Updat eUI ( )
End Sub
C#
pr i vat e voi d Set Desi gnMode( bool desi gn) {
/ / show/ hi de pr evi ew/ desi gn panes
_c1r d. Vi si bl e = desi gn;
_c1ppv. Vi si bl e = ! desi gn;

/ / no pr oper t i es i n pr evi ew mode
i f ( ! desi gn ) {
_l bl Pr opGr i d. Text = " Pr oper t i es" ;
_ppg. Sel ect edObj ect = nul l ;
}

/ / at t ach copy of t he r epor t t o pr evi ew cont r ol
/ / ( so changes caused by scr i pt ar en/ / t saved)
i f ( ! desi gn ) {
_c1ppv. Document = nul l ;
_c1r . CopyFr om( _c1r d. Repor t ) ;
Cur sor = Cur sor s. Wai t Cur sor ;
_c1r . Render ( ) ;
i f ( _c1r . PageI mages. Count > 0 ) {
_c1ppv. Document = _c1r . Document ;
}
Cur sor = Cur sor s. Def aul t ;
}

/ done, updat e UI ;
Updat eUI ( ) ;
}
Delphi
pr ocedur e Set Desi gnMode( desi gn: Bool ean) ;
begi n
/ / show/ hi de pr evi ew/ desi gn panes
_c1r d. Vi si bl e : = desi gn;
_c1ppv. Vi si bl e : = not desi gn;

/ / no pr oper t i es i n pr evi ew mode
i f Not desi gn t hen
begi n
_l bl Pr opGr i d. Text : = ' Pr oper t i es' ;
_ppg. Sel ect edObj ect : = ni l ;
end;

/ / at t ach copy of t he r epor t t o pr evi ew cont r ol
/ / ( so changes caused by scr i pt ar en / / t saved)
24 Overview

i f not desi gn t hen
begi n
_c1ppv. Document : = ni l ;
_c1r . CopyFr om( _c1r d. Repor t ) ;
Cur sor : = Cur sor s. Wai t Cur sor ;
_c1r . Render ;
i f _c1r . PageI mages. Count > 0 t hen
begi n
_c1ppv. Document : = _c1r . Document ;
end;
Cur sor : = Cur sor s. Def aul t ;
end;

/ / done, updat e UI ;
Updat eUI ;
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
Pr i vat e Sub NewFi l e( )
_f i l eName = " "
_di r t y = Fal se
_l i st . I t ems. Cl ear ( )
_c1ppv. Document = Not hi ng
_c1r d. Repor t = Not hi ng
Updat eUI ( )
End Sub
C#
pr i vat e voi d NewFi l e( )
{
_f i l eName = " " ;
_di r t y = f al se;
_l i st . I t ems. Cl ear ( ) ;
_c1ppv. Document = nul l ;
_c1r d. Repor t = nul l ;
Updat eUI ( ) ;
}
Delphi
pr ocedur e Cl ass1. NewFi l e;
begi n
_f i l eName : = ' ' ;
_di r t y : = Fal se;
_l i st . I t ems. Cl ear ;
_c1ppv. Document : = ni l ;
_c1r d. Repor t : = ni l ;
Updat eUI ;
end;
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
Publ i c Sub OpenFi l e( )
' get name of f i l e t o open
Di mdl g As New OpenFi l eDi al og
dl g. Fi l eName = " *. xml "
dl g. Ti t l e = " Open Repor t Def i ni t i on Fi l e"
I f dl g. ShowDi al og( ) <> Di al ogResul t . OK Then
Ret ur n
End I f

' check sel ect ed f i l e
Di mr epor t s( ) As St r i ng = Not hi ng
Tr y
r epor t s = _c1r . Get Repor t I nf o( dl g. Fi l eName)
End Tr y

I f r epor t s = Not hi ng Or r epor t s. Lengt h = 0 Then
MessageBox. Show( " I nval i d ( or empt y) r epor t def i ni t i on f i l e" )
Ret ur n
End I f
' cl ear l i st
NewFi l e( )

' l oad new f i l e
Cur sor = Cur sor s. Wai t Cur sor
_f i l eName = dl g. Fi l eName
Di mr epor t Name As St r i ng
For Each r epor t Name I n r epor t s
Di mr pt As C1Repor t = New C1Repor t ( )
r pt . Load( _f i l eName, r epor t Name)
_l i st . I t ems. Add( New Repor t Hol der ( r pt ) )
Next
Cur sor = Cur sor s. Def aul t
' sel ect f i r st r epor t
_l i st . Sel ect edI ndex = 0
}
' Repor t Hol der cl ass
' Hel per cl ass used t o st or e r epor t s i n l i st boxes. The mai n t hi ng
' i t does i s over r i de t he ToSt r i ng( ) met hod t o r ender t he r epor t name.
Publ i c Cl ass Repor t Hol der
Publ i c ReadOnl y Repor t As C1Repor t
Publ i c Sub New( ByVal r epor t As C1Repor t )
Repor t = r epor t
End Sub
Over r i des Publ i c Funct i on ToSt r i ng( ) As St r i ng
Di ms As St r i ng = Repor t . Repor t Name
Ret ur n( s <> Not hi ng And s. Lengt h > 0) ? s: " Unnamed Repor t "
End Funct i on
End Cl ass



26 Overview

C#
publ i c voi d OpenFi l e( )
{
/ / get name of f i l e t o open
OpenFi l eDi al og dl g = new OpenFi l eDi al og( ) ;
dl g. Fi l eName = " *. xml " ;
dl g. Ti t l e = " Open Repor t Def i ni t i on Fi l e" ;
i f ( dl g. ShowDi al og( ) ! = Di al ogResul t . OK)
r et ur n;

/ / check sel ect ed f i l e
st r i ng[ ] r epor t s = nul l ;
t r y
{
r epor t s = _c1r . Get Repor t I nf o( dl g. Fi l eName) ;
}
cat ch {}
i f ( r epor t s == nul l | | r epor t s. Lengt h == 0)
{
MessageBox. Show( " I nval i d ( or empt y) r epor t def i ni t i on f i l e" ) ;
r et ur n;
}

/ / cl ear l i st
NewFi l e( ) ;

/ / l oad new f i l e
Cur sor = Cur sor s. Wai t Cur sor ;
_f i l eName = dl g. Fi l eName;
f or each ( st r i ng r epor t Name i n r epor t s)
{
C1Repor t r pt = new C1Repor t ( ) ;
r pt . Load( _f i l eName, r epor t Name) ;
_l i st . I t ems. Add( new Repor t Hol der ( r pt ) ) ;
}
Cur sor = Cur sor s. Def aul t ;

/ / sel ect f i r st r epor t
_l i st . Sel ect edI ndex = 0;
}
/ / / Repor t Hol der cl ass
/ / / Hel per cl ass used t o st or e r epor t s i n l i st boxes. The mai n t hi ng
/ / / i t does i s over r i de t he ToSt r i ng( ) met hod t o r ender t he r epor t
name.
publ i c cl ass Repor t Hol der
{
publ i c r eadonl y C1Repor t Repor t ;
publ i c Repor t Hol der ( C1Repor t r epor t )
{
Repor t = r epor t ;
}
over r i de publ i c st r i ng ToSt r i ng( )
{
st r i ng s = Repor t . Repor t Name;
r et ur n ( s ! = nul l && s. Lengt h > 0) ? s: " Unnamed Repor t " ;
}
}
Delphi
pr ocedur e OpenFi l e;
var
dl g: OpenFi l eDi al og;
r epor t s: ar r ay of st r i ng;
Using the C1ReportDesigner Control 27

r epor t Name: st r i ng;
r pt : C1Repor t ;
begi n
/ / get name of f i l e t o open
dl g : = OpenFi l eDi al og. Cr eat e;
dl g. Fi l eName : = ' *. xml ' ;
dl g. Ti t l e : = ' Open Repor t Def i ni t i on Fi l e' ;
i f dl g. ShowDi al og <> Syst em. Wi ndows. For ms. Di al ogResul t . OK t hen
exi t ;

/ / check sel ect ed f i l e
r epor t s : = ni l ;
t r y
r epor t s : = _c1r . Get Repor t I nf o( dl g. Fi l eName) ;
except
end;

i f ( r epor t s = ni l ) or ( Lengt h( r epor t s) = 0) t hen
begi n
MessageBox. Show( ' I nval i d ( or empt y) r epor t def i ni t i on f i l e' ) ;
exi t ;
end;
/ / cl ear l i st
NewFi l e;

/ / l oad new f i l e
Cur sor : = Cur sor s. Wai t Cur sor ;
_f i l eName : = dl g. Fi l eName;
f or i : = 0 t o Hi gh( r epor t s) do
begi n
r epor t Name : = r epor t s[ i ] ;
r pt : = C1Repor t . Cr eat e;
r pt . Load( _f i l eName, r epor t Name) ;
_l i st . I t ems. Add( Repor t Hol der . Cr eat e( r pt ) ) ;
end;
Cur sor : = Cur sor s. Def aul t ;
/ / sel ect f i r st r epor t
_l i st . Sel ect edI ndex : = 0;
end;

/ / Repor t Hol der cl ass
/ / Hel per cl ass used t o st or e r epor t s i n l i st boxes. The mai n t hi ng
/ / i t does i s over r i de t he ToSt r i ng( ) met hod t o r ender t he r epor t
name.
Repor t Hol der = cl ass
publ i c
Repor t : C1Repor t ;
const r uct or Cr eat e( ARepor t : C1Repor t ) ;
f unct i on ToSt r i ng( ) : st r i ng; over r i de;
end;

const r uct or Repor t Hol der . Cr eat e( ARepor t : C1Repor t ) ;
begi n
i nher i t ed Cr eat e;
Repor t : = ARepor t ;
end;

f unct i on Repor t Hol der . ToSt r i ng( ) : st r i ng;
begi n
i f ( Repor t . Repor t Name <> ni l ) and ( Repor t . Repor t Name. Lengt h > 0) t hen
Resul t : = Repor t . Repor t Name
el se
Resul t : = ' Unnamed Repor t ' ;
end;
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
Publ i c Sub SaveFi l e( )
' get name of f i l e t o save
Di mdl g As New SaveFi l eDi al og( )
dl g. Fi l eName = _f i l eName
dl g. Ti t l e = " Save Repor t Def i ni t i on Fi l e"
I f dl g. ShowDi al og( ) <> Di al ogResul t . OK Then
Ret ur n
End I f
' save f i l e
Di mw As New Xml Text Wr i t er ( dl g. Fi l eName,
Syst em. Text . Encodi ng. Def aul t )
w. For mat t i ng = For mat t i ng. I ndent ed
w. I ndent at i on = 2
w. Wr i t eSt ar t Document ( )

' wr i t e al l r epor t s t o i t
Cur sor = Cur sor s. Wai t Cur sor
w. Wr i t eSt ar t El ement ( " Repor t s" )
Di mr h As Repor t Hol der
For Each r h I n _l i st . I t ems
r h. Repor t . Save( r h. Repor t . Repor t Name)
Next r h
w. Wr i t eEndEl ement ( )
Cur sor = Cur sor s. Def aul t

' cl ose t he f i l e
w. Cl ose( )

' and be done
_f i l eName = dl g. Fi l eName
_di r t y = Fal se
Updat eUI ( )
End Sub ' SaveFi l e
C#
publ i c voi d SaveFi l e( )
{
/ / get name of f i l e t o save
SaveFi l eDi al og dl g = new SaveFi l eDi al og( ) ;
dl g. Fi l eName = _f i l eName;
dl g. Ti t l e = " Save Repor t Def i ni t i on Fi l e" ;
i f ( dl g. ShowDi al og( ) ! = Di al ogResul t . OK)
r et ur n;

/ / save f i l e
Xml Text Wr i t er w = new Xml Text Wr i t er ( dl g. Fi l eName,
Syst em. Text . Encodi ng. Def aul t ) ;
w. For mat t i ng = For mat t i ng. I ndent ed;
w. I ndent at i on = 2;
w. Wr i t eSt ar t Document ( ) ;

/ / wr i t e al l r epor t s t o i t
Cur sor = Cur sor s. Wai t Cur sor ;
w. Wr i t eSt ar t El ement ( " Repor t s" ) ;
f or each ( Repor t Hol der r h i n _l i st . I t ems)
r h. Repor t . Save( r h. Repor t . Repor t Name) ;
w. Wr i t eEndEl ement ( ) ;
Cur sor = Cur sor s. Def aul t ;

Using the C1ReportDesigner Control 29

/ / cl ose t he f i l e
w. Cl ose( ) ;

/ / and be done
_f i l eName = dl g. Fi l eName;
_di r t y = f al se;
Updat eUI ( ) ;
}
Delphi
pr ocedur e SaveFi l e;
var
dl g: SaveFi l eDi al og;
w: Xml Text Wr i t er ;
r h: Repor t Hol der ;
i : I nt eger ;
begi n
dl g : = SaveFi l eDi al og. Cr eat e( ) ;
w : = Xml Text Wr i t er . Cr eat e( dl g. Fi l eName,
Syst em. Text . Encodi ng. Def aul t ) ;
/ / get name of f i l e t o save
dl g. Fi l eName : = _f i l eName;
dl g. Ti t l e : = ' Save Repor t Def i ni t i on Fi l e' ;
i f dl g. ShowDi al og <> Syst em. Wi ndows. For ms. Di al ogResul t . OK t hen
exi t ;
/ / save f i l e
w. For mat t i ng : = For mat t i ng. I ndent ed;
w. I ndent at i on : = 2;
w. Wr i t eSt ar t Document ;

/ / wr i t e al l r epor t s t o i t
Cur sor : = Cur sor s. Wai t Cur sor ;
w. Wr i t eSt ar t El ement ( ' Repor t s' ) ;
f or i : = 0 t o _l i st . I t ems. Count - 1 do
begi n
r h : = Repor t Hol der ( _l i st . I t ems[ i ] ) ;
r h. Repor t . Save( r h. Repor t . Repor t Name) ;
end;
w. Wr i t eEndEl ement ;
Cur sor : = Cur sor s. Def aul t ;

/ / cl ose t he f i l e
w. Cl ose;

/ / and be done
_f i l eName : = dl g. Fi l eName;
_di r t y : = Fal se;
Updat eUI ;
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 r epor t was sel ect ed: swi t ch t o desi gn mode and show i t
Pr i vat e Sub _l i st _Sel ect edI ndexChanged( sender As Obj ect , e As
Syst em. Event Ar gs)
' swi t ch t o desi gn mode
Set Desi gnMode( Tr ue)
30 Overview


' at t ach sel ect ed r epor t t o desi gner and pr evi ew cont r ol s
_c1r d. Repor t = Not hi ng
_c1ppv. Document = Not hi ng
I f Not ( _l i st . Sel ect edI t emI s Not hi ng) Then
_c1r d. Repor t = CType( _l i st . Sel ect edI t em, Repor t Hol der ) . Repor t
End I f
End Sub ' _l i st _Sel ect edI ndexChanged
C#
/ / a new r epor t was sel ect ed: swi t ch t o desi gn mode and show i t
pr i vat e voi d _l i st _Sel ect edI ndexChanged( obj ect sender , Syst em. Event Ar gs
e)
{
/ / swi t ch t o desi gn mode
Set Desi gnMode( t r ue) ;

/ / at t ach sel ect ed r epor t t o desi gner and pr evi ew cont r ol s
_c1r d. Repor t = nul l ;
_c1ppv. Document = nul l ;
i f ( _l i st . Sel ect edI t em! = nul l )
_c1r d. Repor t = ( ( Repor t Hol der ) _l i st . Sel ect edI t em) . Repor t ;
}
Delphi
/ / a new r epor t was sel ect ed: swi t ch t o desi gn mode and show i t
pr ocedur e _l i st _Sel ect edI ndexChanged( sender : Syst em. Obj ect ; e:
Syst em. Event Ar gs) ;
begi n
/ / swi t ch t o desi gn mode
Set Desi gnMode( Tr ue) ;

/ / at t ach sel ect ed r epor t t o desi gner and pr evi ew cont r ol s
_c1r d. Repor t : = ni l ;
_c1ppv. Document : = ni l ;
i f _l i st . Sel ect edI t em<> ni l t hen
begi n
_c1r d. Repor t : = ( _l i st . Sel ect edI t emas Repor t Hol der ) . Repor t ;
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
' t he sel ect i on changed, need t o updat e pr oper t y gr i d and show t he
' pr oper t i es of t he sel ect ed obj ect
Pr i vat e Sub _c1r d_Sel ect i onChanged( sender As Obj ect , e As
Syst em. Event Ar gs)
Di msel As Obj ect ( ) = _c1r d. Sel ect edFi el ds
I f sel . Lengt h > 0 Then
_l bl Pr opGr i d. Text = " Fi el d Pr oper t i es"
_ppg. Sel ect edObj ect s = sel
El se
I f Not ( _c1r d. Sel ect edSect i on I s Not hi ng) Then
_l bl Pr opGr i d. Text = " Sect i on Pr oper t i es"
_ppg. Sel ect edObj ect = _c1r d. Sel ect edSect i on
Using the C1ReportDesigner Control 31

El se
I f Not ( _c1r d. Repor t I s Not hi ng) Then
_l bl Pr opGr i d. Text = " Repor t Pr oper t i es"
_ppg. Sel ect edObj ect = _c1r d. Repor t
' not hi ng sel ect ed
El se
_l bl Pr opGr i d. Text = " Pr oper t i es"
_ppg. Sel ect edObj ect = Not hi ng
End I f
End I f
End I f ' done
Updat eUI ( )
End Sub ' _c1r d_Sel ect i onChanged
C#
/ / t he sel ect i on changed, need t o updat e pr oper t y gr i d and show t he
/ / pr oper t i es of t he sel ect ed obj ect
pr i vat e voi d _c1r d_Sel ect i onChanged( obj ect sender , Syst em. Event Ar gs e)
{
obj ect [ ] sel = _c1r d. Sel ect edFi el ds;
i f ( sel . Lengt h > 0)
{
_l bl Pr opGr i d. Text = " Fi el d Pr oper t i es" ;
_ppg. Sel ect edObj ect s = sel ;
}
el se i f ( _c1r d. Sel ect edSect i on ! = nul l )
{
_l bl Pr opGr i d. Text = " Sect i on Pr oper t i es" ;
_ppg. Sel ect edObj ect = _c1r d. Sel ect edSect i on;
}
el se i f ( _c1r d. Repor t ! = nul l )
{
_l bl Pr opGr i d. Text = " Repor t Pr oper t i es" ;
_ppg. Sel ect edObj ect = _c1r d. Repor t ;
}
el se / / not hi ng sel ect ed
{
_l bl Pr opGr i d. Text = " Pr oper t i es" ;
_ppg. Sel ect edObj ect = nul l ;
}

/ / done
Updat eUI ( ) ;
}
Delphi
/ / t he sel ect i on changed, need t o updat e pr oper t y gr i d and show t he
/ / pr oper t i es of t he sel ect ed obj ect

pr ocedur e Cl ass1. _c1r d_Sel ect i onChanged( sender : Syst em. Obj ect ; e:
Syst em. Event Ar gs) ;
var
sel : ar r ay of Syst em. Obj ect ;
begi n
sel : = _c1r d. Sel ect edFi el ds;
i f ( sel . Lengt h > 0) t hen
begi n
_l bl Pr opGr i d. Text : = ' Fi el d Pr oper t i es' ;
_ppg. Sel ect edObj ect s : = sel ;
end
el se
i f ( _c1r d. Sel ect edSect i on <> ni l ) t hen
begi n
32 Overview

_l bl Pr opGr i d. Text : = ' Sect i on Pr oper t i es' ;
_ppg. Sel ect edObj ect : = _c1r d. Sel ect edSect i on;
end
el se
i f ( _c1r d. Repor t <> ni l ) t hen
begi n
_l bl Pr opGr i d. Text : = ' Repor t Pr oper t i es' ;
_ppg. Sel ect edObj ect : = _c1r d. Repor t ;
end
el se / / not hi ng sel ect ed
begi n
_l bl Pr opGr i d. Text : = ' Pr oper t i es' ;
_ppg. Sel ect edObj ect : = ni l ;
end;

/ / done
Updat eUI ;
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 val ue changes i n t he pr oper t y wi ndow, r ef r esh t he desi gner
' t o show t he changes
Pr i vat e Sub _ppg_Pr oper t yVal ueChanged( s As Obj ect ,
e As Pr oper t yVal ueChangedEvent Ar gs)
_c1r d. Ref r esh( )
_di r t y = Tr ue
Updat eUI ( )
End Sub ' _ppg_Pr oper t yVal ueChanged


' when pr oper t i es of t he sel ect ed obj ect s change i n t he desi gner ,
' updat e t he pr oper t y wi ndow t o show t he changes
Pr i vat e Sub _c1r d_Val uesChanged( sender As Obj ect ,
e As Syst em. Event Ar gs)
_ppg. Ref r esh( )
_di r t y = Tr ue
Updat eUI ( )
End Sub ' _c1r d_Val uesChanged
C#
/ / when a val ue changes i n t he pr oper t y wi ndow, r ef r esh t he desi gner
/ / t o show t he changes
pr i vat e voi d _ppg_Pr oper t yVal ueChanged( obj ect s,
Pr oper t yVal ueChangedEvent Ar gs e)
{
_c1r d. Ref r esh( ) ;
_di r t y = t r ue;
Updat eUI ( ) ;
}

/ / when pr oper t i es of t he sel ect ed obj ect s change i n t he desi gner ,
/ / updat e t he pr oper t y wi ndow t o show t he changes
pr i vat e voi d _c1r d_Val uesChanged( obj ect sender , Syst em. Event Ar gs e)
{
_ppg. Ref r esh( ) ;
Using the C1ReportDesigner Control 33

_di r t y = t r ue;
Updat eUI ( ) ;
}
Delphi
/ / when a val ue changes i n t he pr oper t y wi ndow, r ef r esh t he desi gner
/ / t o show t he changes
pr ocedur e Cl ass1. _ppg_Pr oper t yVal ueChanged( s: Syst em. Obj ect ;
e: Pr oper t yVal ueChangedEvent Ar gs) ;
begi n
_c1r d. Ref r esh;
_di r t y : = Tr ue;
Updat eUI ;
End;

/ / when pr oper t i es of t he sel ect ed obj ect s change i n t he desi gner ,
/ / updat e t he pr oper t y wi ndow t o show t he changes
pr ocedur e Cl ass1. _c1r d_Val uesChanged( sender : Syst em. Obj ect ; e:
Syst em. Event Ar gs) ;
begi n
_ppg. Ref r esh;
_di r t y : = Tr ue;
Updat eUI ;
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
' r emove cur r ent r epor t f r omt he l i st
Pr i vat e Sub Del et eRepor t ( )
' a r epor t must be sel ect ed
Di mi ndex As I nt eger = _l i st . Sel ect edI ndex
I f i ndex < 0 Then
Ret ur n
End I f
' r emove r epor t f r omt he desi gner and f r omt he l i st
_c1r d. Repor t = Not hi ng
_l i st . I t ems. RemoveAt ( i ndex)

' sel ect anot her r epor t i f we can
I f i ndex > _l i st . I t ems. Count - 1 Then
i ndex = _l i st . I t ems. Count - 1
End I f
I f i ndex > - 1 Then
_l i st . Sel ect edI ndex = i ndex
End I f
' done
_di r t y = Tr ue
Updat eUI ( )
End Sub ' Del et eRepor t
C#
/ / r emove cur r ent r epor t f r omt he l i st
pr i vat e voi d Del et eRepor t ( )
{
/ / a r epor t must be sel ect ed
i nt i ndex = _l i st . Sel ect edI ndex;
i f ( i ndex < 0) r et ur n;
34 Overview


/ / r emove r epor t f r omt he desi gner and f r omt he l i st
_c1r d. Repor t = nul l ;
_l i st . I t ems. RemoveAt ( i ndex) ;

/ / sel ect anot her r epor t i f we can
i f ( i ndex > _l i st . I t ems. Count - 1) i ndex = _l i st . I t ems. Count - 1;
i f ( i ndex > - 1) _l i st . Sel ect edI ndex = i ndex;

/ / done
_di r t y = t r ue;
Updat eUI ( ) ;
}
Delphi
/ / r emove cur r ent r epor t f r omt he l i st
pr ocedur e Del et eRepor t ;
var
i ndex: I nt eger ;
begi n
/ / a r epor t must be sel ect ed
i ndex : = _l i st . Sel ect edI ndex;
i f i ndex < 0 t hen
begi n
exi t ;
end;
/ / r emove r epor t f r omt he desi gner and f r omt he l i st
_c1r d. Repor t : = ni l ;
_l i st . I t ems. RemoveAt ( i ndex) ;

/ / sel ect anot her r epor t i f we can
i f i ndex > _l i st . I t ems. Count - 1 t hen
i ndex : = _l i st . I t ems. Count - 1;
i f i ndex > - 1 t hen
_l i st . Sel ect edI ndex : = i ndex;
/ / done
_di r t y : = Tr ue;
Updat eUI ;
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
Pr i vat e Sub NewRepor t ( )
' sel ect a dat a sour ce ( j ust mdb f i l es i n t hi s sampl e)
Di mdl g As New OpenFi l eDi al og( )
dl g. Fi l eName = " *. mdb"
dl g. Ti t l e = " Sel ect r epor t dat a sour ce"
I f dl g. ShowDi al og( ) <> Di al ogResul t . OK Then
Ret ur n
End I f
' sel ect f i r st t abl e f r omdat a sour ce
Di mconnSt r i ng As St r i ng = St r i ng. For mat '

Di mt abl eName As St r i ng = Get Fi r st Tabl e( connSt r i ng)
I f t abl eName I s Not hi ng Or t abl eName. Lengt h = 0 Then
End I f
I f ( Tr ue) Then
Using the C1ReportDesigner Control 35

MessageBox. Show( " Fai l ed t o r et r i eve dat a f r omt he sel ect ed
sour ce. " )
Ret ur n
End I f

' cr eat e new r epor t
Di mr pt As New C1Repor t ( )
r pt . Repor t Name = t abl eName

' set dat a sour ce
r pt . Dat aSour ce. Connect i onSt r i ng = connSt r i ng
r pt . Dat aSour ce. Recor dSour ce = t abl eName

' add a t i t l e f i el d
Di ms As Sect i on = r pt . Sect i ons( Sect i onTypeEnum. Header )
s. Vi si bl e = Tr ue
s. Hei ght = 600
Di mf As Fi el d = s. Fi el ds. Add( " Ti t l eFi el d" , t abl eName, 0, 0, 4000,
600)
f . Font . Bol d = Tr ue
f . Font . Si ze = 24
f . For eCol or = Col or . Navy

' add up t o 5 cal cul at ed f i el ds
Di mf i el dNames As St r i ng( ) = r pt . Dat aSour ce. Get DBFi el dLi st ( Tr ue)
Di mcnt As I nt eger = Mat h. Mi n( 5, f i el dNames. Lengt h)

' add a page header
s = r pt . Sect i ons( Sect i onTypeEnum. PageHeader )
s. Vi si bl e = Tr ue
s. Hei ght = 400
Di mr c As New Rect angl e( 0, 0, 1000, CI nt ( s. Hei ght ) )
Di mi As I nt eger
For i = 0 To cnt - 1
Next i
I f ( Tr ue) Then
f = s. Fi el ds. Add( " Ti t l eFi el d" , f i el dNames( i ) , r c)
f . Font . Bol d = Tr ue
r c. Of f set ( r c. Wi dt h, 0)
End I f

' add det ai l sect i on
s = r pt . Sect i ons( Sect i onTypeEnum. Det ai l )
s. Vi si bl e = Tr ue
s. Hei ght = 300
r c = New Rect angl e( 0, 0, 1000, CI nt ( s. Hei ght ) )
Di mi As I nt eger
For i = 0 To cnt - 1
Next i
I f ( Tr ue) Then
f = s. Fi el ds. Add( " Ti t l eFi el d" , f i el dNames( i ) , r c)
f . Cal cul at ed = Tr ue
r c. Of f set ( r c. Wi dt h, 0)
End I f

' add new r epor t t o t he l i st and sel ect i t
_l i st . I t ems. Add( New Repor t Hol der ( r pt ) )
_l i st . Sel ect edI ndex = _l i st . I t ems. Count - 1

' done
_di r t y = Tr ue
Updat eUI ( )
End Sub ' NewRepor t
36 Overview

C#
pr i vat e voi d NewRepor t ( )
{
/ / sel ect a dat a sour ce ( j ust mdb f i l es i n t hi s sampl e)
OpenFi l eDi al og dl g = new OpenFi l eDi al og( ) ;
dl g. Fi l eName = " *. mdb" ;
dl g. Ti t l e = " Sel ect r epor t dat a sour ce" ;
i f ( dl g. ShowDi al og( ) ! = Di al ogResul t . OK) r et ur n;

/ / sel ect f i r st t abl e f r omdat a sour ce
st r i ng connSt r i ng =
st r i ng. For mat ( @" Pr ovi der =Mi cr osof t . J et . OLEDB. 4. 0; Dat a
Sour ce={0}; " ,
dl g. Fi l eName) ;
st r i ng t abl eName = Get Fi r st Tabl e( connSt r i ng) ;
i f ( t abl eName == nul l | | t abl eName. Lengt h == 0)
{
MessageBox. Show( " Fai l ed t o r et r i eve dat a f r omt he sel ect ed
sour ce. " ) ;
r et ur n;
}

/ / cr eat e new r epor t
C1Repor t r pt = new C1Repor t ( ) ;
r pt . Repor t Name = t abl eName;

/ / set dat a sour ce
r pt . Dat aSour ce. Connect i onSt r i ng = connSt r i ng;
r pt . Dat aSour ce. Recor dSour ce = t abl eName;

/ / add a t i t l e f i el d
Sect i on s = r pt . Sect i ons[ Sect i onTypeEnum. Header ] ;
s. Vi si bl e = t r ue;
s. Hei ght = 600;
Fi el d f = s. Fi el ds. Add( " Ti t l eFi el d" , t abl eName, 0, 0, 4000, 600) ;
f . Font . Bol d = t r ue;
f . Font . Si ze = 24;
f . For eCol or = Col or . Navy;

/ / add up t o 5 cal cul at ed f i el ds
st r i ng[ ] f i el dNames = r pt . Dat aSour ce. Get DBFi el dLi st ( t r ue) ;
i nt cnt = Mat h. Mi n( 5, f i el dNames. Lengt h) ;

/ / add a page header
s = r pt . Sect i ons[ Sect i onTypeEnum. PageHeader ] ;
s. Vi si bl e = t r ue;
s. Hei ght = 400;
Rect angl e r c = new Rect angl e( 0, 0, 1000, ( i nt ) s. Hei ght ) ;
f or ( i nt i = 0; i < cnt ; i ++)
{
f = s. Fi el ds. Add( " Ti t l eFi el d" , f i el dNames[ i ] , r c) ;
f . Font . Bol d = t r ue;
r c. Of f set ( r c. Wi dt h, 0) ;
}

/ / add det ai l sect i on
s = r pt . Sect i ons[ Sect i onTypeEnum. Det ai l ] ;
s. Vi si bl e = t r ue;
s. Hei ght = 300;
r c = new Rect angl e( 0, 0, 1000, ( i nt ) s. Hei ght ) ;
f or ( i nt i = 0; i < cnt ; i ++)
{
f = s. Fi el ds. Add( " Ti t l eFi el d" , f i el dNames[ i ] , r c) ;
Using the C1ReportDesigner Control 37

f . Cal cul at ed = t r ue;
r c. Of f set ( r c. Wi dt h, 0) ;
}

/ / add new r epor t t o t he l i st and sel ect i t
_l i st . I t ems. Add( new Repor t Hol der ( r pt ) ) ;
_l i st . Sel ect edI ndex = _l i st . I t ems. Count - 1;

/ / done
_di r t y = t r ue;
Updat eUI ( ) ;
}
Delphi
pr ocedur e NewRepor t ;
var
dl g: OpenFi l eDi al og;
connSt r i ng: st r i ng;
t abl eName: st r i ng;
r pt : C1Repor t ;
s: Sect i on;
f : Fi el d;
f i el dNames: ar r ay of st r i ng;
cnt : I nt eger ;
r c: Rect angl e;
i : I nt eger ;
i : I nt eger ;
begi n
/ / sel ect a dat a sour ce ( j ust mdb f i l es i n t hi s sampl e)
dl g : = OpenFi l eDi al og. Cr eat e;
dl g. Fi l eName : = ' *. mdb' ;
dl g. Ti t l e : = ' Sel ect r epor t dat a sour ce' ;
i f dl g. ShowDi al og <> Syst em. Wi ndows. For ms. Di al ogResul t . OK t hen
exi t ;

/ / sel ect f i r st t abl e f r omdat a sour ce
connSt r i ng : =
Syst em. St r i ng. For mat ( ( ' Pr ovi der =Mi cr osof t . J et . OLEDB. 4. 0; Dat a
Sour ce={0}; ' , dl g. Fi l eName) ;
t abl eName : = Get Fi r st Tabl e( connSt r i ng) ;
i f ( t abl eName = ni l ) or ( t abl eName. Lengt h = 0) t hen
begi n
MessageBox. Show( ' Fai l ed t o r et r i eve dat a f r omt he sel ect ed
sour ce. ' ) ;
exi t ;
end;

/ / cr eat e new r epor t
r pt : = C1Repor t . Cr eat e;
r pt . Repor t Name : = t abl eName;

/ / set dat a sour ce
r pt . Dat aSour ce. Connect i onSt r i ng : = connSt r i ng;
r pt . Dat aSour ce. Recor dSour ce : = t abl eName;

/ / add a t i t l e f i el d
s : = r pt . Sect i ons( Sect i onTypeEnum. Header ) ;
s. Vi si bl e : = Tr ue;
s. Hei ght : = 600;
f : = s. Fi el ds. Add( ' Ti t l eFi el d' , t abl eName, 0, 0, 4000, 600) ;
f . Font . Bol d : = Tr ue;
f . Font . Si ze : = 24;
f . For eCol or : = Col or . Navy;

38 Overview

/ / add up t o 5 cal cul at ed f i el ds
f i el dNames : = r pt . Dat aSour ce. Get DBFi el dLi st ( Tr ue) ;
cnt : = Mat h. Mi n( 5, f i el dNames. Lengt h) ;

/ / add a page header
s : = r pt . Sect i ons( Sect i onTypeEnum. PageHeader ) ;
s. Vi si bl e : = Tr ue;
s. Hei ght : = 400;
r c : = Rect angl e. Cr eat e( 0, 0, 1000, I nt eger ( s. Hei ght ) ) ;
f or i = 0 t o cnt - 1 do
begi n
f : = s. Fi el ds. Add( ' Ti t l eFi el d' , f i el dNames[ i ] , r c) ;
f . Font . Bol d : = Tr ue;
r c. Of f set ( r c. Wi dt h, 0) ;
end;

/ / add det ai l sect i on
s : = r pt . Sect i ons( Sect i onTypeEnum. Det ai l ) ;
s. Vi si bl e : = Tr ue;
s. Hei ght : = 300;
r c : = Rect angl e. Cr eat e( 0, 0, 1000, CI nt ( s. Hei ght ) ) ;
f or i = 0 t o cnt - 1 do
begi n
f : = s. Fi el ds. Add( ' Ti t l eFi el d' , f i el dNames[ i ] , r c) ;
f . Cal cul at ed : = Tr ue;
r c. Of f set ( r c. Wi dt h, 0) ;
end;

/ / add new r epor t t o t he l i st and sel ect i t
_l i st . I t ems. Add( Repor t Hol der . Cr eat e( r pt ) ) ;
_l i st . Sel ect edI ndex : = _l i st . I t ems. Count - 1;

/ / done
_di r t y : = Tr ue;
Updat eUI ;
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
Pr i vat e Funct i on Get Fi r st Tabl e( connSt r i ng As St r i ng) As St r i ng
Di mt abl eName As St r i ng = Not hi ng
Di mconn As New Ol eDbConnect i on( connSt r i ng)
Tr y
' get schema
conn. Open( )

Di mdt As Dat aTabl e = conn. Get Ol eDbSchemaTabl e(
Ol eDbSchemaGui d. Tabl es, Not hi ng)
Di mdr As Dat aRow
For Each dr I n dt . Rows
' check t he t abl e t ype
Di mt ype As St r i ng = dr ( " TABLE_TYPE" ) . ToSt r i ng( ) . ToUpper ( )
I f t ype = " TABLE" Or t ype = " VI EW" Or t ype = " LI NK" Then
' get t he t abl e name
t abl eName = dr ( " TABLE_NAME" ) . ToSt r i ng( )
End I f
Next dr

' done
conn. Cl ose( )
Cat ch
End Tr y
Using the C1ReportDesigner Control 39

' r et ur n t he f i r st t abl e we f ound
Ret ur n t abl eName
End Funct i on ' Get Fi r st Tabl e
C#
pr i vat e st r i ng Get Fi r st Tabl e( st r i ng connSt r i ng)
{
st r i ng t abl eName = nul l ;
Ol eDbConnect i on conn = new Ol eDbConnect i on( connSt r i ng) ;
t r y
{
/ / get schema
conn. Open( ) ;

Dat aTabl e dt = conn. Get Ol eDbSchemaTabl e( Ol eDbSchemaGui d. Tabl es,
nul l ) ;
f or each ( Dat aRow dr i n dt . Rows)
{
/ / check t he t abl e t ype
st r i ng t ype = dr [ " TABLE_TYPE" ] . ToSt r i ng( ) . ToUpper ( ) ;
i f ( t ype ! = " TABLE" && t ype ! = " VI EW" && t ype ! = " LI NK" )
cont i nue;

/ / get t he t abl e name
t abl eName = dr [ " TABLE_NAME" ] . ToSt r i ng( ) ;
br eak;
}

/ / done
conn. Cl ose( ) ;
}
cat ch {}

/ / r et ur n t he f i r st t abl e we f ound
r et ur n t abl eName;
}
Delphi
f unct i on Get Fi r st Tabl e( connSt r i ng: St r i ng) : st r i ng;
var
t abl eName: St r i ng;
conn: Ol eDbConnect i on;
dt : Dat aTabl e;
dr : Dat aRow;
t : St r i ng;
i : I nt eger ;
begi n
conn : = Ol eDbConnect i on. Cr eat e( connSt r i ng) ;
t abl eName : = ni l ;
t r y
/ / get schema
conn. Open;

dt : = conn. Get Ol eDbSchemaTabl e( Ol eDbSchemaGui d. Tabl es, ni l ) ;
f or i : = 0 t o dt . Rows. Count - 1 do
begi n
dr : = dt . Rows[ i ] ;
/ / check t he t abl e t ype
t : = dr [ ' TABLE_TYPE' ] . ToSt r i ng. ToUpper ;
i f ( t <> ' TABLE' ) and ( t <> ' VI EW' ) and ( t <> ' LI NK' ) t hen
cont i nue;

/ / get t he t abl e name
40 Overview

t abl eName : = dr [ ' TABLE_NAME' ] . ToSt r i ng;
br eak;
end;

/ / done
conn. Cl ose;
except
end;
/ / r et ur n t he f i r st t abl e we f ound
Resul t : = t abl eName;
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
' handl e cl i cks on t ool bar but t ons
Pr i vat e Sub _t b_But t onCl i ck( sender As Obj ect , e As
Tool Bar But t onCl i ckEvent Ar gs)
'
' add f i el ds
' ( j ust set cr eat e i nf o and wai t f or Cr eat eFi el d event f r om
desi gner )
I f e. But t on = _bt nAddFi el d Then
_c1r d. Cr eat eFi el dI nf o = e. But t on
End I f
I f e. But t on = _bt nAddLabel Then
_c1r d. Cr eat eFi el dI nf o = e. But t on
End I f
End Sub ' _t b_But t onCl i ck
C#
/ / handl e cl i cks on t ool bar but t ons
pr i vat e voi d _t b_But t onCl i ck( obj ect sender , Tool Bar But t onCl i ckEvent Ar gs
e)
{
/ /

/ / add f i el ds
/ / ( j ust set cr eat e i nf o and wai t f or Cr eat eFi el d event f r om
desi gner )
i f ( e. But t on == _bt nAddFi el d) _c1r d. Cr eat eFi el dI nf o = e. But t on;
i f ( e. But t on == _bt nAddLabel ) _c1r d. Cr eat eFi el dI nf o = e. But t on;
}
Delphi
/ / handl e cl i cks on t ool bar but t ons
pr ocedur e Cl ass1. _t b_But t onCl i ck( sender : Syst em. Obj ect ; e:
Tool Bar But t onCl i ckEvent Ar gs) ;
begi n
/ / add f i el ds
/ / ( j ust set cr eat e i nf o and wai t f or Cr eat eFi el d event f r om
desi gner )
i f ( e. But t on = _bt nAddFi el d) t hen
_c1r d. Cr eat eFi el dI nf o : = e. But t on;
i f ( e. But t on = _bt nAddLabel ) t hen
_c1r d. Cr eat eFi el dI nf o : = e. But t on;
end;
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
Di m_ct r As I nt eger = 0

Pr i vat e Sub _c1r d_Cr eat eFi el d( sender As Obj ect , e As
C1. Wi n. C1Repor t Desi gner . Cr eat eFi el dEvent Ar gs)
' save undo i nf o
_c1r d. UndoSt ack. SaveSt at e( )

' add l abel f i el d
Di mf i el dName As St r i ng = St r i ng. For mat ( " NewFi el d{0}" , ++ _ct r )
' ToDo: Unsuppor t ed oper at or
' ToDo: ++ oper at or not suppor t ed wi t hi n expr essi ons
Di mf i el dText As St r i ng = f i el dName
Di mf As Fi el d = e. Sect i on. Fi el ds. Add( f i el dName, f i el dText ,
e. Fi el dBounds)

' i f t hi s i s a cal cul at ed f i el d,
' change t he Text and Cal cul at ed pr oper t i es
I f e. Cr eat eFi el dI nf o = _bt nAddFi el d Then
Di mf i el dNames As St r i ng( ) =
_c1r d. Repor t . Dat aSour ce. Get DBFi el dLi st ( Tr ue)
I f f i el dNames. Lengt h > 0 Then
f . Text = f i el dNames( 0)
f . Cal cul at ed = Tr ue
End I f
End I f
End Sub ' _c1r d_Cr eat eFi el d
C#
i nt _ct r = 0;
pr i vat e voi d _c1r d_Cr eat eFi el d( obj ect sender ,
C1. Wi n. C1Repor t Desi gner . Cr eat eFi el dEvent Ar gs e)
{
/ / save undo i nf o
_c1r d. UndoSt ack. SaveSt at e( ) ;

/ / add l abel f i el d
st r i ng f i el dName = st r i ng. For mat ( " NewFi el d{0}" , ++_ct r ) ;
st r i ng f i el dText = f i el dName;
Fi el d f = e. Sect i on. Fi el ds. Add( f i el dName, f i el dText ,
e. Fi el dBounds) ;

/ / i f t hi s i s a cal cul at ed f i el d,
/ / change t he Text and Cal cul at ed pr oper t i es
i f ( e. Cr eat eFi el dI nf o == _bt nAddFi el d)
{
st r i ng[ ] f i el dNames =
_c1r d. Repor t . Dat aSour ce. Get DBFi el dLi st ( t r ue) ;
i f ( f i el dNames. Lengt h > 0)
{
f . Text = f i el dNames[ 0] ;
f . Cal cul at ed = t r ue;
}
}
}
42 Overview

Delphi
pr ocedur e _c1r d_Cr eat eFi el d( sender : Syst em. Obj ect ; e:
C1. Wi n. C1Repor t Desi gner . Cr eat eFi el dEvent Ar gs) ;
var
f i el dName: st r i ng;
f i el dText : st r i ng;
f : Fi el d;
f i el dNames: ar r ay of st r i ng;
begi n
/ / save undo i nf o
_c1r d. UndoSt ack. SaveSt at e;

/ / add l abel f i el d
I nc( _ct r ) ;
f i el dName : = Syst em. St r i ng. For mat ( ' NewFi el d{0}' ,
Syst em. Obj ect ( _ct r ) ) ;
/ / ToDo: Unsuppor t ed oper at or
/ / ToDo: ++ oper at or not suppor t ed wi t hi n expr essi ons
f i el dText : = f i el dName;
f : = e. Sect i on. Fi el ds. Add( f i el dName, f i el dText , e. Fi el dBounds) ;

/ / i f t hi s i s a cal cul at ed f i el d,
/ / change t he Text and Cal cul at ed pr oper t i es
i f e. Cr eat eFi el dI nf o = _bt nAddFi el d t hen
begi n
f i el dNames : = _c1r d. Repor t . Dat aSour ce. Get DBFi el dLi st ( Tr ue) ;
i f f i el dNames. Lengt h > 0 t hen
begi n
f . Text : = f i el dNames[ 0] ;
f . Cal cul at ed : = Tr ue;
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.
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.
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).
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.
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)
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;}
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)
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:
50 Object Reference

Visual Basic
Pr i vat e Sub _t bCr eat e_But t onCl i ck( sender As Obj ect ,
e As Tool Bar But t onCl i ckEvent Ar gs)
' save t ype of f i el d t o cr eat e and wai t f or t he Cr eat eFi el d event
_desi gner . Cr eat eFi el dI nf o = e. But t on
End Sub ' _t bCr eat e_But t onCl i ck


' user i s cr eat i ng a f i el d wi t h t he mouse
' ( i n r esponse t o set t i ng t he _desi gner . Cr eat eFi el dI nf o pr oper t y)
Pr i vat e Sub _desi gner _Cr eat eFi el d( sender As Obj ect ,
e As Cr eat eFi el dEvent Ar gs)
' save undo i nf o
_desi gner . UndoSt ack. SaveSt at e( )

' cr eat e new f i el d i n t hi s sect i on
Di mf l dName As St r i ng = Get Uni queFi el dName( )
Di mf i el ds As Fi el dCol l ect i on = e. Sect i on. Fi el ds
Di mf i el d As Fi el d = f i el ds. Add( f l dName, Not hi ng, e. Fi el dBounds)

' set new f i el d pr oper t i es based on Cr eat eFi el dI nf o
Di mbt n As Obj ect = e. Cr eat eFi el dI nf o
I f bt n = _bt nLabel Then
f i el d. Text = f i el d. Name
f i el d. Cal cul at ed = Fal se
El se
I f bt n = _bt nPageBr eak Then
f i el d. For cePageBr eak = For cePageBr eakEnum. Af t er
f i el d. Cal cul at ed = Fal se
El se
I f bt n = _bt nRect angl e Then
f i el d. Bor der St yl e = Bor der St yl eEnum. Sol i d
f i el d. Cal cul at ed = Fal se
El se
Debug. Asser t ( Fal se, " Unknown f i el d cr eat or obj ect " )
End I f
End I f
End I f ' sel ect t he new f i el d, zap cr eat or
_desi gner . Cr eat eFi el dI nf o = Not hi ng
_desi gner . Sel ect edFi el ds = New Fi el d( ) {f i el d}
End Sub ' _desi gner _Cr eat eFi el d
C#
pr i vat e voi d _t bCr eat e_But t onCl i ck( obj ect sender ,
Tool Bar But t onCl i ckEvent Ar gs e)
{
/ / save t ype of f i el d t o cr eat e and wai t f or t he Cr eat eFi el d event
_desi gner . Cr eat eFi el dI nf o = e. But t on;

}

/ / user i s cr eat i ng a f i el d wi t h t he mouse
/ / ( i n r esponse t o set t i ng t he _desi gner . Cr eat eFi el dI nf o pr oper t y)
pr i vat e voi d _desi gner _Cr eat eFi el d( obj ect sender ,
Cr eat eFi el dEvent Ar gs e)
{
/ / save undo i nf o
_desi gner . UndoSt ack. SaveSt at e( ) ;

/ / cr eat e new f i el d i n t hi s sect i on
st r i ng f l dName = Get Uni queFi el dName( ) ;
Fi el dCol l ect i on f i el ds = e. Sect i on. Fi el ds;
Fi el d f i el d = f i el ds. Add( f l dName, nul l , e. Fi el dBounds) ;
CreateFieldInfo Property 51


/ / set new f i el d pr oper t i es based on Cr eat eFi el dI nf o
obj ect bt n = e. Cr eat eFi el dI nf o;
i f ( bt n == _bt nLabel )
{
f i el d. Text = f i el d. Name;
f i el d. Cal cul at ed = f al se;
}
el se i f ( bt n == _bt nPageBr eak)
{
f i el d. For cePageBr eak = For cePageBr eakEnum. Af t er ;
f i el d. Cal cul at ed = f al se;
}
el se i f ( bt n == _bt nRect angl e)
{
f i el d. Bor der St yl e = Bor der St yl eEnum. Sol i d;
f i el d. Cal cul at ed = f al se;
}
el se
{
Debug. Asser t ( f al se, " Unknown f i el d cr eat or obj ect " ) ;
}

/ / sel ect t he new f i el d, zap cr eat or
_desi gner . Cr eat eFi el dI nf o = nul l ;
_desi gner . Sel ect edFi el ds = new Fi el d[ ] { f i el d };
}
Delphi
pr ocedur e Cl ass1. _t bCr eat e_But t onCl i ck( sender : Syst em. Obj ect ; e:
Tool Bar But t onCl i ckEvent Ar gs) ;
begi n
/ / save t ype of f i el d t o cr eat e and wai t f or t he Cr eat eFi el d event
_desi gner . Cr eat eFi el dI nf o : = e. But t on;
end;

/ / user i s cr eat i ng a f i el d wi t h t he mouse
/ / ( i n r esponse t o set t i ng t he _desi gner . Cr eat eFi el dI nf o pr oper t y)
pr ocedur e Cl ass1. _desi gner _Cr eat eFi el d( sender : Syst em. Obj ect ; e:
Cr eat eFi el dEvent Ar gs) ;
var
bt n: Syst em. Obj ect ;
f i el d: Fi el d;
f i el ds: Fi el dCol l ect i on;
f l dName: st r i ng;
f l ds: ar r ay of f i el ds;
begi n
/ / save undo i nf o
_desi gner . UndoSt ack. SaveSt at e;

/ / cr eat e new f i el d i n t hi s sect i on
f l dName : = Get Uni queFi el dName;
f i el ds : = e. Sect i on. Fi el ds;
f i el d : = f i el ds. Add( f l dName, ni l , e. Fi el dBounds) ;

/ / set new f i el d pr oper t i es based on Cr eat eFi el dI nf o
bt n : = e. Cr eat eFi el dI nf o;
i f ( bt n = _bt nLabel ) t hen
begi n
f i el d. Text : = f i el d. Name;
f i el d. Cal cul at ed : = Fal se;
end
el se
i f ( bt n = _bt nPageBr eak) t hen
52 Object Reference

begi n
f i el d. For cePageBr eak : = For cePageBr eakEnum. Af t er ;
f i el d. Cal cul at ed : = Fal se;
end
el se
i f ( bt n = _bt nRect angl e) t hen
begi n
f i el d. Bor der St yl e : = Bor der St yl eEnum. Sol i d;
f i el d. Cal cul at ed : = Fal se;
end
el se
Debug. Asser t ( Fal se, ' Unknown f i el d cr eat or obj ect ' ) ;

/ / sel ect t he new f i el d, zap cr eat or
_desi gner . Cr eat eFi el dI nf o : = ni l ;
Set Lengt h( f l ds, 1) ;
f l ds[ 0] : = f i el d;
_desi gner . Sel ect edFi el ds : = f l ds;
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;

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)


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

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
Pr i vat e Sub _r epor t Li st _Sel ect edI ndexChanged( sender As Obj ect , e As
Syst em. Event Ar gs)
' make sur e we' r e i n desi gn vi ew
Repor t Desi gnMode = Tr ue

' r eset any cr eat e f i el d i nf or mat i on
_desi gner . Cr eat eFi el dI nf o = Not hi ng

' assi gn sel ect ed r epor t t o desi gner component
Di mr w As Repor t I t em= _r epor t Li st . Sel ect edI t em
I f r w I s Not hi ng Then
desi gner . Repor t = Not hi ng
El se
desi gner . Repor t = r w. _r epor t
End I f

' updat e UI
Updat eUI ( )
End Sub ' _r epor t Li st _Sel ect edI ndexChanged
C#
pr i vat e voi d _r epor t Li st _Sel ect edI ndexChanged( obj ect sender ,
Syst em. Event Ar gs e)
{
/ / make sur e we' r e i n desi gn vi ew
Repor t Desi gnMode = t r ue;

/ / r eset any cr eat e f i el d i nf or mat i on
_desi gner . Cr eat eFi el dI nf o = nul l ;

/ / assi gn sel ect ed r epor t t o desi gner component
Repor t I t emr w = _r epor t Li st . Sel ect edI t em;
_desi gner . Repor t = ( r w ! = nul l ) ? r w. _r epor t : nul l ;

/ / updat e UI
Updat eUI ( ) ;
}

56 Object Reference

Delphi
pr ocedur e Cl ass1. _r epor t Li st _Sel ect edI ndexChanged( sender :
Syst em. Obj ect ; e: Syst em. Event Ar gs) ;
var
r w: Repor t I t em;
begi n
/ / make sur e we' r e i n desi gn vi ew
Repor t Desi gnMode : = Tr ue;

/ / r eset any cr eat e f i el d i nf or mat i on
_desi gner . Cr eat eFi el dI nf o : = ni l ;

/ / assi gn sel ect ed r epor t t o desi gner component
r w : = _r epor t Li st . Sel ect edI t em;
i f r w <> nul l t hen
_desi gner . Repor t : = r w. Repor t
el se
_ desi gner . Repor t : = ni l ;

/ / updat e UI
Updat eUI ;
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)


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
' sel ect i on changed, updat e pr oper t y gr i d
Pr i vat e Sub _desi gner _Sel ect i onChanged( sender As Obj ect , e As
Syst em. Event Ar gs)
' show f i el d pr oper t i es
Di msel As Obj ect ( ) = _desi gner . Sel ect edFi el ds
I f sel . Lengt h > 0 Then
_pr opLabel . Text = " Fi el d Pr oper t i es"
_pr opGr i d. Sel ect edObj ect s = sel

' show sect i on pr oper t i es
El se
I f Not ( _desi gner . Sel ect edSect i on I s Not hi ng) Then
_pr opLabel . Text = " Sect i on Pr oper t i es"
_pr opGr i d. Sel ect edObj ect = _desi gner . Sel ect edSect i on

' show r epor t pr oper t i es
El se
I f Not ( _desi gner . Repor t I s Not hi ng) Then
_pr opLabel . Text = " Repor t Pr oper t i es"
_pr opGr i d. Sel ect edObj ect = _desi gner . Repor t

' not hi ng t o show. . .
58 Object Reference

El se
_pr opLabel . Text = " Pr oper t i es"
_pr opGr i d. Sel ect edObj ect = Not hi ng
End I f
End I f
End I f ' updat e UI ( _menus, t ool bar s, et c. )
_desi gner . Cr eat eFi el dI nf o = Not hi ng
Updat eUI ( )
End Sub ' _desi gner _Sel ect i onChanged
C#
/ / sel ect i on changed, updat e pr oper t y gr i d
pr i vat e voi d _desi gner _Sel ect i onChanged( obj ect sender , Syst em. Event Ar gs
e)
{
/ / show f i el d pr oper t i es
obj ect [ ] sel = _desi gner . Sel ect edFi el ds;
i f ( sel . Lengt h > 0)
{
_pr opLabel . Text = " Fi el d Pr oper t i es" ;
_pr opGr i d. Sel ect edObj ect s = sel ;
}

/ / show sect i on pr oper t i es
el se i f ( _desi gner . Sel ect edSect i on ! = nul l )
{
_pr opLabel . Text = " Sect i on Pr oper t i es" ;
_pr opGr i d. Sel ect edObj ect = _desi gner . Sel ect edSect i on;
}

/ / show r epor t pr oper t i es
el se i f ( _desi gner . Repor t ! = nul l )
{
_pr opLabel . Text = " Repor t Pr oper t i es" ;
_pr opGr i d. Sel ect edObj ect = _desi gner . Repor t ;
}

/ / not hi ng t o show. . .
el se
{
_pr opLabel . Text = " Pr oper t i es" ;
_pr opGr i d. Sel ect edObj ect = nul l ;
}

/ / updat e UI ( _menus, t ool bar s, et c. )
_desi gner . Cr eat eFi el dI nf o = nul l ;
Updat eUI ( ) ;
}
Delphi
/ / sel ect i on changed, updat e pr oper t y gr i d
pr ocedur e Cl ass1. _desi gner _Sel ect i onChanged( sender : Syst em. Obj ect ; e:
Syst em. Event Ar gs) ;
var

/ / show f i el d pr oper t i es
sel : ar r ay of Syst em. Obj ect ;
begi n
sel : = _desi gner . Sel ect edFi el ds;
i f ( Lengt h( sel ) > 0) t hen
begi n
_pr opLabel . Text : = ' Fi el d Pr oper t i es' ;
_pr opGr i d. Sel ect edObj ect s : = sel ;
SelectedFields Property 59

end

/ / show sect i on pr oper t i es
el se
i f ( _desi gner . Sel ect edSect i on <> ni l ) t hen
begi n
_pr opLabel . Text : = ' Sect i on Pr oper t i es' ;
_pr opGr i d. Sel ect edObj ect : = _desi gner . Sel ect edSect i on;
end

/ / show r epor t pr oper t i es
el se
i f ( _desi gner . Repor t <> ni l ) t hen
begi n
_pr opLabel . Text : = ' Repor t Pr oper t i es' ;
_pr opGr i d. Sel ect edObj ect : = _desi gner . Repor t ;
end

/ / not hi ng t o show. . .
el se
begi n
_pr opLabel . Text : = ' Pr oper t i es' ;
_pr opGr i d. Sel ect edObj ect : = ni l ;
end;

/ / updat e UI ( _menus, t ool bar s, et c. )
_desi gner . Cr eat eFi el dI nf o : = ni l ;
Updat eUI ;
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
' f or mat t ool bar
Pr i vat e Sub _t bFor mat _But t onCl i ck( sender As Obj ect ,
e As Tool Bar But t onCl i ckEvent Ar gs)
' get r eady t o wor k
Di msel As Fi el d( ) = _desi gner . Sel ect edFi el ds
Debug. Asser t ( ( sel . Lengt h > 0) )

' get r ef er ence f i el d ( l ast i n t he sel ect i on)
Di mr ef Fl d As Fi el d = CType( sel ( ( sel . Lengt h - 1) ) , Fi el d)

' save undo i nf o
_desi gner . UndoSt ack. SaveSt at e( )

' al i gn f i el ds
I f e. But t on = _bt nAl i gnLef t Then
Di mi As I nt eger
For i = 0 To sel . Lengt h - 1
sel ( i ) . Lef t = r ef Fl d. Lef t
Next i
El se
I f e. But t on = _bt nAl i gnCent er Then
Di mmi d As Doubl e = r ef Fl d. Lef t + r ef Fl d. Wi dt h / 2
Di mi As I nt eger
For i = 0 To sel . Lengt h - 1
sel ( i ) . Lef t = mi d - sel ( i ) . Wi dt h / 2
Next i
El se
60 Object Reference

I f e. But t on = _bt nAl i gnRi ght Then
Di mr i ght As Doubl e = r ef Fl d. Lef t + r ef Fl d. Wi dt h
Di mi As I nt eger
For i = 0 To sel . Lengt h - 1
sel ( i ) . Lef t = r i ght - sel ( i ) . Wi dt h
Next i
El se
I f e. But t on = _bt nAl i gnTop Then
Di mi As I nt eger
For i = 0 To sel . Lengt h - 1
sel ( i ) . Top = r ef Fl d. Top
Next i
El se
I f e. But t on = _bt nAl i gnMi ddl e Then
Di mmi d As Doubl e = r ef Fl d. Top + r ef Fl d. Hei ght / 2
Di mi As I nt eger
For i = 0 To sel . Lengt h - 1
sel ( i ) . Top = mi d - sel ( i ) . Hei ght / 2
Next i
El se
I f e. But t on = _bt nAl i gnBot t omThen
Di mbot t omAs Doubl e = r ef Fl d. Top + r ef Fl d. Hei ght
Di mi As I nt eger
For i = 0 To sel . Lengt h - 1
sel ( i ) . Top = bot t om- sel ( i ) . Hei ght
Next i
End I f
End I f ' show t he changes
End I f
End I f
End I f
End I f
_desi gner . Ref r esh( )
Updat eUI ( )
End Sub ' _t bFor mat _But t onCl i ck
C#
/ / f or mat t ool bar
pr i vat e voi d _t bFor mat _But t onCl i ck( obj ect sender ,
Tool Bar But t onCl i ckEvent Ar gs e)
{
/ / get r eady t o wor k
Fi el d[ ] sel = _desi gner . Sel ect edFi el ds;
Debug. Asser t ( sel . Lengt h > 0) ;

/ / get r ef er ence f i el d ( l ast i n t he sel ect i on)
Fi el d r ef Fl d = ( Fi el d) sel [ sel . Lengt h- 1] ;

/ / save undo i nf o
_desi gner . UndoSt ack. SaveSt at e( ) ;

/ / al i gn f i el ds
i f ( e. But t on == _bt nAl i gnLef t )
{
f or ( i nt i = 0; i < sel . Lengt h; i ++)
sel [ i ] . Lef t = r ef Fl d. Lef t ;
}
el se i f ( e. But t on == _bt nAl i gnCent er )
{
doubl e mi d = r ef Fl d. Lef t + r ef Fl d. Wi dt h/ 2;
f or ( i nt i = 0; i < sel . Lengt h; i ++)
sel [ i ] . Lef t = mi d - sel [ i ] . Wi dt h/ 2;
}
el se i f ( e. But t on == _bt nAl i gnRi ght )
SelectedFields Property 61

{
doubl e r i ght = r ef Fl d. Lef t + r ef Fl d. Wi dt h;
f or ( i nt i = 0; i < sel . Lengt h; i ++)
sel [ i ] . Lef t = r i ght - sel [ i ] . Wi dt h;
}
el se i f ( e. But t on == _bt nAl i gnTop)
{
f or ( i nt i = 0; i < sel . Lengt h; i ++)
sel [ i ] . Top = r ef Fl d. Top;
}
el se i f ( e. But t on == _bt nAl i gnMi ddl e)
{
doubl e mi d = r ef Fl d. Top + r ef Fl d. Hei ght / 2;
f or ( i nt i = 0; i < sel . Lengt h; i ++)
sel [ i ] . Top = mi d - sel [ i ] . Hei ght / 2;
}
el se i f ( e. But t on == _bt nAl i gnBot t om)
{
doubl e bot t om= r ef Fl d. Top + r ef Fl d. Hei ght ;
f or ( i nt i = 0; i < sel . Lengt h; i ++)
sel [ i ] . Top = bot t om- sel [ i ] . Hei ght ;
}

/ / show t he changes
_desi gner . Ref r esh( ) ;
Updat eUI ( ) ;
}
Delphi
/ / f or mat t ool bar
pr ocedur e _t bFor mat _But t onCl i ck( sender : Syst em. Obj ect ; e:
Tool Bar But t onCl i ckEvent Ar gs) ;
var
sel : ar r ay of Fi el d;
r ef Fl d: Fi el d;
i : I nt eger ;
r i ght , mi d: doubl e;
begi n
/ / get r eady t o wor k
sel : = _desi gner . Sel ect edFi el ds;
Debug. Asser t ( sel . Lengt h > 0) ;

/ / get r ef er ence f i el d ( l ast i n t he sel ect i on)
r ef Fl d : = Fi el d( sel [ sel . Lengt h - 1] ) ;

/ / save undo i nf o
_desi gner . UndoSt ack. SaveSt at e;

/ / al i gn f i el ds
I f e. But t on = _bt nAl i gnLef t Then
f or i : = 0 To sel . Lengt h - 1 do
sel [ i ] . Lef t : = r ef Fl d. Lef t
el se
I f e. But t on = _bt nAl i gnCent er Then
mi d : = r ef Fl d. Lef t + r ef Fl d. Wi dt h / 2;
f or i : = 0 t o sel . Lengt h - 1 do
sel [ i ] . Lef t = mi d - sel [ i ] . Wi dt h / 2
El se
I f e. But t on = _bt nAl i gnRi ght Then
r i ght : = r ef Fl d. Lef t + r ef Fl d. Wi dt h;
f or i : = 0 t o sel . Lengt h - 1 do
sel [ i ] . Lef t : = r i ght - sel [ i ] . Wi dt h
El se
I f e. But t on = _bt nAl i gnTop Then
62 Object Reference

f or i : = 0 t o sel . Lengt h - 1 do
sel [ i ] . Top : = r ef Fl d. Top
El se
I f e. But t on = _bt nAl i gnMi ddl e Then
mi d : = r ef Fl d. Top + r ef Fl d. Hei ght / 2;
f or i : = 0 t o sel . Lengt h - 1 do
sel [ i ] . Top : = mi d - sel [ i ] . Hei ght / 2
El se
I f e. But t on = _bt nAl i gnBot t omThen
bot t om: = r ef Fl d. Top + r ef Fl d. Hei ght ;
f or i : = 0 t o sel . Lengt h - 1 do
sel [ i ] . Top = bot t om- sel [ i ] . Hei ght
_desi gner . Ref r esh;
Updat eUI ;
end; / / _t bFor mat _But t onCl i ck
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;}
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
' handl e cl i pboar d commands ( f or r epor t s and f i el ds)
Pr i vat e Sub Handl eCl i pboar d( cmd As Tool Bar But t on)
' save undo st at e f or al l but copy
I f cmd <> _bt nCopy Then
_desi gner . UndoSt ack. SaveSt at e( )
_di r t y = Tr ue
End I f

' execut e command
Di mcl i p As Cl i pboar dHandl er = _desi gner . Cl i pboar dHandl er
I f cmd = _bt nCut Then
cl i p. Cut ( )
End I f
I f cmd = _bt nCopy Then
cl i p. Copy( )
End I f
I f cmd = _bt nPast e Then
cl i p. Past e( )
End I f
I f cmd = _bt nDel et e Then
cl i p. Del et e( )
End I f
' updat e UI when done
Updat eUI ( )
End Sub ' Handl eCl i pboar d
C#
/ / handl e cl i pboar d commands ( f or r epor t s and f i el ds)
pr i vat e voi d Handl eCl i pboar d( Tool Bar But t on cmd)
{
/ / save undo st at e f or al l but copy
i f ( cmd ! = _bt nCopy)
{
_desi gner . UndoSt ack. SaveSt at e( ) ;
_di r t y = t r ue;
}

/ / execut e command
Cl i pboar dHandl er cl i p = _desi gner . Cl i pboar dHandl er ;
i f ( cmd == _bt nCut ) cl i p. Cut ( ) ;
i f ( cmd == _bt nCopy) cl i p. Copy( ) ;
64 Object Reference

i f ( cmd == _bt nPast e) cl i p. Past e( ) ;
i f ( cmd == _bt nDel et e) cl i p. Del et e( ) ;

/ / updat e UI when done
Updat eUI ( ) ;
}
Delphi
/ / handl e cl i pboar d commands ( f or r epor t s and f i el ds)
pr ocedur e Cl ass1. Handl eCl i pboar d( cmd: Tool Bar But t on) ;
var
cl i p: Cl i pboar dHandl er ;
begi n

/ / save undo st at e f or al l but copy
i f ( cmd <> _bt nCopy) t hen
begi n
_desi gner . UndoSt ack. SaveSt at e;
_di r t y : = Tr ue;
end;

/ / execut e command
cl i p : = _desi gner . Cl i pboar dHandl er ;
i f ( cmd = _bt nCut ) t hen
cl i p. Cut ;
i f ( cmd = _bt nCopy) t hen
cl i p. Copy;
i f ( cmd = _bt nPast e) t hen
cl i p. Past e;
i f ( cmd = _bt nDel et e) t hen
cl i p. Del et e;

/ / updat e UI when done
Updat eUI ;
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
' updat e UI ( _menus, t ool bar s, et c. )
Pr i vat e Sub Updat eUI ( )
_bt nUndo. Enabl ed = _desi gner . UndoSt ack. CanUndo
_bt nRedo. Enabl ed = _desi gner . UndoSt ack. CanRedo

_bt nCut . Enabl ed =
_bt nCopy. Enabl ed =
_bt nDel et e. Enabl ed = _desi gner . Cl i pboar dHandl er . CanCut
_bt nPast e. Enabl ed = _desi gner . Cl i pboar dHandl er . CanPast e
End Sub
C#
/ / updat e UI ( _menus, t ool bar s, et c. )
pr i vat e voi d Updat eUI ( )
{
_bt nUndo. Enabl ed = _desi gner . UndoSt ack. CanUndo;
_bt nRedo. Enabl ed = _desi gner . UndoSt ack. CanRedo;

_bt nCut . Enabl ed =
_bt nCopy. Enabl ed =
HitTest Method 65

_bt nDel et e. Enabl ed = _desi gner . Cl i pboar dHandl er . CanCut ;
_bt nPast e. Enabl ed = _desi gner . Cl i pboar dHandl er . CanPast e;
}
Delphi
/ / updat e UI ( _menus, t ool bar s, et c. )
pr ocedur e Cl ass1. Updat eUI ;
begi n
_bt nUndo. Enabl ed : = _desi gner . UndoSt ack. CanUndo;
_bt nRedo. Enabl ed : = _desi gner . UndoSt ack. CanRedo;
_bt nPast e. Enabl ed : = _desi gner . Cl i pboar dHandl er . CanPast e;

_bt nCut . Enabl ed : = _desi gner . Cl i pboar dHandl er . CanCut ;
_bt nCopy. Enabl ed : = _bt nCut . Enabl ed;
_bt nDel et e. Enabl ed : = _bt nCut . Enabl ed;
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
' handl e cont ext - sensi t i ve desi gner menu
Pr i vat e Sub _desi gner Menu_Popup( ByVal sender As Obj ect , ByVal e As
Syst em. Event Ar gs)
' make sur e t he desi gner has t he f ocus
_desi gner . Focus( )

' get f i el d under t he mouse
Di mpt As Poi nt = _desi gner . Poi nt ToCl i ent ( Cont r ol . MousePosi t i on)
Di mht i As Hi t Test I nf o = _desi gner . Hi t Test ( pt . X, pt . Y)
66 Object Reference

Di mf As Fi el d = ht i . Fi el d

' no f i el d t her e? cl ear sel ect i on
I f f I s Not hi ng Then
_desi gner . Sel ect edFi el ds = Not hi ng
End I f

' f i el d not i n sel ect i on? t hen sel ect i t
I f Not f I s Not hi ng Then
Di msel ect ed As Bool ean = Fal se
Di msf As Fi el d
For Each sf I n _desi gner . Sel ect edFi el ds
I f sf <> f Then
cont i nue
End I f
sel ect ed = Tr ue
Exi t For
Next

I f Not sel ect ed Then
f
End I f

End I f

' show cut / copy/ del et e onl y when a f i el d was cl i cked
_menuCopyFi el d. Vi si bl e =
_menuCut Fi el d. Vi si bl e =
_menuDel et eFi el d. Vi si bl e = ( f <> Not hi ng)
End Sub
C#
/ / handl e cont ext - sensi t i ve desi gner menu
pr i vat e voi d _desi gner Menu_Popup( obj ect sender , Syst em. Event Ar gs e)
{
/ / make sur e t he desi gner has t he f ocus
_desi gner . Focus( ) ;

/ / get f i el d under t he mouse
Poi nt pt = _desi gner . Poi nt ToCl i ent ( Cont r ol . MousePosi t i on) ;
Hi t Test I nf o ht i = _desi gner . Hi t Test ( pt . X, pt . Y) ;
Fi el d f = ht i . Fi el d;

/ / no f i el d t her e? cl ear sel ect i on
i f ( f == nul l )
_desi gner . Sel ect edFi el ds = nul l ;

/ / f i el d not i n sel ect i on? t hen sel ect i t
i f ( f ! = nul l )
{
bool sel ect ed = f al se;
f or each ( Fi el d sf i n _desi gner . Sel ect edFi el ds)
{
i f ( sf ! = f ) cont i nue;
sel ect ed = t r ue;
br eak;
}

i f ( ! sel ect ed)
_desi gner . Sel ect edFi el ds = new Fi el d[ ] { f };
}

/ / show cut / copy/ del et e onl y when a f i el d was cl i cked
_menuCopyFi el d. Vi si bl e =
HitTest Method 67

_menuCut Fi el d. Vi si bl e =
_menuDel et eFi el d. Vi si bl e = ( f ! = nul l ) ;
}
Delphi
/ / handl e cont ext - sensi t i ve desi gner menu
pr ocedur e _desi gner Menu_Popup( sender : Syst em. Obj ect ; e:
Syst em. Event Ar gs) ;
var
pt : Poi nt ;
ht i : Hi t Test I nf o;
f : Fi el d;
sel ect ed: Bool ean;
sf : Fi el d;
i : I nt eger ;
f l ds: ar r ay of f i el d;
begi n
/ / make sur e t he desi gner has t he f ocus
_desi gner . Focus;

/ / get f i el d under t he mouse
pt : = _desi gner . Poi nt ToCl i ent ( Cont r ol . MousePosi t i on) ;
ht i : = _desi gner . Hi t Test ( pt . X, pt . Y) ;
f : = ht i . Fi el d;

/ / no f i el d t her e? cl ear sel ect i on
i f f = ni l t hen
begi n
_desi gner . Sel ect edFi el ds : = ni l ;
end
el se
begi n
/ / f i el d not i n sel ect i on? t hen sel ect i t
sel ect ed : = Fal se;
f or i : = 0 t o _desi gner . Sel ect edFi el ds. Count - 1 do
begi n
sf : = _desi gner . Sel ect edFi el ds[ i ] ;
i f ( sf <> f ) t hen
cont i nue;
sel ect ed : = t r ue;
br eak;
end;

i f not sel ect ed t hen
begi n
Set Lengt h( f l ds, 1) ;
f l ds[ 0] : = f ;
_desi gner . Sel ect edFi el ds : = f l ds;
end;

end;

/ / show cut / copy/ del et e onl y when a f i el d was cl i cked
_menuCopyFi el d. Vi si bl e : = f <> ni l ;
_menuCut Fi el d. Vi si bl e : = f <> ni l ;
_menuDel et eFi el d. Vi si bl e : = f <> ni l ;
end;
See Also
C1ReportDesigner Control (page 43)
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
' pr oper t y val ue changed, updat e desi gner
Pr i vat e Sub _pr opGr i d_Pr oper t yVal ueChanged( s As Obj ect , e As
Pr oper t yVal ueChangedEvent Ar gs)

' show changes i n t he desi gner
_desi gner . Ref r esh( )

' r emember t he document i s di r t y
I f Not _di r t y Then
_di r t y = Tr ue
Updat eUI ( )
End I f
End Sub ' _pr opGr i d_Pr oper t yVal ueChanged
C#
/ / pr oper t y val ue changed, updat e desi gner
pr i vat e voi d _pr opGr i d_Pr oper t yVal ueChanged( obj ect s,
Pr oper t yVal ueChangedEvent Ar gs e)
{

/ / show changes i n t he desi gner
_desi gner . Ref r esh( ) ;

/ / r emember t he document i s di r t y
i f ( ! _di r t y)
{
_di r t y = t r ue;
Updat eUI ( ) ;
}
}


ToPixelsX Method 69

Delphi
/ / pr oper t y val ue changed, updat e desi gner
pr ocedur e Cl ass1. _pr opGr i d_Pr oper t yVal ueChanged( s: Syst em. Obj ect ; e:
Pr oper t yVal ueChangedEvent Ar gs) ;
begi n
/ / show changes i n t he desi gner
_desi gner . Ref r esh;
/ / r emember t he document i s di r t y
i f ( not _di r t y)
begi n
_di r t y : = t r ue;
Updat eUI ;
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;
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)
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)
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)




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

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
Pr i vat e Sub _desi gner _Val uesChanged( sender As Obj ect , e As
Syst em. Event Ar gs)
_di r t y = Tr ue
_pr opGr i d. Ref r esh( )
CreateFieldEventArgs class 75

_desi gner . Cr eat eFi el dI nf o = Not hi ng
Updat eUI ( )
End Sub ' _desi gner _Val uesChanged
C#
pr i vat e voi d _desi gner _Val uesChanged( obj ect sender , Syst em. Event Ar gs e)
{
_di r t y = t r ue;
_pr opGr i d. Ref r esh( ) ;
_desi gner . Cr eat eFi el dI nf o = nul l ;
Updat eUI ( ) ;
}
Delphi
pr ocedur e Cl ass1. _desi gner _Val uesChanged( sender : Syst em. Obj ect ; e:
Syst em. Event Ar gs) ;
begi n
_di r t y : = Tr ue;
_pr opGr i d. Ref r esh;
_desi gner . Cr eat eFi el dI nf o : = ni l ;
Updat eUI ;
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).
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);

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
' handl e cl i pboar d commands ( f or r epor t s and f i el ds)
Pr i vat e Sub Handl eCl i pboar d( ByVal cmd As Tool Bar But t on)
' save undo st at e f or al l but copy
I f cmd <> _bt nCopy Then
_desi gner . UndoSt ack. SaveSt at e( )
_di r t y = Tr ue
End I f

' execut e command
Di mcl i p As Cl i pboar dHandl er = _desi gner . Cl i pboar dHandl er
I f cmd = _bt nCut Then
cl i p. Cut ( )
End I f
I f cmd = _bt nCopy Then
cl i p. Copy( )
End I f
I f cmd = _bt nPast e Then
cl i p. Past e( )
End I f
I f cmd = _bt nDel et e Then
cl i p. Del et e( )
End I f

' updat e UI when done
Updat eUI ( )
End Sub

' updat e UI ( _menus, t ool bar s, et c. )
Pr i vat e Sub Updat eUI ( )
_bt nUndo. Enabl ed = _desi gner . UndoSt ack. CanUndo
_bt nRedo. Enabl ed = _desi gner . UndoSt ack. CanRedo

_bt nCut . Enabl ed =
_bt nCopy. Enabl ed =
_bt nDel et e. Enabl ed = _desi gner . Cl i pboar dHandl er . CanCut
_bt nPast e. Enabl ed = _desi gner . Cl i pboar dHandl er . CanPast e
End Sub
C#
/ / handl e cl i pboar d commands ( f or r epor t s and f i el ds)
pr i vat e voi d Handl eCl i pboar d( Tool Bar But t on cmd)
{
78 Object Reference

/ / save undo st at e f or al l but copy
i f ( cmd ! = _bt nCopy)
{
_desi gner . UndoSt ack. SaveSt at e( ) ;
_di r t y = t r ue;
}

/ / execut e command
Cl i pboar dHandl er cl i p = _desi gner . Cl i pboar dHandl er ;
i f ( cmd == _bt nCut ) cl i p. Cut ( ) ;
i f ( cmd == _bt nCopy) cl i p. Copy( ) ;
i f ( cmd == _bt nPast e) cl i p. Past e( ) ;
i f ( cmd == _bt nDel et e) cl i p. Del et e( ) ;

/ / updat e UI when done
Updat eUI ( ) ;
}

/ / updat e UI ( _menus, t ool bar s, et c. )
pr i vat e voi d Updat eUI ( )
{
_bt nUndo. Enabl ed = _desi gner . UndoSt ack. CanUndo;
_bt nRedo. Enabl ed = _desi gner . UndoSt ack. CanRedo;

_bt nCut . Enabl ed =
_bt nCopy. Enabl ed =
_bt nDel et e. Enabl ed = _desi gner . Cl i pboar dHandl er . CanCut ;
_bt nPast e. Enabl ed = _desi gner . Cl i pboar dHandl er . CanPast e;
}
Delphi
/ / handl e cl i pboar d commands ( f or r epor t s and f i el ds)
pr ocedur e Cl ass1. Handl eCl i pboar d( cmd: Tool Bar But t on) ;
var
cl i p: Cl i pboar dHandl er ;
begi n

/ / save undo st at e f or al l but copy
i f ( cmd <> _bt nCopy) t hen
begi n
_desi gner . UndoSt ack. SaveSt at e;
_di r t y : = Tr ue;
end;

/ / execut e command
cl i p : = _desi gner . Cl i pboar dHandl er ;
i f ( cmd = _bt nCut ) t hen
cl i p. Cut ;
i f ( cmd = _bt nCopy) t hen
cl i p. Copy;
i f ( cmd = _bt nPast e) t hen
cl i p. Past e;
i f ( cmd = _bt nDel et e) t hen
cl i p. Del et e;

/ / updat e UI when done
Updat eUI ;
end;

/ / updat e UI ( _menus, t ool bar s, et c. )
pr ocedur e Cl ass1. Updat eUI ;
begi n
_bt nUndo. Enabl ed : = _desi gner . UndoSt ack. CanUndo;
_bt nRedo. Enabl ed : = _desi gner . UndoSt ack. CanRedo;
CanCut Property 79


_bt nPast e. Enabl ed : = _desi gner . Cl i pboar dHandl er . CanPast e;
_bt nCut . Enabl ed : = _bt nPast e. Enabl ed;
_bt nCopy. Enabl ed : = _bt nPast e. Enabl ed;
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)
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 ( )
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.
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)
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
_desi gner . UndoSt ack. Enabl ed = Tr ue ' << mor e f unct i onal i t y, l ess speed
_desi gner . UndoSt ack. Enabl ed = Fal se ' << no undo/ r edo, mor e speed
C#
_desi gner . UndoSt ack. Enabl ed = t r ue; / / << mor e f unct i onal i t y, l ess
speed
_desi gner . UndoSt ack. Enabl ed = f al se; / / << no undo/ r edo, mor e speed
Delphi
_desi gner . UndoSt ack. Enabl ed : = Tr ue; / / << mor e f unct i onal i t y, l ess
speed
_desi gner . UndoSt ack. Enabl ed : = Fal se; / / << no undo/ r edo, mor e 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 ( )

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)



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;
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;}

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;

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.

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;}

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;}
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).
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)
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)
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;}

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.

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

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.
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)
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)
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)
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)
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
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

S-ar putea să vă placă și