Style Property - To Parent Directory

Transcription

Style Property - To Parent Directory
User’s Guide
Copyright © 1987-2005 ComponentOne LLC. All rights reserved.
Corporate Headquarters
ComponentOne LLC
4516 Henry Street
Suite 500
Pittsburgh, PA 15213 USA
Internet:
[email protected]
Web site:
http://www.componentone.com
Sales
E-mail: [email protected]
Telephone: 1.800.858.2739 or 1.412.681.4343 (Pittsburgh, PA USA Office)
Technical Support
See Technical Support in this manual for information on obtaining technical support.
Trademarks
ComponentOne FlexGrid for .NET and the ComponentOne FlexGrid for .NET logo are trademarks, and ComponentOne
is a registered trademark of ComponentOne LLC. All other trademarks used herein are the properties of their respective
owners.
Warranty
ComponentOne warrants that the original CD (or diskettes) are free from defects in material and workmanship, assuming
normal use, for a period of 90 days from the date of purchase. If a defect occurs during this time, you may return the
defective CD (or disk) to ComponentOne, along with a dated proof of purchase, and ComponentOne will replace it at no
charge. After 90 days, you can obtain a replacement for a defective CD (or disk) by sending it and a check for $25 (to cover
postage and handling) to ComponentOne.
Except for the express warranty of the original CD (or disks) set forth here, ComponentOne makes no other warranties,
express or implied. Every attempt has been made to ensure that the information contained in this manual is correct as of
the time it was written. We are not responsible for any errors or omissions. ComponentOne’s liability is limited to the
amount you paid for the product. ComponentOne is not liable for any special, consequential, or other damages for any
reason.
Copying and Distribution
While you are welcome to make backup copies of the software for your own use and protection, you are not permitted to
make copies for the use of anyone else. We put a lot of time and effort into creating this product, and we appreciate your
support in seeing that it is used by licensed users only. Please read License Agreement and Licensing sections in this
manual before copying and redistributing any ComponentOne FlexGrid for .NET files.
· iii
Table of Contents
Table of Contents ....................................................................................................................... iii
Welcome to ComponentOne FlexGrid for .NET..................................................................... 1
Overview ................................................................................................................................. 1
What is New in Version 2.5................................................................................................... 2
Installation............................................................................................................................... 3
Adding the C1FlexGrid Component to the Toolbox ......................................................... 3
END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE.............. 4
Licensing FAQs..................................................................................................................... 11
Redistributable Files............................................................................................................. 14
Technical Support................................................................................................................. 14
Namespaces........................................................................................................................... 15
Using the C1FlexGrid Control ................................................................................................. 19
Layout .................................................................................................................................... 20
Selection ................................................................................................................................. 22
Data Binding ......................................................................................................................... 23
Storing and Retrieving Data ............................................................................................... 24
Cell Ranges............................................................................................................................ 25
Cell Images ............................................................................................................................ 26
Formatting Cells ................................................................................................................... 26
Editing Cells .......................................................................................................................... 34
Outlining and Summarizing ............................................................................................... 45
Merging Cells........................................................................................................................ 52
Saving, Loading, and Printing ............................................................................................ 57
FlexGrid Property Groups .................................................................................................. 61
FlexGrid Samples ....................................................................................................................... 63
Visual Basic Samples............................................................................................................ 63
C# Samples............................................................................................................................ 66
ComponentOne FlexGrid for Mobile Devices Samples .................................................. 70
FlexGrid Tutorials ...................................................................................................................... 71
Edit Tutorial .......................................................................................................................... 71
Outline Tutorial .................................................................................................................... 81
Data Analysis Tutorial ......................................................................................................... 91
C1FlexGrid Reference.............................................................................................................. 101
C1FlexGrid Class ................................................................................................................ 101
CellRange Struct ................................................................................................................. 275
HitTestInfo class ................................................................................................................. 285
RowCollection class ........................................................................................................... 287
ColumnCollection class ..................................................................................................... 297
Row Class ............................................................................................................................ 306
Column Class ...................................................................................................................... 320
CellStyleCollection class.................................................................................................... 345
CellStyle class...................................................................................................................... 356
CellBorder class .................................................................................................................. 372
Node class............................................................................................................................ 374
GridGlyphs Class ............................................................................................................... 384
iv ·
GridTree class...................................................................................................................... 385
GridPrinter Class ................................................................................................................ 391
C1FlexGrid Enumerations................................................................................................. 397
C1FlexGrid Interfaces ........................................................................................................ 423
C1FlexGridClassic Control ..................................................................................................... 427
C1FlexGridClassic Reference ................................................................................................. 429
C1FlexGridClassic Class .................................................................................................... 429
Cell Class ............................................................................................................................. 539
C1FlexGridClassic Enumerations..................................................................................... 540
Index............................................................................................................................................ 555
Overview · 1
Welcome to ComponentOne FlexGrid
for .NET
ComponentOne FlexGrid™ for .NET includes C1FlexGrid, a full-featured grid control that allows you
to display, format, and edit data quickly and easily.
FlexGrid for .NET incorporates the latest in data-binding technology -- ADO.NET and ComponentOne
DataObjects -- integrating seamlessly with the Microsoft .NET Framework.
ComponentOne custom controls are innovative, flexible, and powerful. If you like FlexGrid, make sure
you check out our other award-winning products, which are described in the ComponentOne Products
section.
ComponentOne has a user-friendly distribution policy. We want every programmer to obtain a copy of
FlexGrid for .NET 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 FlexGrid for .NET will
display a ComponentOne banner every time they are loaded to remind developers to license the product.
We are confident that you will like ComponentOne FlexGrid For .NET. If you have any suggestions or
ideas for new features that you'd like to see included in a future version, or ideas for new controls, 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
Overview
The ComponentOne FlexGrid For .NET package consists of two controls:
C1FlexGrid Control
C1FlexGrid is a powerful, full-featured grid. It provides new ways to display, edit, format, organize,
summarize, and print tabular data. It will read and write grids from and to compressed binary files or
text files (compatible with Microsoft Access and Excel). C1FlexGrid provides all the basics plus advanced
features such as outline trees, sorting, cell merging, masked editing, translated combo and image lists,
and automatic data aggregation.
C1FlexGrid can be used in bound mode, where it displays data from any .Net data source, including
ADO.Net and ComponentOne DataObjects, or in unbound mode, where the grid itself manages the data.
2 · Welcome to ComponentOne FlexGrid for .NET
C1FlexGridClassic Control
C1FlexGridClassic is a control that derives from C1FlexGrid and provides an object model that is
virtually 100% identical to the VSFlexGrid ActiveX control. C1FlexGridClassic was developed to allow
easy migration of existing VSFlexGrid projects.
The source code for C1FlexGridClassic is provided as a sample. You can use it as a reference that shows
how to use the C1FlexGrid control as a base class in the development of custom grid controls.
What is New in Version 2.5
Version 2.5 of the C1FlexGrid includes two major new features and several useful additions.
Support for Custom Editors
You can now use any .NET control as a grid editor. Simply assign an instance of the control to a column's
Editor property and the grid will use the control to edit cells in that column.
You can customize the behavior of the custom editors by implementing the IC1EmbeddedEditor interface
(defined in C1Common.dll) thereby improving the integration between the grid and external editors. All
controls in the C1Input library now implement IC1EmbeddedEditor and can be used as grid editors (no
code is required).
We also provide samples that show how you can use UIType editor classes as grid editors (see the
"CustomEditors" in our on-line sample library).
Save and Load Microsoft™ Excel files
The SaveGrid and LoadGrid methods now have overloaded versions that allow you to save and load
Microsoft Excel files (xls). The grid uses pure .NET code and does not require Excel to be installed on the
computer.
There are also specialized methods called SaveExcel and LoadExcel that provide additional control,
allowing you to save grids into specific sheets of Excel workbooks.
Automatic Clipboard Support
The new AutoClipboard property allows the grid to automatically handle the standard clipboard keys to
cut, copy, paste, and delete cell values.
Custom Behavior for Cell Merging and Grouping
The new CustomComparer property allows you to specify an IComparer class used to determine
whether adjacent cells should be merged or grouped.
Easier Access to Data Source Objects
The new Row.DataSource property allows easy access to the row's data source. For example, when the
grid is bound to an ADO.NET DataView, you can easily get the DataViewRow object attached to each
grid row.
More Powerful CellStyle class
The CellStyle class has a new Editor property that allows you to specify custom editors, and a new
Render method that allows you to use the style to paint strings and images into any Graphics object.
Installation · 3
New Events
The grid now fires events before and after the user adds or removes rows, allowing you to monitor or
cancel these actions (BeforeAddRow, AfterAddRow, CancelAddRow, BeforeDeleteRow, and
AfterDeleteRow).
There are also new events to support unbound data columns (GetUnboundValue and
SetUnboundValue).
More Speed
Version 2.5 has several optimizations that make the grid paint and scroll significantly faster than before.
Installation
To install FlexGrid for .NET, run the C1FlexGrid.msi installation file provided in the distribution CD (or
downloaded from the Web), and follow the instructions.
The installation program will create a directory called "ComponentOne Studio.NET" under "Program
Files". This directory will contain the following subdirectories:
bin
Contains copies of all binaries (DLLs, EXEs) in the ComponentOne Visual
Studio.NET package.
Common
Contains support and data files that are used by many of the demo programs.
Demos
Contains demo projects for all Studio components.
Help
Contains online documentation for all Studio components.
C1FlexGrid
Contains samples and tutorials for the C1FlexGrid component.
Other
Samples and tutorials for the other Studio components.
Installing Demonstration Versions
If you wish to try FlexGrid for .NET and do not have a registration key, install the product as usual but
don't provide a registration key. The only difference between unregistered (evaluation) and registered
(purchased) versions of the software is that the unregistered version will display a banner when it starts
executing.
Uninstalling FlexGrid for .NET
To uninstall FlexGrid for .NET, open the Control Panel application, select the "Add or Remove
Programs" option, select FlexGrid for .NET and click the "Remove" button.
Adding the C1FlexGrid Component to the Toolbox
When you install C1FlexGrid, the following new components will appear in the Visual Studio’s toolbox
customization dialog box:
•
C1FlexGrid
•
C1FlexGridClassic
C1FlexGrid is the component that provides new ways to display, edit, format, organize, summarize, and
print tabular data.
The C1FlexGridClassic component allows easy migration of existing VSFlexGrid projects.
4 · Welcome to ComponentOne FlexGrid for .NET
In order to use these components, you must add it 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 the C1FlexGrid and C1FlexGridClassic 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, “C1FlexGrid”.
Select the tab where you want the component to appear. Right-click that tab 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 box for the component belonging
to namespace C1.Win.C1FlexGrid.
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
END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 5
your purchase. To return the product directly to C1, you must obtain 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
6 · Welcome to ComponentOne FlexGrid for .NET
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.
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.
END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 7
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").
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
8 · Welcome to ComponentOne FlexGrid for .NET
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.
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
END-USER LICENSE AGREEMENT FOR COMPONENTONE SOFTWARE · 9
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, endusers, 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.
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
10 · Welcome to ComponentOne FlexGrid for .NET
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 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.
Licensing FAQs · 11
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 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.
12 · Welcome to ComponentOne FlexGrid for .NET
Later, when the component is created at run time, it gets passed the key that was created at design time
and can decide whether to simply accept the key, to throw an exception and fail altogether, or to display
some information reminding the user that the software has not been licensed.
All ComponentOne products are designed to display licensing information if the product is not licensed.
None will throw licensing exceptions and prevent applications from running.
Common Scenarios
Creating components at design time
This is the most common scenario and also the simplest: the user adds one or more controls to the form,
the licensing information is stored in the licenses.licx file, and the component works.
Note that the mechanism is exactly the same for Windows Forms and Web Forms (ASP.NET) projects.
Creating components at run time
This is also a fairly common scenario. You do not need an instance of the component on the form, but
would like to create one or more instances at run time.
In this case, the project will not contain a licenses.licx file (or the file will not contain an appropriate key
for the component) and therefore licensing will fail.
To fix this problem, add an instance of the component to a form in the project. This will create the
licenses.licx file and things will then work as expected. (The component can be removed from the form
after the licenses.licx file has been created).
Inheriting from licensed components
If a component that inherits from a licensed component is created, the licensing information to be stored
in the form is still needed. This can be done in two ways:
1.
Add a LicenseProvider attribute to the component.
This will mark the component as licensed. When a component is added to a form, Visual Studio
will create and manage the licenses.licx file, and the base class will handle the licensing process as
usual. No additional work is needed. For example:
[LicenseProvider(typeof(LicenseProvider))]
class MyGrid: C1.Win.C1FlexGrid.C1FlexGrid
{
// ...
}
2.
Add an instance of the base component to the form.
This will embed the licensing information into the licenses.licx file as in the previous scenario,
and the base component will find it and use it. As before, the extra instance can be deleted after
the licenses.licx file has been created.
Using licensed components in console applications
When building console applications, there are no forms to add components to, and therefore Visual
Studio won't create a licenses.licx file.
Licensing FAQs · 13
In these cases, create a temporary Windows Forms application and add all the desired licensed
components to a form. Then close the Windows Forms application and copy the licenses.licx file into the
console application project.
Make sure the licensex.licx file is configured as an embedded resource. To do this, right-click the
licenses.licx file in the Solution Explorer window and select Properties. In the property window, set the
"Build Action" property to "Embedded Resource".
Using licensed components in Visual C++ applications
It seems there is a bug in VC++ 2003. The licenses.licx is ignored during the build process, therefore the
licensing information is not included in VC++ applications.
To fix this problem, extra steps must be taken to compile the licensing resources and link them to the
project. Note the following:
1.
Build the C++ project as usual. This should create an exe file and also a licenses.licx file with
licensing information in it.
2.
Copy the licenses.licx file from the app directory to the target folder (Debug or Release).
3.
Copy the C1Lc.exe utility and the licensed dlls to the target folder. (Don't use the standard lc.exe,
it has bugs.)
4.
Use C1Lc.exe to compile the licenses.licx file. The command line should look like this:
c1lc /target:MyApp.exe /complist:licenses.licx /i:C1.Win.C1FlexGrid.dll
5.
Link the licenses into the project. To do this, go back to Visual Studio, right-click the project,
select properties, and go to the Linker/Command Line option. Enter the following:
/ASSEMBLYRESOURCE:Debug\MyApp.exe.licenses
6.
Rebuild the executable to include the licensing information in the application.
Troubleshooting
We try very hard to make the licensing mechanism as unobtrusive as possible, but problems may occur
for a number of reasons.
Below is a description of the most common problems and their solutions.
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.
14 · Welcome to ComponentOne FlexGrid for .NET
5.
Open the main form and add an instance of each licensed control.
6.
Check the Solution Explorer window, there should be a licenses.licx file there.
7.
Rebuild the project using the "Rebuild All" option (not just "Rebuild").
I have a licensed version of a ComponentOne product on my web server but the components still
behave as unlicensed.
There is no need to install any licenses on machines used as servers and not used for development.
The components must be licensed on the development machine, therefore the licensing information will
be saved into the executable (exe or dll) when the project is built. After that, the application can be
deployed on any machine, including web servers.
I downloaded a new build of a component that I have purchased, and now I'm getting the splash screen
when I build my projects.
Make sure that the license key is still valid. If you licensed the component over a year ago, your
subscription may have expired. In this case, you have two options:
Option 1 - Renew your subscription to get a new license key.
If you choose this option, you will receive a new key that you can use to license the new components
(from the installation utility or directly from the About Box).
The new subscription will entitle you to a full year of upgrades and to download the latest maintenance
builds directly from http://prerelease.componentone.com/.
Option 2 – Continue to use the components you have.
Subscriptions expire, products do not. You can continue to use the components you received or
downloaded while your subscription was valid.
Redistributable Files
ComponentOne FlexGrid for .NET 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:
•
C1.Common.dll
•
C1.Win.C1Flexgrid.Classic.dll
•
C1.Win.C1Flexgrid.dll
Site licenses are available for groups of multiple developers. Please contact [email protected]
for details.
Technical Support
ComponentOne FlexGrid for .Net 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:
Namespaces · 15
ComponentOne Web site
The ComponentOne Web site at www.componentone.com provides a wealth of information and software
downloads for FlexGrid for .Net users, including:
•
Descriptions of the various support options available through the ComponentOne Service Team.
•
Answers to frequently asked questions (FAQ's) about our products, organized by functionality.
Please consult the FAQ's before contacting us directly, as this can save you time and also
introduce you to other useful information pertaining to our products.
•
Free product updates, which provide you with bug fixes and new features.
Internet e-mail
For technical support through the Internet, e-mail us at:
[email protected]
To help us provide you with the best support, please include the following information when contacting
ComponentOne:
•
Your ComponentOne product serial number.
•
The version and name of your operating system.
•
Your development environment and its version.
For more information on technical support, go to:
www.componentone.com/support
Peer-to-Peer newsgroup
ComponentOne also sponsors peer-to-peer newsgroups for users. ComponentOne does not offer formal
technical support in this newsgroup, but instead sponsors it as a forum for users to post and answer each
other's questions regarding our products. However, ComponentOne may monitor the newsgroups to
ensure accuracy of information and provide comments when necessary. You can access the newsgroup
from the ComponentOne Web site at www.componentone.com/newsgroups.
Namespaces
Namespaces organize the objects defined in an assembly. Assemblies can contain multiple namespaces,
which can in turn contain other namespaces. Namespaces prevent ambiguity and simplify references
when using large groups of objects such as class libraries.
The general namespace for ComponentOne Windows products is C1.Win. The namespace for the
FlexGrid control is C1.Win.C1FlexGrid. The following code fragment shows how to declare a C1FlexGrid
control using the fully qualified name for this class:
•
Visual Basic
Dim flex As C1.Win.C1FlexGrid.C1FlexGrid
•
C#
C1.Win.C1FlexGrid.C1FlexGrid flex;
16 · Welcome to ComponentOne FlexGrid for .NET
•
Delphi
uses C1.Win.C1FlexGrid;
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 Column, you can use it inside your project without
qualification. However, the C1FlexGrid assembly also implements a class called Column. So, if you want
to use the C1FlexGrid class in the same project, you must use a fully qualified reference to make the
reference unique. If the reference is not unique, Visual Studio .NET produces an error stating that the
name is ambiguous. The following code snippet demonstrates how to declare these objects:
•
Visual Basic
' Define a new Column object (custom Column class)
Dim MyCol as Column
' Define a new C1FlexGrid.Column object.
Dim FlexCol as C1.Win.C1FlexGrid.Column
•
C#
// Define a new Column object (custom Column class)
Column MyCol;
// Define a new C1FlexGrid.Column object.
C1.Win.C1FlexGrid.Column FlexCol;
•
Delphi
var
FlexCol: C1.Win.C1FlexGrid.Column;
MyCol: Column;
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 (import 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:
•
Visual Basic
Imports C1Column = C1.Win.C1FlexGrid.Column
Imports MyColumn = MyProject.Column
Dim c1 As C1Column
Dim c2 As MyColumn
•
C#
using C1Column = C1.Win.C1FlexGrid.Column;
using MyColumn = MyProject.Column;
C1Column c1;
MyColumn c2;
Namespaces · 17
•
Delphi
uses C1.Win.C1FlexGrid.Column,
MyProject.Column;
var
c2: MyColumn;
c1: C1Column;
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.
Using the C1FlexGrid Control · 19
Using the C1FlexGrid Control
The C1FlexGrid control allows you to display, edit, group and summarize data in a grid format. The grid
can be bound to a data source or it can manage its own data.
The C1FlexGrid control has a rich object model with the following elements:
The following sections walk you through the main features in the C1FlexGrid control:
Layout
Describes how to set up the grid dimensions and layout.
Selection
Describes the concepts of "current cell" and "selection".
Editing Cells
Describes how to implement simple text editing, drop-down lists and combo
lists, cell buttons, editing masks, and data validation.
20 · Using the C1FlexGrid Control
Formatting Cells
Describes how to customize the appearance of the grid by formatting
numbers, dates, and boolean values, or by changing fonts, colors, alignment,
and pictures for individual cells or ranges.
Merging Cells
Describes how to change the grid display so that cells with similar contents
are merged, creating "grouped" views that highlight relationships in the data.
Outlining and
Summarizing
Describes how to add subtotals to grids and how to build outline trees.
Data Binding
Discusses the basic aspects of ADO/OLEDB and DAO data-binding.
Saving, Loading, and
Printing
Describes how you can save the contents or formatting of a grid and re-load
it later, or exchange grid data with other applications such as Microsoft
Access and Excel. This section also shows how you can print grids.
Property Groups
Presents a map of the main C1FlexGrid properties cross-referenced by
function.
Layout
A C1FlexGrid control consists of rows and columns. The collections of rows and columns is exposed by
the Rows and Cols properties.
When the grid is bound to a data source, the number of rows and columns is determined by how much
data is available in the data source. In unbound mode, you can set them to arbitrary values using the
Count property in the collections. For example, the code below sets the grid dimensions to 500 rows by 10
columns:
•
Visual Basic
fg.Rows.Count = 500
fg.Cols.Count = 10
•
C#
fg.Rows.Count = 500;
fg.Cols.Count = 10;
•
Delphi
fg.Rows.Count := 500;
fg.Cols.Count := 10;
There are two basic types of rows and columns: fixed and scrollable. Fixed rows remain on the top of the
grid when the user scrolls the grid vertically, and fixed columns remain on the left of the grid when the
user scrolls the grid horizontally. Fixed cells are useful for displaying row and column header
information. (The counts returned by the Count property include fixed and scrollable cells)
You can set the number of fixed rows and columns using the Fixed property in the Rows and Cols
collections. For example, the code below creates a grid with two fixed rows and no fixed columns:
•
Visual Basic
fg.Rows.Fixed = 1
fg.Cols.Fixed = 0
•
C#
fg.Rows.Fixed = 1;
fg.Cols.Fixed = 0;
Layout · 21
•
Delphi
fg.Rows.Fixed := 1;
fg.Cols.Fixed := 0;
The Rows and Cols collections also contain methods for inserting, deleting, and moving rows and
columns on the grid. You can use their Item property (an indexer) to access individual elements (rows
and columns) in each collection.
Editing Columns with the C1FlexGrid Column Editor
If you prefer, you can set up the grid columns at design time instead of writing code to do it. Select the
grid in .Net, go to the Properties window and click the ellipsis button next to the Cols property, or rightclick the control and select the Edit Columns… menu. This will bring up the Column Editor shown
below:
In bound mode, the editor can be used to select which fields in the DataSource should be displayed, their
order, column captions, widths, and alignment. In unbound mode, the editor is also used to select column
data types.
The editor allows you to perform the following actions:
1.
Reorder Columns: You can move columns to new positions by dragging them by the header
cells with the mouse.
2.
Adjust Column Widths: You can adjust column widths with the mouse, by dragging the right
edge of the header cells with the mouse. You can also select multiple columns by shift-clicking
the header cells, and then set all column widths at once using the property window. Setting the
column width to –1 restores the default width.
3.
Set Column Properties: Whenever one or more columns are selected, you can see and edit their
properties in the property grid on the left of the editor.
4.
Insert or Remove Columns: Use the toolbar to insert columns before or after the selection (useful
mostly in unbound mode), or to remove columns.
22 · Using the C1FlexGrid Control
5.
Use the Toolbar to Perform Common Tasks: The table below describes the function of the
buttons on the toolbar:
These buttons are toggles that control the property grid. The first one
determines whether the properties for the selected columns should be
displayed in alphabetical or categorized order. The second determines whether
the property grid should display s description for the properties selected.
Undo: Cancels all changes and reverts the grid columns to their original state.
Insert Column: Insert columns to the left or to the right of the selection. These
buttons are enabled only of the grid is not bound to a data source.
Remove Column: Removes the selected column.
Column Width: Make all selected columns have the same width, make them
wider or narrower.
Make Visible: Makes all columns visible. If you change the Visible property of
a column to false, it will be hidden, and therefore you won't be able to select it
with the mouse. Use this button to show all columns so you can select and edit
them.
Alignment: Align column content to the left, center, or right. These buttons only
affect the scrollable area of the grid. To set the alignment for the header
columns, select the columns and set the TextAlignFixed property.
AutoResize: This toggle button determines whether the grid should
automatically resize all columns to fit their contents when the grid is bound to a
data source.
Reload from Datasource: Resets all columns with information from the current
DataSource. This button is useful when the grid is bound to a data source and
you want to start editing from scratch. The button is disabled when the grid is
not bound to a data source.
Selection
The grid has a cursor cell, which displays a focus rectangle while the grid is active. The user may move
the cursor with the keyboard or the mouse, and edit the contents of the cell if the grid is editable.
You can get or set the current cell in code using the Row and Col properties. Setting either of these
properties to –1 hides the cursor.
The grid supports extended selections, rectangular ranges of cells defined by two opposing corners: the
cursor cell and the cell selection cell. You can get or set the selection cell in code using the RowSel and
ColSel properties. You can also set the selection in code using the Select method.
NOTE: When the cursor cell changes, the selection is automatically reset. To create extended selections in
code, either set Row and Col before RowSel and ColSel, or use the Select method.
The appearance of the selection is controlled by the following properties:
1.
FocusRect determines the type of focus rectangle that is drawn to indicate the cursor cell.
2.
HighLight determines when the selection should be highlighted (always, when the control has
the focus, or never)
Data Binding · 23
3.
Styles.HighLight and Styles.Focus are cell styles that determine the appearance of the selection
(font, color, and border).
The type of selection available is determined by the SelectionMode property. By default, the grid
supports regular range selections. You can modify this behavior to prevent extended selections, to select
by row, by column, or in listbox mode (listbox mode allows you to select individual rows).
When using the listbox selection mode, you can get or set the selection status for individual rows using
the Rows(index).Selected property. You can also retrieve a collection of selected rows using the
Rows.Selected property. For example, the code below selects all rows that satisfy a condition:
•
Visual Basic
fg.SelectionMode = SelectionModeEnum.ListBox
Dim index As Integer
For index = fg.Rows.Fixed To fg.Rows.Count – 1
If Val(fg(index, "Sales")) > 80000 Then
fg.Rows(index).Selected = True
End If
Next
Console.WriteLine("There are now {0} rows selected", _
fg.Rows.Selected.Count)
•
C#
fg.SelectionMode = SelectionModeEnum.ListBox;
for (int index = fg.Rows.Fixed ; index < fg.Rows.Count; index++)
{
if ( Val(fg(index, "Sales")) > 80000 ) {
fg.Rows(index).Selected = true;
}
}
Console.WriteLine("There are now {0} rows selected",
fg.Rows.Selected.Count);
•
Delphi
var
index: Integer;
begin
fg.SelectionMode := SelectionModeEnum.ListBox;
while (index <= fg.Rows.Count) do
begin
if (Val(fg(index, 'Sales')) > 80000) then
fg.Rows(index).Selected := True;
Inc(index);
end;
Console.WriteLine('There are now {0} rows selected',
fg.Rows.Selected.Count);
end;
Data Binding
Data binding is a process that allows one or more data consumers to be connected to a data provider in a
synchronized manner. If you move the cursor on a data-bound grid, other controls connected to the same
data source will change to reflect the new current record. If you edit a value on a data-bound grid, other
controls connected to the same data source will change to reflect the new value.
24 · Using the C1FlexGrid Control
C1FlexGrid supports data binding to ADO.NET data source objects such as DataTable, DataView,
DataSet, and DataViewManager.
C1FlexGrid also supports data binding to ComponentOne DataObjects components such as
C1ExpressTable, C1ExpressVew, C1ExpressConnection, C1DataView, C1DataTableSource and
C1DataSet.
To bind the grid to a data source, assign the data source object to the grid's DataSource property. If the
data source object contains more than one table, you must also set the DataMember property a string that
specifies which table should be used.
Alternatively, you can assign both properties simultaneously with a single call to the SetDataBinding
method.
When you assign a new data source to the grid, it will automatically refresh its columns to bind to the
columns available in the data source. You can then customize the columns by moving, hiding, or deleting
them. You can also set column properties such as their Width, EditMask and Format.
For an example of reordering the grid columns after binding to a data source, see the "ColumnOrder"
sample in our on-line sample library.
For details about creating ADO.Net data source objects, please refer to the .NET Framework
documentation.
For details about using ComponentOne DataObjects, see the C1DataObjects documentation included in
the ComponentOne Studio for .NET.
Storing and Retrieving Data
The C1FlexGrid can be used in bound or unbound mode. In bound mode, the grid is connected to a data
source, and all the data displayed on the grid comes from the data source. In this mode, changing data on
the grid changes it in the underlying data source. In unbound mode, the grid manages its own data
source.
In either bound or unbound modes, the easiest way to access data in the C1FlexGrid is using the Row
and Column indexers. The indexers allow you to specify a cell in a row or column from which to get or
set the data stored there. For example, the following code selects the data in the second cell of a row:
•
Visual Basic
Row(2).Selected = True
•
C#
Row[2].Selected = true;
•
Delphi
Row[2].Selected := true;
The Item property is another easy way to access data in the C1FlexGrid. The Item property is an indexer
that takes row and column indices and gets or sets the data stored in the cell. (You can also use column
names as indices). For example, the following code stores row numbers in the first grid column:
•
Visual Basic
Dim r As Integer
For r = fg.Rows.Fixed To fg.Rows.Count – 1
fg(r, 0) = r
Next
Cell Ranges · 25
•
C#
int r;
for ( r = fg.Rows.Fixed ; r <= fg.Rows.Count – 1) {
fg[r, 0] = r;
}
•
Delphi
var
r: Integer;
begin
r := fg.Rows.Fixed;
while (r < fg.Rows.Count) do
begin
fg[r, 0] := r;
r := r + 1;
end;
end;
When you assign a value to a cell, the grid tries to convert that value into the column's specified
DataType. If the conversion fails, the grid fires the GridError event and does not change the cell. You can
override this behavior using the SetData method and setting the coerce parameter to false.
When you retrieve data using the indexers, the grid returns the actual data stored in the cell. To retrieve a
string containing the formatted version of the data (what the grid displays to the user), use the
GetDataDisplay method.
You can also set and retrieve the contents of the selection using the Clip property. This property is
especially useful in handling the clipboard and drag-drop operations. By default, the Clip property
returns a string with tab characters (Chr(9)) between cells and return characters (Chr(13)) between rows .
To use different delimiters, change the ClipSeparators property.
Finally, you can set and retrieve the contents of arbitrary cell ranges using CellRange objects.
Cell Ranges
CellRange objects allow you to work on arbitrary groups of cells as a single unit. For example, the code
below creates a CellRange object, clears the data in the range, and assigns it a custom style:
•
Visual Basic
Dim rg As CellRange = fg.GetCellRange(3, 3, 10, 10)
rg.Data = Nothing
rg.Style = fg.Styles("MyRangeStyle")
•
C#
CellRange rg = fg.GetCellRange(3, 3, 10, 10);
rg.Data = null;
rg.Style = fg.Styles["MyRangeStyle"];
•
Delphi
var
rg: CellRange;
begin
rg := fg.GetCellRange(3, 3, 10, 10);
rg.Data := nil;
rg.Style := fg.Styles['MyRangeStyle'];
end;
26 · Using the C1FlexGrid Control
The CellRange object has a StyleNew property that retrieves the range style, if one exists, or creates a
new one, assigns it to the range, and returns it. This property is convenient in situations where you don't
need full-fledged control over formatting. For example, if all you want to do is give the range a red
background, you can write
•
Visual Basic
Dim rg As CellRange = fg.GetCellRange(3, 3, 10, 10)
rg.StyleNew.BackColor = Color.Red
•
C#
CellRange rg = fg.GetCellRange(3, 3, 10, 10);
rg.StyleNew.BackColor = Color.Red;
•
Delphi
var
rg: CellRange;
begin
rg := fg.GetCellRange(3, 3, 10, 10);
rg.StyleNew.BackColor := Color.Red;
end;
Cell Images
Each grid cell can display images in addition to the data stored in the cell. This can be done in two ways:
1.
You can assign an Image object to a cell using the SetCellImage method. This method allows you
to assign arbitrary images to each cell, and is useful if the images are not related to the data in the
cell. For example, you may want to use a picture as an indicator that the data in the cell is invalid.
2.
You can assign an ImageMap to the column and the grid will automatically map the cell data
into a corresponding image. This method is useful in situations where the image contains a
representation of the data. For example, the images may contain icons that represent product
types.
Formatting Cells
One of the main strengths of the C1FlexGrid control is the ability to customize almost every aspect of the
appearance of the entire grid and individual cells.
Cell content
To control how the content of the cells is formatted, set the Cols(index).Format property to a format string
similar to the ones you use with the String.Format method in the .NET framework. For example, the code
below shows short dates on column one and currency values on column two:
•
Visual Basic
fg.Cols(1).Format = "d" ' << short date
fg.Cols(2).Format = "c" ' << currency
•
C#
fg.Cols[1].Format = "d"; // << short date
fg.Cols[2].Format = "c"; // << currency
Formatting Cells · 27
•
Delphi
fg.Cols[1].Format := 'd';
fg.Cols[2].Format := 'c';
You can also use custom formats like the ones used in the Visual Basic Format function (e.g., "#,###",
etc.).
You can retrieve the raw grid data using the indexers or the GetData method. To retrieve the formatted
data, use the GetDataDisplay method instead. For example:
•
Visual Basic
fg.Cols(1).Format = "d" ' << short date
fg.Cols(2).Format = "c" ' << currency
fg(1, 2) = 10000
Console.WriteLine("Raw value: {0}", fg(1, 2))
Console.WriteLine("Display value: {0}", fg.GetDataDisplay(1, 2))
Raw value: 10000
Display value: $10,000.00
•
C#
fg.Cols[1].Format = "d"; // << short date
fg.Cols[2].Format = "c"; // << currency
fg[1, 2] = 10000;
Console.WriteLine("Raw value: {0}", fg[1, 2]);
Console.WriteLine("Display value: {0}", fg.GetDataDisplay(1, 2));
Raw value: 10000;
Display value: $10,000.00;
•
Delphi
var
value: Raw;
begin
fg.Cols[1].Format := "d"; // << short date
fg.Cols[2].Format := "c"; // << currency
fg[1, 2] := 10000;
Console.WriteLine('Raw value: {0}', fg[1, 2]);
Console.WriteLine('Display value: {0}', fg.GetDataDisplay(1, 2));
end;
Cell appearance
The appearance of the cells (alignment, font, colors, borders etc) is handled with CellStyle objects. The
grid has a Styles property that holds the collection of styles used to format the grid. This collection has
some built-in members that define the appearance of grid elements such as fixed and scrollable cells,
selection, focus cell, etc. You can change these styles to modify the way the grid looks, and you can also
create your own custom styles and assign them to cells, rows, or columns.
Changing the built-in styles is the simplest way to change the appearance of the grid. For example, the
code below displays the selection as bold green characters over a red background:
•
Visual Basic
Dim cs As CellStyle = fg.Styles.Highlight
cs.Font = New Font(fg.Font, FontStyle.Bold)
cs.ForeColor = Color.Green
cs.BackColor = Color.Red
28 · Using the C1FlexGrid Control
•
C#
CellStyle cs = fg.Styles.Highlight;
cs.Font = new Font(fg.Font, FontStyle.Bold);
cs.ForeColor = Color.Green;
cs.BackColor = Color.Red;
•
Delphi
var
cs: CellStyle;
begin
cs := fg.Styles.Highlight;
cs.Font := Font.Create(fg.Font, FontStyle.Bold);
cs.ForeColor := Color.Green;
cs.BackColor := Color.Red;
end;
You can also create your own styles and assign them to cells, rows and columns. For example, the code
below creates a custom cell style and assigns it to every fifth row:
•
Visual Basic
Dim cs As CellStyle = fg.Styles.Add("Fifth")
cs.BackColor = Color.Gray
Dim idex%
For idex = fg.Rows.Fixed To fg.Rows.Count - 1 Step 5
fg.Rows(idex).Style = cs
Next
•
C#
CellStyle cs = fg.Styles.Add("Fifth");
cs.BackColor = Color.Gray;
for (int index = fg.Rows.Fixed ; index <= fg.Rows.Count – 1; index +=
5){
fg.Rows[index].Style = cs;
•
Delphi
var
fg: System.Object;
cs: CellStyle;
begin
cs := fg.Styles.Add('Fifth');
cs.BackColor := Color.Gray;
index := fg.Rows.Fixed; while (idex < fg.Rows.Count) do
begin
fg.Rows[index].Style := cs;
end;
end;
Here's an example that shows how you can create custom styles and assign them to columns, rows, and
cell ranges:
•
Visual Basic
' create a new custom style
Dim s As CellStyle = _flex.Styles.Add("MyStyle")
s.BackColor = Color.Red
s.ForeColor = Color.White
' assign new style to a column
_flex.Cols(3).Style = _flex.Styles("MyStyle") '
' assign new style to a row
Formatting Cells · 29
_flex.Rows(3).Style = _flex.Styles("MyStyle") '
' assign new style to a cell range
Dim rg As CellRange = _flex.GetCellRange(4, 4, 6, 6)
rg.Style = _flex.Styles("MyStyle")
•
C#
// create a
CellStyle s
s.BackColor
s.ForeColor
new custom style
= _flex.Styles.Add("MyStyle");
= Color.Red;
= Color.White;
// assign new style to a column
_flex.Cols[3].Style = _flex.Styles["MyStyle"];
// assign new style to a row
_flex.Rows[3].Style = _flex.Styles["MyStyle"];
// assign new style to a cell range
CellRange rg = _flex.GetCellRange(4,4,6,6);
rg.Style = _flex.Styles["MyStyle"];
•
Delphi
var
rg: CellRange;
s: CellStyle;
begin
s := _flex.Styles.Add('MyStyle');
s.BackColor := Color.Red;
s.ForeColor := Color.White;
_flex.Cols[3].Style := _flex.Styles['MyStyle'];
_flex.Rows[3].Style := _flex.Styles['MyStyle'];
rg := _flex.GetCellRange(4, 4, 6, 6);
rg.Style := _flex.Styles['MyStyle'];
end;
If you prefer, you can set up styles at design time instead of writing code to do it. Just select the grid, go
to the Properties window and click the button next to the Styles property.
30 · Using the C1FlexGrid Control
The grid will display the style editor dialog shown below:
The style editor lets you modify existing styles and add new custom ones, which may later be assigned to
cells, rows, and columns.
The Add and Remove buttons add and remove custom styles. You can rename custom styles by selecting
them on the list and typing the new name. The Clear button removes all custom styles and restores the
built-in styles to their default values.
The AutoFormat button brings up a secondary dialog that allows you to select a complete set of
predefined styles. Here's what the AutoFormat dialog looks like:
Formatting Cells · 31
Conditional formatting
To format cells based on their contents, you can use the CellChanged event to select a style for the cell
based on its contents. For example, the code below creates a new style for large currency values and
applies it to cells based on their contents:
•
Visual Basic
' create a custom style for large values
cs = fg.Styles.Add("LargeValue")
cs.Font = New Font(Font, FontStyle.Italic)
cs.BackColor = Color.Gold
' format cells based on their content
Private Sub fg_CellChanged(ByVal sender As Object,
ByVal e As RowColEventArgs) Handles fg.CellChanged
' mark currency values > 50,000 as LargeValues
' (reset others by setting their Style to Nothing)
Dim cs As CellStyle
If Val(fg(e.Row, e.Col)) >= 50000 Then
cs = fg.Styles("LargeValue")
End If
fg.SetCellStyle(e.Row, e.Col, cs)
End Sub
•
C#
// create a custom style for large values
cs = fg.Styles.Add("LargeValue");
cs.Font = new Font(Font, FontStyle.Italic);
cs.BackColor = Color.Gold;
// format cells based on their content
private void fg_CellChanged( object sender,
RowColEventArgs e) {
// mark currency values > 50,000 as LargeValues
// (reset others by setting their Style to null)
CellStyle cs;
if ( Val(fg(e.Row, e.Col)) >= 50000 ) {
cs = fg.Styles["LargeValue"];
}
fg.SetCellStyle(e.Row, e.Col, cs);
}
•
Delphi
cs := fg.Styles.Add('LargeValue');
cs.Font := Font.Create(Font, FontStyle.Italic);
cs.BackColor := Color.Gold;
procedure fg_CellChanged(sender: System.Object; e: RowColEventArgs)
begin
// mark currency values > 50,000 as LargeValues
// (reset others by setting their Style to null)
if val(fg[e.Row, e.Col] >= 50000 then
cs := fg.Styles['LargeValue'];
fg.SetCellStyle(e.Row, e.Col, cs);
end;
Owner-drawn cells
Even though the CellStyle objects offer a lot of control over the cell appearance (back and foreground
colors, alignment, font, margins, borders, etc), sometimes that is not enough. You may want to use a
32 · Using the C1FlexGrid Control
gradient background, or draw some custom graphics directly into a cell. In these cases, you can use the
DrawMode property and the OwnerDrawCell event to gain total control over how each cell is drawn.
The DrawMode property determines whether or not the OwnerDrawCell event is fired. The event
allows you to override every visual aspect of the cell. The parameters in the OwnerDrawCell event allow
you to change the data that is displayed, the style used to display the data, or to take over completely and
draw whatever you want into the cell.
You can change the text and image that will be shown in the cell by setting the e.Text and e.Image
parameters in the event handler. You can also change the style that will be used to display the cell by
setting the e.Style property.
Note that you should not modify the properties of the Style parameter because that might affect other
cells. Instead, assign a new CellStyle object to the Style parameter. For example, instead of setting
e.Style.ForeColor = Color.Red, assign a whole new style to the parameter using e.Style =
_flex.Styles["RedStyle"].
You can also use your own drawing code to draw into the cell, and even combine your custom code with
calls to the e.DrawCell method. For example, you could paint the cell background using GDI calls and
then call e.DrawCell to display the cell borders and content.
For an example of advanced OwnerDraw code, see the "RtfGrid" sample in our on-line sample library.
The code below shows an example. It uses a gradient brush to pain the background of the selected cells.
First, the code sets the DrawMode property, declares a LinearGradientBrush object and updates the
brush whenever the grid is resized:
•
Visual Basic
' use owner-draw to add gradients
fg.DrawMode = DrawModeEnum.OwnerDraw
' brush to use with owner-draw cells
Dim m_GradientBrush As LinearGradientBrush
Private Sub fg_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles fg.Resize
' update gradient brush when the control is resized
m_GradientBrush = New LinearGradientBrush(ClientRectangle, _
Color.SteelBlue, Color.White, 45)
End Sub
•
C#
// use owner-draw to add gradients
fg.DrawMode = DrawModeEnum.OwnerDraw;
// brush to use with owner-draw cells
LinearGradientBrush m_GradientBrush;
private void fg_Resize( object sender,
{
System.EventArgs e)
fg.Resize
// update gradient brush when the control is resized
m_GradientBrush = new LinearGradientBrush(ClientRectangle,,
Color.SteelBlue, Color.White, 45);
}
Formatting Cells · 33
•
Delphi
// brush to use with owner-draw cells
m_GradientBrush: LinearGradientBrush;
// use owner-draw to add gradients
fg.DrawMode := DrawModeEnum.OwnerDraw;
procedure fg_Resize(sender: System.Object; e: System.EventArgs);
begin
m_GradientBrush := new LinearGradientBrush(ClientRectangle,
Color.SteelBlue, Color.White, 45);
end;
The second step is handling the OwnerDrawCell event and using the custom brush for painting the cell
background. In this example, the foreground is handled by the grid itself, using the DrawCell method in
the event argument:
•
Visual Basic
Private Sub fg_OwnerDrawCell(ByVal sender As Object, _
ByVal e As OwnerDrawCellEventArgs) Handles fg.OwnerDrawCell
' draw selected cell background using gradient brush
If fg.Selection.Contains(e.Row, e.Col) Then
e.Graphics.FillRectangle(m_GradientBrush, e.Bounds) ' draw
background
e.DrawCell(DrawCellFlags.Content) ' let the grid draw the
content
e.Handled = True ' we're done drawing this cell
End If
End Sub
•
C#
private void fg_OwnerDrawCell( object sender,
e) fg.OwnerDrawCell {
OwnerDrawCellEventArgs
// draw selected cell background using gradient brush
if (fg.Selection.Contains(e.Row, e.Col))
{
e.Graphics.FillRectangle(m_GradientBrush, e.Bounds); // draw
background
e.DrawCell(DrawCellFlags.Content); // let the grid draw the
content
e.Handled = true; // we're done drawing this cell
}
}
•
Delphi
procedure fg_OwnerDrawCell(sender: System.Object; _
e: OwnerDrawCellEventArgs);
begin
// draw selected cell background using gradient brush
If fg.Selection.Contains(e.Row, e.Col) Then
begin
e.Graphics.FillRectangle(m_GradientBrush, e.Bounds); // draw
background
e.DrawCell(DrawCellFlags.Content); // let the grid draw the content
e.Handled := True // we're done drawing this cell
end;
end;
34 · Using the C1FlexGrid Control
Editing Cells
By default, the C1FlexGrid control allows users to edit cells by typing into them. You can prevent users
from editing the grid by setting the AllowEditing property to False. You can also prevent users from
editing specific columns by settings the Cols(index).AllowEditing property to False. (When the grid is
bound to a data source, it detects which columns are editable and automatically sets the AllowEditing
property.)
To start editing a cell, the user can:
1.
Start typing into the cell. This replaces the contents of the cell.
2.
Press F2 or Enter. This puts the grid in edit mode and puts the current cell contents in the editor.
3.
Double-click a cell. This has the same effect as pressing F2, but selected the character near the
click.
The basic editing mode allows users to type values into the cells. If the column being edited has a specific
data type, values entered by the user are converted into the proper data type automatically. If the user
types a value that cannot be converted into the proper data type, the grid fires a GridError event and
ignores the edits.
The basic editing is sufficient for many applications, but the C1FlexGrid has properties and events that
allow you to control the editing process and provide selection lists, editing buttons, and advanced
validation control.
Starting with version 2.5, the C1FlexGrid also has built-in support for external editors. This allows you to
use any control as a grid editor (for example, you can now use the C1Input controls as grid editors).
These features are described below.
Editing with Lists and Combos
In many applications, cells have a well-defined list of possible values. In these cases, you can let users
select the value from a drop-down list. To do this, build a string containing all the choices separated by
pipe characters (e.g., "True|False|Don't know") and assign it to the Cols(index).ComboList property.
Each column may have a different list. Setting the ComboList property causes the grid to display a dropdown box next to the cell. The user can click the box (or press F2) to display the list of choices available
for that cell.
Another common situation is where cells have a list of common values, but users should be allowed to
type something else as well. This can be accomplished with drop-down combos, a combination of text
box and drop-down list. To create combos, just start the choice list with a pipe character (e.g.
"|True|False|Don't know"), then assign it to the Cols(index).ComboList property as before.
For example, the code below would cause the grid to display a drop-down combolist containing color
names on column one, and a drop-down combo on column two. When editing column one, the user must
pick a value from the list. When editing column two, the user can pick a value or type in something else:
•
Visual Basic
fg.Cols(1).ComboList = "Red|Green|Blue|Red|White"
fg.Cols(2).ComboList = "|Red|Green|Blue|Red|White"
•
' drop-down list
' drop-down combo
C#
fg.Cols[1].ComboList = "Red|Green|Blue|Red|White";
fg.Cols[2].ComboList = "|Red|Green|Blue|Red|White";
// drop-down list
// drop-down combo
Editing Cells · 35
•
Delphi
fg.Cols[1].ComboList := 'Red|Green|Blue|Red|White';
fg.Cols[2].ComboList := '|Red|Green|Blue|Red|White';
In some cases, cells in the same column may need different lists. For example, a property list may show
properties on the first column and their values on the second. The values depend on the property, so
valid choices change from one row to the next. In these cases, you should trap the BeforeEdit event and
set the ComboList property to the appropriate list for the current cell. The ComboList property applies to
the whole grid.
The built-in ComboBox provides an auto-search feature by default. As the user types a value, the
selection will move to the next match. You can disable this feature using the EditOptions property and
control the time before the grid resets the auto-search buffer using the AutoSearchDelay property.
The built-in ComboBox also has an auto-cycle feature like the editors in the Visual Studio property
window. When you double-click a cell that has a list associated with it, the grid will automatically select
the next value. You can also disable this feature using the EditOptions property.
Checkboxes
By default, the grid displays values in boolean columns as checkboxes (the type of the column is
determined by the DataType property of the Column object). If you don't want boolean values displayed
as checkboxes, set the column's Format property to a string containing the values that should be
displayed for True and False values. For example:
•
Visual Basic
fg.Cols("bools").Format = "Yes;No"
•
C#
fg.Cols["bools"].Format = "Yes;No";
•
Delphi
fg.Cols['bools'].Format := 'Yes;No';
In unbound mode, you can use the GetCellCheck and SetCellCheck properties to add checkboxes to any
cells. The checkboxes will be displayed along with any text in the cell, and you can set their position
using the column's ImageAlign property.
There are two types of check boxes: boolean and tri-state. Boolean check boxes toggle between the
CheckEnum.Checked and CheckEnum.Unchecked states. Tri-state check boxes cycle through the
settings CheckEnum.TSChecked and CheckEnum.TSUnchecked and CheckEnum.TSGrayed.
If the cell has a check box and the AllowEditing property is set to True, the user can change the state of
the check boxes by clicking them with the mouse or by pressing the space or return keys.
By default, toggling the value of checkbox with the mouse or keyboard will toggle all selected
checkboxes. You can disable this feature using the EditOptions property.
Value-Mapped Lists
The ComboList property described above ensures that cell values are selected from a list. The value
selected by the user is converted into the appropriate type for the column and stored in the grid, exactly
as if the user had typed the value.
36 · Using the C1FlexGrid Control
In many cases, cells can assume values from a well-defined lists, but you want to display a user-friendly
version of the actual value. For example, if a column contains product codes, you may want to store the
code but display the product name instead.
This is accomplished with the Cols(index).DataMap property. This property contains a reference to an
IDictionary object that establishes the mapping between what is stored in the grid and what is visible to
the user (the IDictionary interface is defined in the System.Collections namespace, and is implemented by
the Hashtable class among others).
For example, the code below creates a data map that contains color values and their names. The colors are
stored in the grid, and their names are displayed to the user:
•
Visual Basic
Dim dtMap As Hashtable = New Hashtable()
dtMap.Add(Color.Red, "Apple")
dtMap.Add(Color.Green, "Forest")
dtMap.Add(Color.Blue, "Sky")
dtMap.Add(Color.Black, "Coal")
dtMap.Add(Color.White, "Snow")
fg.Cols(1).DataType = GetType(Color)
fg.Cols(1).DataMap = dtMap
•
C#
Hashtable Hashtable dtMap = new Hashtable();
dtMap.Add(Color.Red, "Apple");
dtMap.Add(Color.Green, "Forest");
dtMap.Add(Color.Blue, "Sky");
dtMap.Add(Color.Black, "Coal");
dtMap.Add(Color.White, "Snow");
fg.Cols[1].DataType = typeof(Color);
fg.Cols[1].DataMap = dtMap;
•
Delphi
var
Hashtable: Hashtable;
begin
dtMap := Hashtable.Create;
dtMap.Add(Color.Red, 'Apple');
dtMap.Add(Color.Green, 'Forest');
dtMap.Add(Color.Blue, 'Sky');
dtMap.Add(Color.Black, 'Coal');
dtMap.Add(Color.White, 'Snow');
fg.Cols[1].DataType := TypeOf(Color);
fg.Cols[1].DataMap := dtMap;
end;
Any class that implements IDictionary can be used as a DataMap. For example, Hashtable,
ListDictionary and SortedList. All of these classes provide valid data maps. The difference is that when
they are used in editable columns, the order of the items in the drop down list will depend on the class.
The SortedList class sorts items by key, Hashtable uses an arbitrary order, and ListDictionary keeps the
order in which items were added to the list. Because of this, ListDictionary is usually the best choice for
DataMaps.
Note that the keys in the data map must be of the same type as the cells being edited. For example, if a
column contains short integers (Int16), then any data maps associated with the column should have short
integer keys. Using regular integers (Int32) as keys would not work.
Editing Cells · 37
The example below shows the difference:
•
Visual Basic
private void Form1_Load(object sender, System.EventArgs e)
{
SortedList sl = new SortedList(); // << sorts by key
sl.Add("0", "Zero");
sl.Add("1", "One");
sl.Add("2", "Two");
sl.Add("3", "Three");
ListDictionary ld = new ListDictionary(); // << keeps Add order
ld.Add(0, "Zero");
ld.Add(1, "One");
ld.Add(2, "Two");
ld.Add(3, "Three");
Hashtable
ht.Add(0,
ht.Add(1,
ht.Add(2,
ht.Add(3,
ht = new Hashtable(); // << arbitrary order
"Zero");
"One");
"Two");
"Three");
flex.Cols[1].DataMap = sl; flex.Cols[1].Caption = "SortedList";
flex.Cols[2].DataMap = ld; flex.Cols[2].Caption = "ListDictionary";
flex.Cols[3].DataMap = ht; flex.Cols[3].Caption = "HashTable";
}
•
C#
private void Form1_Load(object sender, System.EventArgs e);
{;
SortedList sl = new SortedList(); // << sorts by key
sl.Add("0", "Zero");
sl.Add("1", "One");
sl.Add("2", "Two");
sl.Add("3", "Three");
ListDictionary ld = new ListDictionary(); // << keeps Add order
ld.Add(0, "Zero");
ld.Add(1, "One");
ld.Add(2, "Two");
ld.Add(3, "Three");
Hashtable
ht.Add(0,
ht.Add(1,
ht.Add(2,
ht.Add(3,
ht = new Hashtable(); // << arbitrary order
"Zero");
"One");
"Two");
"Three");
flex.Cols[1].DataMap = sl; flex.Cols[1].Caption = "SortedList";
flex.Cols[2].DataMap = ld; flex.Cols[2].Caption = "ListDictionary";
flex.Cols[3].DataMap = ht; flex.Cols[3].Caption = "HashTable";
}
•
Delphi
procedure Form1_Load(sender: System.Object; e: System.EventArgs);
var
sl: SortedList;
ld: ListDictionary;
ht: Hashtable;
begin
sl := SortedList.Create; // << sorts by key
38 · Using the C1FlexGrid Control
sl.Add('0',
sl.Add('1',
sl.Add('2',
sl.Add('3',
'Zero');
'One');
'Two');
'Three');
ld := ListDictionary.Create; // << keeps Add order
ld.Add(System.Object(0), 'Zero');
ld.Add(System.Object(1), 'One');
ld.Add(System.Object(2), 'Two');
ld.Add(System.Object(3), 'Three');
ht := Hashtable.Create; // << arbitrary order
ht.Add(System.Object(0), 'Zero');
ht.Add(System.Object(1), 'One');
ht.Add(System.Object(2), 'Two');
ht.Add(System.Object(3), 'Three');
flex.Cols[1].DataMap
flex.Cols[1].Caption
flex.Cols[2].DataMap
flex.Cols[2].Caption
flex.Cols[3].DataMap
flex.Cols[3].Caption
end; //Form1_Load
:=
:=
:=
:=
:=
:=
sl;
'SortedList';
ld;
'ListDictionary';
ht;
'HashTable';
Also, if the column's DataType property is set to an enumeration, the grid will automatically build and
use a data map with the names of each value in the enumeration. For example, the following code creates
an enumeration containing countries. The country values are stored in the grid, and their names are
displayed to the user:
•
Visual Basic
Private Enum Countries
NewYork
Chicago
NewOrleans
London
Paris
End Enum
fg.Cols(1).DataType = GetType(Countries)
•
C#
private enum Countries
{
NewYork;
Chicago;
NewOrleans;
London;
Paris;
};
fg.Cols(1).DataType = typeof(Countries);
•
Delphi
type
Countries = (NewYork, Chicago, NewOrleans, London, Paris);
fg.Cols[1].DataType := TypeOf(Countries);
Cell Buttons
Certain types of cells may require sophisticated editors other than text boxes or drop-down lists. For
example, if a column contains file names or a color, it should be edited with a dialog box.
Editing Cells · 39
In these cases, you should set the ComboList property to an ellipsis ("…"). The control will display a
button next to the cell and will fire the CellButtonClick event when the user clicks on it. You can trap the
event, show the dialog, and update the cell's contents with the user's selection.
If you add a pipe character before the ellipsis, then the user will also be allowed to edit the cell contents
by typing into the cell.
By default, the cell buttons display the ellipsis. You can assign pictures to the cell buttons using the
CellButtonImage property.
The example below shows how you can use cell buttons to display a calendar for editing date columns.
The example assumes that you have a MonthCalendar control named "cal" on the form:
•
Visual Basic
' set up date column
Dim c As Col = fg.Cols(1)
c.DataType = GetType(Color)
c.ComboList = "..." ' << show cell button
•
C#
// set up date column
Col c = fg.Cols[1];
c.DataType = typeof(Color);
c.ComboList = "...";// << show cell button
•
Delphi
var
c: Col;
begin
c := fg.Cols[1];
c.DataType := TypeOf(Color);
c.ComboList := '...';
end;
This code sets up the column so the user can click a button or edit the date by typing. The next step is the
code that handles clicks on the cell button:
•
Visual Basic
Private Sub fg_CellButtonClick(ByVal sender As Object, _
ByVal e As RowColEventArgs) Handles fg.CellButtonClick
' create color picker dialog
Dim clrDlg As New ColorDialog()
' initialize the dialog
If fg(e.Row, e.Col) Is GetType(Color) Then
clrDlg.Color = fg(e.Row, e.Col)
End If
' get new color from dialog and assign it to the cell
If clrDlg.ShowDialog() = DialogResult.OK Then
fg(e.Row, e.Col) = clrDlg.Color
End If
End Sub
•
C#
private void fg_CellButtonClick( object sender,
fg.CellButtonClick {
// create color picker dialog
RowColEventArgs e)
40 · Using the C1FlexGrid Control
ColorDialog
clrDlg = new ColorDialog();
// initialize the dialog
if ( fg(e.Row, e.Col) Is typeof(Color) )
{
clrDlg.Color = fg(e.Row, e.Col);
}
// get new color from dialog and assign it to the cell
if ( clrDlg.ShowDialog() = DialogResult.OK )
{
fg(e.Row, e.Col) = clrDlg.Color;
}
}
•
Delphi
procedure fg_CellButtonClick(sender: System.Object; _
e: RowColEventArgs);
var
clrDlg: ColorDialog;
begin
// create color picker dialog
clrDlg := ColorDialog.Create;
// initialize the dialog
If fg[e.Row, e.Col] Is Color Then
clrDlg.Color := fg[e.Row, e.Col];
// get new color from dialog and assign it to the cell
If clrDlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
fg[e.Row, e.Col] := clrDlg.Color
end;
Masks
The C1FlexGrid control also supports masked editing. This type of editing uses an input mask to provide
a template and automatically validate the input as the user types. The mask is specified by the
Col(index).EditMask property, which can be used with regular text fields and with drop-down combo
fields.
Mask strings have two types of characters: literal characters, which become part of the input, and
template characters, which serve as placeholders for characters belonging to specific categories (e.g. digits
or alphabetic). For example, the code below assigns a "(999) 999-9999" editing mask to column one, which
holds phone numbers (the digit "9" is a placeholder that stands for any digit):
•
Visual Basic
' set up phone number edit mask
fg.Cols(1).EditMask = "(999) 999-9999
•
C#
// set up phone number edit mask
fg.Cols[1].EditMask = "(999) 999-9999;
•
Delphi
fg.Cols(1).EditMask := '(999) 999-9999;';
Setting the EditMask property to a non-empty string causes it to use the built-in masked editor, even if
the column contains date/time values (usually, a DateTimePicker control is used to edit these columns).
Editing Cells · 41
This is especially convenient if you have DateTime columns that hold times only (not dates). In these
cases, you can set the following properties to use a masked editor instead of the DateTimePicker control:
•
Visual Basic
fg.Cols(1).DataType = GetType(DateTime) '
fg.Cols(1).Format = "hh:mm tt" '
fg.Cols(1).EditMask = "99:99 LL" '
•
C#
fg.Cols[1].DataType=typeof(DateTime);
fg.Cols[1].Format="hh:mm tt";
fg.Cols[1].EditMask="99:99 LL";
•
Delphi
fg.Cols[1].DataType := TypeOf(DateTime);
fg.Cols[1].Format := 'hh:mm tt';
fg.Cols[1].EditMask := '99:99 LL';
For details on the syntax used to build the mask strings, see the EditMask property in the control
reference section.
If different cells in the same column need different masks, trap the BeforeEdit event and set the
EditMask property to an appropriate value for the current cell.
Validation
In many cases, edit masks alone are not enough to ensure that the data enters by the user was valid. For
example, a mask won't let you specify a range of possible values, or validate the current cell based on the
contents of another cell.
In these cases, trap the ValidateEdit event and see if the value contained in the Editor.Text property is a
valid entry for the current cell (at this point, the cell still has the original value in it). If the input is invalid,
set the Cancel parameter to True and the grid will remain in edit mode until the user types a valid entry.
For example, the code below validates input into a currency column to ensure that values entered are
between 1,000 and 10,000:
•
Visual Basic
Private Sub fg_ValidateEdit(ByVal sender As Object, _
ByVal e As ValidateEditEventArgs) Handles fg.ValidateEdit
' validate amounts
If fg.Cols(e.Col).DataType Is GetType(Decimal) Then
Try
Dim dec As Decimal = Decimal.Parse(fg.Editor.Text())
If dec < 1000 Or dec > 10000 Then
MessageBox.Show("Value must be between 1,000 and
10,000")
e.Cancel = True
End If
Catch
MessageBox.Show("Value not recognized as a Currency")
e.Cancel = True
End Try
End If
End Sub
42 · Using the C1FlexGrid Control
•
C#
private void fg_ValidateEdit( object sender,
ValidateEditEventArgs e)
{
// validate amounts
if (fg.Cols[e.Col].DataType is (Decimal))
{
try {
10,000");
Decimal dec = Decimal.Parse(fg.Editor.Text);
if ( dec < 1000 || dec > 10000 ) {
MessageBox.Show("value must be between 1,000 and
e.Cancel = true;
}
} catch{
MessageBox.Show("value not recognized as a Currency");
e.Cancel = true;
}
}
}
•
Delphi
Private Sub fg_ValidateEdit(sender: System.Object; _
e: ValidateEditEventArgs);
var
dec: Decimal;
begin
// validate amounts
If fg.Cols(e.Col).DataType Is Decimal Then
Try
dec := Decimal.Parse(fg.Editor.Text())
If (dec < 1000) Or (dec > 10000) Then
begin
MessageBox.Show('Value must be between 1,000 and 10,000');
e.Cancel := True;
end;
except
MessageBox.Show('Value not recognized as a Currency');
e.Cancel := True
end;
end;
Using Custom Editors
The built-in editors provide a lot of flexibility and power, but in some cases you may want to use external
controls as specialized editors. For example, you may want to use the C1NumericInput control that
provides a drop-down calculator for entering numbers, or an editor for selecting from multi-column lists,
or a specialized control that you wrote to edit your business objects.
Any control that derives from the base Control class can be used as a basic grid editor. Controls that
implement the IC1EmbeddedEditor interface (defined in C1Common.dll) can provide better integration
with the grid and more advanced features. For details on the IC1EmbeddedEditor interface, see the
Editor property.
To use a control as a custom editor, all you have to do is associate an instance of the control with a grid
column or a style using its Editor property. You can do this at design time (using the column editor) or at
run time. After that, the control will be automatically used by the grid.
Editing Cells · 43
To define custom editors at design time, add an instance of the editor control to the form, then right-click
the grid and select "Edit Columns…". Select the columns that should use the custom editor and set their
Editor properties to the name of the new editor control.
For example, to use a NumericUpDown control as a grid editor, follow these steps:
1.
Add a C1FlexGrid control to the form.
2.
Add a NumericUpDown control to the form and set its BorderStyle property to "None".
3.
Right-click the grid and select the "Edit Columns…" option.
4.
In the column editor, select the first scrollable grid column and set its Editor property to
"numericUpDown1".
Run the project and edit some values in the first column. Notice how the grid positions and initializes the
NumericUpDown control so you can edit cell values. When you are done editing a cell, click a different
cell or press the Tab key to move to the next one. Notice how the new value is applied to the cell.
You can also assign custom editors to the grid at run time, using code.
•
Visual Basic
Private Sub Form_Load(EventArgs e)
' create custom editor
Dim editor as New NuumericUpDown()
editor.BorderStyle = BorderStyle.None
' assign custom editor to the grid
fg.Cols(1).Editor = editor
End Sub
•
C#
private void Form_Load(EventArgs e)
{
// create custom editor
NumericUpDown editor = new NumericUpDown();
editor.BorderStyle = BorderStyle.None;
// assign custom editor to the grid
fg.Cols[1].Editor = editor;
}
•
Delphi
procedure TWinForm.Form_Load(object sender; e: System.EventArgs);
var editor: NumericUpDown;
begin
// create custom editor
editor := NumericUpDown.Create;
editor.BorderStyle := BorderStyle.None;
// assign custom editor to the grid
fg.Cols[1].Editor := editor;
end;
44 · Using the C1FlexGrid Control
Creating Custom Editors
Any control that derives from the Control base class can be used as a grid editor. This is possible because
the grid knows enough about the base class to access properties such as Text and Bounds, and events
such as Leave and TextChanged. In many cases this level of support is adequate.
In some cases, however, you may want to use controls that do not follow the base class that closely. For
example, a DateTimePicker control has a Value property that should be used to retrieve the edited value
instead of Text. In these cases, you can implement one or more methods in the IC1EmbeddedEditor
interface to override the default behavior. For example, all controls in the C1Input library support
IC1EmbeddedEditor and therefore integrate closely with C1FlexGrid (and also C1TrueDBGrid).
The IC1EmbeddedEditor interface is fairly simple, and because the grid binds to it using late binding,
you don't even have to implement all its members. Only implement the ones that make sense to your
editor control.
The interface does provide enough flexibility to allow virtually any control to be used as a grid editor.
You can even use UITypeEditor classes as grid editors. To do this, you need a wrapper class that (1)
derives from Control (UITypeEditor doesn't), (2) implements the IC1EmbeddedEditor interface, and (3),
encapsulates the appropriate UITypeEditor. We provide source code for this wrapper class in the
"CustomEditors" sample.
Using the UITypeEditor wrapper class, you can use any UITypeEditors with the C1FlexGrid. .NET
provides several UITypeEditors for editing Colors, Fonts, file names, etc. You can also write your own
UITypeEditors, in some cases that is easier than writing a control.
For an example of using built-in, custom, and UITypeEditor editors with the C1FlexGrid, see the
"CustomEditors" sample in our on-line sample library.
Controlling Edit Mode
You can determine whether the grid is in edit mode by reading the value of the Editor property. If this
property returns null, the grid is not in edit mode. Otherwise, the grid is in edit mode and the property
returns a reference to the control that is being used to edit the cell (the control may be a TextBox, a
ComboBox, or other type of control).
You can put the grid in edit mode programmatically using the StartEditing method, and finish editing
using the FinishEditing method.
You can control the editing process further by handling the editing events fired by the grid. In the process
of editing a cell, the grid fires the following sequence of events:
BeforeEdit Event (page 223)
This event fires whenever an editable cell is selected. It allows you to prevent the cell from being edited
by setting the event's Cancel parameter to true. You can also modify the ComboList property so the
appropriate drop-down button gets painted in the cell.
Note that the user might not actually start editing after this, he could simply move the selection to a
different cell or control.
StartEdit Event (page 258)
This event is similar to BeforeEdit, except the user has actually typed a key or clicked the dropdown
button in the cell and really is about to start editing. You can still cancel the editing at this point.
Note that the Editor property is still null at this point, because the control hasn't yet determined the type
of editor that should be used. You can assign custom editors to the Editor property at this point.
Outlining and Summarizing · 45
SetupEditor Event (page 255)
This event fires after the editor control has been created and configured to edit the cell, but before it is
displayed. You can change the editor properties at this point (for example, set the maximum length or
password character to be used in a TextBox editor). You can also attach your own event handlers to the
editor.
ValidateEdit Event (page 259)
This event fires when the user is done editing, before the editor value gets copied back into the grid. You
can examine the original value by retrieving it from the grid (the event provides the coordinates of the
cell). You can examine the new value about to be assigned to the grid through the Editor properties (e.g.,
Editor.Text). If the new value is not valid for the cell, set the Cancel parameter to true and the grid will
remain in edit mode.
If instead of keeping the cell in edit mode you would rather restore the original value and leave edit
mode, set Cancel to true and then call the FinishEditing method.
AfterEdit Event (page 209)
This event fires after the new value has been applied to the cell and the editor has been deactivated. You
can use this event to update anything that depends on the cell value (for example, subtotals or sorting).
Outlining and Summarizing
The FlexGrid control has methods and properties that allow you to summarize data and display it in a
hierarchical manner. To summarize data and add aggregate values, use the Subtotal method. To display
hierarchical views of the data, use the Tree property.
Creating Subtotals
The Subtotal method adds subtotal rows that contain aggregate data for the regular (non-subtotal) rows.
Subtotal supports hierarchical aggregates. For example, if your grid contains sales data, you may
Subtotal to get aggregate sales figures by Product, Region, and Salesperson. The code below illustrates
this:
•
Visual Basic
Private Sub ShowTotals()
' show OutlineBar on column 0
fg.Tree.Column = 0
fg.Tree.Style = TreeStyleFlags.Simple
' clear existing subtotals
fg.Subtotal(AggregateEnum.Clear)
' get a Grand total (use -1 instead of column index)
fg.Subtotal(AggregateEnum.Sum, -1, -1, 3, "Grand Total")
' total per Product (column 0)
fg.Subtotal(AggregateEnum.Sum, 0, 0, 3, "Total {0}")
' total per Region (column 1)
fg.Subtotal(AggregateEnum.Sum, 1, 1, 3, "Total {0}")
' size column widths based on content
fg.AutoSizeCols()
End Sub
46 · Using the C1FlexGrid Control
•
C#
private void ShowTotals() {
// show OutlineBar on column 0
fg.Tree.Column = 0;
fg.Tree.Style = TreeStyleFlags.Simple;
// clear existing subtotals
fg.Subtotal(AggregateEnum.Clear);
// get a Grand total (use -1 instead of column index)
fg.Subtotal(AggregateEnum.Sum, -1, -1, 3, "Grand Total");
// total per Product (column 0)
fg.Subtotal(AggregateEnum.Sum, 0, 0, 3, "Total {0}");
// total per Region (column 1)
fg.Subtotal(AggregateEnum.Sum, 1, 1, 3, "Total {0}");
// size column widths based on content
fg.AutoSizeCols();
}
•
Delphi
procedure ShowTotals()
begin
// show OutlineBar on column 0
fg.Tree.Column := 0;
fg.Tree.Style := TreeStyleFlags.Simple;
// clear existing subtotals
fg.Subtotal(AggregateEnum.Clear);
// get a Grand total (use -1 instead of column index)
fg.Subtotal(AggregateEnum.Sum, -1, -1, 3, 'Grand Total');
// total per Product (column 0)
fg.Subtotal(AggregateEnum.Sum, 0, 0, 3, 'Total {0}');
// total per Region (column 1)
fg.Subtotal(AggregateEnum.Sum, 1, 1, 3, 'Total {0}');
// size column widths based on content
fg.AutoSizeCols;
end;
When the Subtotal method adds rows with the aggregate information, it automatically assigns subtotal
styles to the new rows (there are built-in styles for 5 levels of subtotals). You can customize the
appearance of the subtotal rows by changing the properties of the outline styles, at design time with the
style editor or at run time with code. For example:
•
Visual Basic
' set styles for subtotals
Dim cs As CellStyle
cs = fg.Styles(CellStyleEnum.GrandTotal)
cs.BackColor = Color.Black
cs.ForeColor = Color.White
cs.Font = New Font(Font, FontStyle.Bold)
cs = fg.Styles(CellStyleEnum.Subtotal0)
cs.BackColor = Color.DarkRed
cs.ForeColor = Color.White
cs.Font = New Font(Font, FontStyle.Bold)
cs = fg.Styles(CellStyleEnum.Subtotal1)
Outlining and Summarizing · 47
cs.BackColor = Color.DarkBlue
cs.ForeColor = Color.White
•
C#
// set styles for subtotals
CellStyle cs;
cs = fg.Styles[CellStyleEnum.GrandTotal];
cs.BackColor = Color.Black;
cs.ForeColor = Color.White;
cs.Font = new Font(Font, FontStyle.Bold);
cs = fg.Styles[CellStyleEnum.Subtotal0];
cs.BackColor = Color.DarkRed;
cs.ForeColor = Color.White;
cs.Font = new Font(Font, FontStyle.Bold);
cs = fg.Styles[CellStyleEnum.Subtotal1];
cs.BackColor = Color.DarkBlue;
cs.ForeColor = Color.White;
•
Delphi
cs := fg.Styles[CellStyleEnum.GrandTotal);
cs.BackColor := Color.Black;
cs.ForeColor := Color.White;
cs.Font := Font.Create(Font, FontStyle.Bold);
cs := fg.Styles[CellStyleEnum.Subtotal0];
cs.BackColor := Color.DarkRed;
cs.ForeColor := Color.White;
cs.Font := Font.Create(Font, FontStyle.Bold);
cs := fg.Styles[CellStyleEnum.Subtotal1];
cs.BackColor := Color.DarkBlue;
cs.ForeColor := Color.White;
After executing this code, the grid would look like this:
48 · Using the C1FlexGrid Control
The Grand Total row contains the total sales for all products, regions, and sales personnel. It was created
using a –1 for the groupOn parameter in the call to the Subtotal method. The other subtotals show total
sales by product and region. They were created using a values 0 and 1 for the groupOn parameter.
You may also calculate aggregates other than sums (e.g. averages or percentages), and calculate several
aggregates for each row (e.g. gross and net sales).
Subtotal rows created by the Subtotal method differ from regular rows in three aspects:
1) Subtotal rows can be automatically removed by invoking the Subtotal method with the
flexSTClear parameter. This is useful to provide dynamic views of the data, where the user may
move columns and re-sort the data, making it necessary to recalculate the subtotals.
2) Subtotal rows can be used as nodes in an outline, allowing you to collapse and expand groups of
rows to present an overview of the data or to reveal its details. To see the outline tree, you need
to set the Tree.Column and Tree.Style properties to define the position and appearance of the
outline tree.
3) Subtotal rows can be treated as nodes in a tree. You can get a Node object for any subtotal row
through the Rows(index).Node property.
4) When the grid is bound to a data source, the subtotal rows do not correspond to actual data. If
you move the cursor in the data source, subtotal rows will be skipped in the grid.
The outline tree allows users to collapse and expand sections of the grid by clicking on the nodes. You
can use outline trees to display many types of information, not only aggregates. The next topic shows
how you can create a custom outline tree to display directory information.
Creating Custom Trees
To create outline trees without using the Subtotal method, you need to follow these steps:
1) Add rows to the grid.
2) Turn some rows into outline nodes by setting their Row(index).IsNode property to True.
3) Get the Node object for each node row and set its Level property to define the node's position in
the tree hierarchy. Higher values mean the node is deeper (more indented) into the outline tree.
For example, the code below creates a directory tree:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' initialize grid layout
fg.Cols.Fixed = 0
fg.Cols.Count = 1
fg.Rows.Count = 1
fg.ExtendLastCol = True
fg.Styles.Normal.TextAlign = TextAlignEnum.LeftCenter
fg.Styles.Normal.Border.Style = BorderStyleEnum.None
' initialize outline tree
fg.Tree.Column = 0
fg.Tree.Style = TreeStyleFlags.SimpleLeaf
' populate the grid
AddDirectory("c:\", 0)
End Sub
Outlining and Summarizing · 49
•
C#
private void Form1_Load( System.object sender,
base.Load {
System.EventArgs e)
// initialize grid layout
fg.Cols.Fixed = 0;
fg.Cols.Count = 1;
fg.Rows.Count = 1;
fg.ExtendLastCol = true;
fg.Styles.Normal.TextAlign = TextAlignEnum.LeftCenter;
fg.Styles.Normal.Border.Style = BorderStyleEnum.None;
// initialize outline tree
fg.Tree.Column = 0;
fg.Tree.Style = TreeStyleFlags.SimpleLeaf;
// populate the grid
AddDirectory("c:\", 0);
}
•
Delphi
procedure Form1_Load(sender: System.Object; _
e: System.EventArgs);
begin
// initialize grid layout
fg.Cols.Fixed := 0;
fg.Cols.Count := 1;
fg.Rows.Count := 1;
fg.ExtendLastCol := True;
fg.Styles.Normal.TextAlign := TextAlignEnum.LeftCenter;
fg.Styles.Normal.Border.Style := BorderStyleEnum.None;
// initialize outline tree
fg.Tree.Column := 0;
fg.Tree.Style := TreeStyleFlags.SimpleLeaf;
// populate the grid
AddDirectory("c:\", 0)
end;
The code above initializes the grid layout and calls the AddDirectory routine that does the job of
populating the grid and setting up the tree structure:
•
Visual Basic
Private Sub AddDirectory(ByVal dir As String, ByVal level As Integer)
' add this directory
Dim thisDir As String
thisDir = Path.GetFileName(dir)
If thisDir.Length = 0 Then thisDir = dir
fg.AddItem(thisDir.ToUpper())
' make this new row a node
Dim row As Row = fg.Rows(fg.Rows.Count - 1)
row.IsNode = True
' set node level
Dim nd As Node = row.Node
nd.Level = level
' add files in this directory
50 · Using the C1FlexGrid Control
Dim file As String, cnt As Integer
cnt = 0
For Each file In Directory.GetFiles(dir)
fg.AddItem(Path.GetFileName(file).ToLower())
cnt = cnt + 1
If cnt > 10 Then Exit For
Next
' add subdirectories (up to level 4)
If level <= 4 Then
Dim subdir As String
cnt = 0
For Each subdir In Directory.GetDirectories(dir)
AddDirectory(subdir, level + 1)
cnt = cnt + 1
If cnt > 10 Then Exit For
Next
End If
End Sub
•
C#
private void AddDirectory( string dir, int level) {
// add this directory
string thisDir = Path.GetFileName(dir);
if ( thisDir.Length == 0 ) thisDir = dir;
fg.AddItem(thisDir.ToUpper());
// make this new row a node
Row row = fg.Rows[fg.Rows.Count – 1];
row.IsNode = true;
// set node level
Node nd = row.Node;
nd.Level = level;
// add files in this directory
int cnt = 0;
foreach (string file In Directory.GetFiles(dir)
{
fg.AddItem(Path.GetFileName(file).ToLower());
cnt = cnt + 1;
if ( cnt > 10 ) break;
}
•
Delphi
procedure AddDirectory(dir: String; level: Integer);
var
thisDir: string;
r: Row;
nd: Node;
file: string;
cnt: Integer;
files: array of string;
subdir: string;
begin
// add this directory
thisDir := Path.GetFileName(dir);
If thisDir.Length = 0 Then thisDir := dir;
fg.AddItem(thisDir.ToUpper());
// make this new row a node
r := fg.Rows(fg.Rows.Count - 1);
r.IsNode := True;
Outlining and Summarizing · 51
// set node level
nd := r.Node;
nd.Level := level;
// add files in this directory
cnt := 0;
files := Directory.GetFiles(dir);
for I := 0 to High(Files) do
begin
fg.AddItem(Path.GetFileName(files[I].ToLower());
cnt := cnt + 1;
if cnt > 10 then
break;
end;
// add subdirectories (up to level 4)
If level <= 4 Then
begin
cnt := 0;
files := Directory.GetDirectories(dir);
for I := 0 to High(files) do
begin
AddDirectory(subdir, level + 1);
cnt := cnt + 1;
if cnt > 10 then
break;
end;
end;
end;
AddDirectory is a recursive routine that traverses the current directory and all its subdirectories. In this
sample, the tree size is limited to four directory levels in order to save time. In a real application, the
routine should be changed to populate tree branches only when they are expanded (see the FlexGrid
Tutorials (page 71)).
This code creates a grid that looks like this:
52 · Using the C1FlexGrid Control
Merging Cells
The C1FlexGrid control allows you to merge cells, making them span multiple rows or columns. This
capability can be used to enhance the appearance and clarity of the data displayed on the grid. The effect
of these settings is similar to the HTML "<ROWSPAN>" and "<COLSPAN>" tags.
To enable cell merging, you must do two things:
1.
Set the grid's AllowMerging property to a value other than None. (The effect of each setting is
explained in the reference section).
2.
If you want to merge columns, set the Cols(index).AllowMerging property to True for each
column that you would like to merge. If you want to merge rows, set the
Rows(index).AllowMerging property to True for each row that you would like to merge
Merging will occur if adjacent cells contain the same non-empty string. There is no method to force a pair
of cells to merge. The merging is done automatically based on the cell contents. This makes it easy to
provide merged views of sorted data, where values in adjacent rows present repeated data.
Cell merging has several possible uses. For example, you can use it to create merged table headers,
merged data views, or grids where the text spills into adjacent columns.
Merged table headers
To create merged table headers, you must start by setting the grid's AllowMerging property to
FixedOnly. Then, designate the rows and columns that you want to merge by setting the row and
column's AllowMerging properties. Finally, assign the text to the header cells so that the cells you want
to merge have the same contents.
The code below shows an example:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim i%
' initialize control
fg.Styles.Normal.WordWrap = True
fg.Cols.Count = 9
fg.Rows.Fixed = 2
fg.AllowMerging = AllowMergingEnum.FixedOnly
' create row headers
fg.Rows(0).AllowMerging = True
' four cells with same contents, will merge
Dim rng As CellRange = fg.GetCellRange(0, 1, 0, 4)
rng.Data = "North"
' four cells with same contents, will merge
rng = fg.GetCellRange(0, 5, 0, 8)
rng.Data = "South"
For i = 1 To 4
fg(1, i) = "Qtr " & i
fg(1, i + 4) = "Qtr " & i
Next
' create column header
fg.Cols(0).AllowMerging = True
Merging Cells · 53
' two cells with same contents, will merge
rng = fg.GetCellRange(0, 0, 1, 0)
rng.Data = "Sales by Product"
' align and autosize the cells
fg.Styles.Fixed.TextAlign = TextAlignEnum.CenterCenter
fg.AutoSizeCols(1, fg.Cols.Count - 1, 10)
End Sub
•
C#
private void Form1_Load( System.object sender,
base.Load {
i%;
System.EventArgs e)
// initialize control
fg.Styles.Normal.WordWrap = true;
fg.Cols.Count = 9;
fg.Rows.Fixed = 2;
fg.AllowMerging = AllowMergingEnum.FixedOnly;
// create row headers
fg.Rows[0].AllowMerging = true;
// four cells with same contents, will merge
CellRange rng = fg.GetCellRange(0, 1, 0, 4);
rng.Data = "North";
// four cells with same contents, will merge
rng = fg.GetCellRange(0, 5, 0, 8);
rng.Data = "South";
for ( i = 1 ; i <= 4; i++)
{
fg[1, i] = "Qtr " + i;
fg[1, i + 4] = "Qtr " + i;
} //
// create column header
fg.Cols[0].AllowMerging = true;
// two cells with same contents, will merge
rng = fg.GetCellRange(0, 0, 1, 0);
rng.Data = "Sales by Product";
// align and autosize the cells
fg.Styles.Fixed.TextAlign = TextAlignEnum.CenterCenter;
fg.AutoSizeCols(1, fg.Cols.Count - 1, 10);
}
•
Delphi
procedure Form1_Load(sender: System.Object; _
e: System.EventArgs);
var
I: Integer;
rng: CellRange;
begin
// initialize control
fg.Styles.Normal.WordWrap := True;
fg.Cols.Count := 9;
fg.Rows.Fixed := 2;
fg.AllowMerging := AllowMergingEnum.FixedOnly;
// create row headers
fg.Rows[0].AllowMerging := True;
54 · Using the C1FlexGrid Control
// four cells with same contents, will merge
rng := fg.GetCellRange(0, 1, 0, 4);
rng.Data := 'North';
// four cells with same contents, will merge
rng := fg.GetCellRange(0, 5, 0, 8);
rng.Data := 'South';
For i := 1 To 4 do
begin
fg[1, i] := 'Qtr ' + I;
fg[1, i + 4] = 'Qtr ' + I;
end;
// create column header
fg.Cols[0].AllowMerging := True;
// two cells with same contents, will merge
rng := fg.GetCellRange(0, 0, 1, 0);
rng.Data := 'Sales by Product';
// align and autosize the cells
fg.Styles.Fixed.TextAlign := TextAlignEnum.CenterCenter;
fg.AutoSizeCols(1, fg.Cols.Count - 1, 10);
end;
This is the result:
Merged data views
Cell merging works the same way when the grid is bound to a data source. The code below shows an
example (the code uses a DataAdapter object that was created at design time):
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim i%
' bind the grid to a data source
Dim ds As New DataSet()
SqlDataAdapter1.Fill(ds)
fg.DataSource = ds.Tables(0)
' set up cell merging
fg.AllowMerging = AllowMergingEnum.RestrictCols
For i = fg.Cols.Fixed To fg.Cols.Count – 1
fg.Cols(i).AllowMerging = True
Next
End Sub
Merging Cells · 55
•
C#
private void Form1_Load( System.object sender,
{
// bind the grid to a data source
DataSet ds = new DataSet();
SqlDataAdapter1.Fill(ds);
fg.DataSource = ds.Tables[0];
System.EventArgs e)
// set up cell merging
fg.AllowMerging = AllowMergingEnum.RestrictCols;
for (int i = fg.Cols.Fixed; i <= fg.Cols.Count – 1; i++)
fg.Cols(i).AllowMerging = true;
}
•
Delphi
procedure Form1_Load(sender: System.Object;_
e: System.EventArgs);
var
I: Integer;
ds: DataSet;
begin
// bind the grid to a data source
ds := DataSet.Create;
SqlDataAdapter1.Fill(ds);
fg.DataSource := ds.Tables[0];
// set up cell merging
fg.AllowMerging := AllowMergingEnum.RestrictCols;
For i := fg.Cols.Fixed To fg.Cols.Count – 1 do
fg.Cols[i].AllowMerging := True;
end;
This is the result:
56 · Using the C1FlexGrid Control
Notice how merging the cells has the effect of visually grouping the data and making the information on
the table easier to understand.
Spilling Text
The AllowMerging property has two settings that operate differently from the others, and don't require
you to set the AllowMerging property on specific rows and columns.
1.
The Spill setting causes text that is too long to fit in a cell to spill into empty adjacent cells. The
resulting behavior is similar to the one in Microsoft Excel. If you type a long entry into a cell and
the adjacent cell is empty, the entry will spill to occupy as much room as needed.
For example, the picture below shows what a grid might look like when AllowMerging is set to
Spill and the user types entries of varying lengths:
2.
The Nodes setting is similar to Spill but only applies to outline nodes. This setting is useful when
data is organized into groups, and the node rows contain information in a format different from
the data rows.
For example, the picture below shows what a grid might look like when the data is grouped and
summarized using the Subtotal method, and then AllowMerging is set to Nodes:
Saving, Loading, and Printing · 57
This image is similar to the one in the previous topic, that described subtotals. The difference is
that the subtotal rows (nodes) now spill onto empty adjacent cells, improving the appearance of
the grid.
Custom Merging
You can customize the default merging behavior in two ways:
1.
Assign a custom IComparer class to the CustomComparer property.
By default, the grid will merge adjacent cells that contain the same non-null value. String comparisons are
case-sensitive and blanks are included.
If you wanted the grid to merge cells using a case-insensitive comparison and trimming blanks, you
could write a custom class that implements IComparer and assign it to the CustomComparer property.
2.
Write a new class that derives from the C1FlexGrid and override the GetMergedRange virtual
method, providing your own custom merging logic.
For examples that show how to implement custom merging logic, see the "CustomMerge" samples in our
on-line sample library.
Saving, Loading, and Printing
The C1FlexGrid control has methods that allow you to save, load, and print grids.
Saving and Loading Grids to Text Files
The SaveGrid method saves the grid contents to a text file. The method has parameters that control the
type of delimiter to use (e.g. commas, tabs, custom delimiters), whether to save the fixed cells or only the
scrollable cells, and the type of encoding to used (e.g. ASCII or Unicode). The resulting text files can later
be loaded back into the control, or into other applications that support comma or tab-delimited files (for
example, Microsoft Excel).
The LoadGrid method loads data from text files. You can load text files created with the SaveGrid
method or with other applications.
The format of the text files is fairly simple. Cell contents are saved as formatted strings (exactly as they
are displayed on the screen). If the cell text contains quote characters or cell separator characters, the cell
is enclosed in quotes. Any quote characters contained in the cell text are doubled. This is the also the
convention used in Microsoft Excel text files.
Text files do not contain pictures or formatting information.
The SaveGrid method has a flags parameter that allows you to specify whether you want to save the
entire grid or only certain parts (scrollable, visible, or selected).
Saving and Loading Microsoft Excel Files
Starting with version 2.5, you can use the SaveGrid and LoadGrid methods to save and load Microsoft
Excel files (xls) as well as text files. This allows you to save formatting information in addition to the data.
To save and load Excel files using the SaveGrid and LoadGrid methods, simply set the format parameter
to FileFormatEnum.Excel and call the methods as usual. You don't need to have Microsoft Excel installed
on your computer.
58 · Using the C1FlexGrid Control
Excel files contain "workbooks", which are made up of "worksheets". The SaveGrid and LoadGrid
methods always save books with a single sheet, and load the first sheet from existing books. If you want
additional control over which sheets to load or save, use the SaveExcel, LoadExcel, and
LoadExcelSheetNames methods instead. The process of saving and loading Excel files will convert most
data types and formatting information, including row and column dimensions, fonts, colors, formats, and
cell alignment. However, not all formatting elements can be converted. For example, the grid will load
the values in Excel cells, but it will not load the underlying formulas. Other features such as frozen and
merged cells, images, data maps, and cell borders are not translated either.
Loading Grids from Databases
You can also load grid data from a database. This is different from data binding, which keeps a live
connection between one or more controls and the underlying data source. To load data from a database,
you can use DataReader objects, as shown below:
•
Visual Basic
Private Sub _btnData_Click(sender As Object, e As System.EventArgs)
' prepare DataReader
Dim strConn As String = "data source=MYMACHINE;initial
catalog=Northwind;"
Dim myConn As New SqlConnection(strConn)
Dim myCMD As New SqlCommand("SELECT * FROM Employees", myConn)
myConn.Open()
Dim myReader As SqlDataReader = myCMD.ExecuteReader()
' build grid structure from DB schema
Dim dt As DataTable = myReader.GetSchemaTable()
_flex.Cols.Count = 1
Dim dr As DataRow
For Each dr In dt.Rows
Dim c As Column = _flex.Cols.Add()
c.Caption =(c.Name <<= CStr(dr("ColumnName")))
c.DataType = CType(dr("DataType"), Type)
Next dr
' populate grid
_flex.Rows.Count = 1
Dim row As Integer = 1
Dim cols As Integer = dt.Columns.Count
Dim v As Object() = _
CType(Array.CreateInstance(GetType(Object), cols), Object())
While myReader.Read()
myReader.GetValues(v)
_flex.AddItem(v, row ++, 1)
End While
' cleanup
_flex.AutoSizeCols()
myReader.Close()
myConn.Close()
End Sub '_btnData_Click
•
C#
private void _btnData_Click(object sender, System.EventArgs e)
{
// prepare DataReader
string strConn = "data source=MYMACHINE;initial catalog=Northwind;";
SqlConnection myConn = new SqlConnection(strConn);
SqlCommand myCMD = new SqlCommand("SELECT * FROM Employees", myConn);
myConn.Open();
Saving, Loading, and Printing · 59
SqlDataReader myReader = myCMD.ExecuteReader();
// build grid structure from DB schema
DataTable dt = myReader.GetSchemaTable();
_flex.Cols.Count = 1;
foreach (DataRow dr in dt.Rows)
{
Column c = _flex.Cols.Add();
c.Caption = c.Name = (string)dr["ColumnName"];
c.DataType = (Type)dr["DataType"];
}
// populate grid
_flex.Rows.Count = 1;
int row = 1;
int cols = dt.Columns.Count;
object[] v = (object[])Array.CreateInstance(typeof(object), cols);
while (myReader.Read())
{
myReader.GetValues(v);
_flex.AddItem(v, row++, 1);
}
// cleanup
_flex.AutoSizeCols();
myReader.Close();
myConn.Close();
}
•
Delphi
var
v: System.Array;
cols: Integer;
row: Integer;
dt: DataTable;
dr: DataRow;
myReader: SqlDataReader;
myCMD: SqlCommand;
myConn: SqlConnection;
strConn: string;
c: Column;
begin
// prepare DataReader
strConn := 'data source=MYMACHINE;initial catalog=Northwind;';
myConn := SqlConnection.Create(strConn);
myCMD := SqlCommand.Create('SELECT * FROM Employees', myConn);
myConn.Open;
myReader := myCMD.ExecuteReader;
// build grid structure from DB schema
dt := myReader.GetSchemaTable;
_flex.Cols.Count = 1
for I := 0 to dt.Rows.Count – 1 do
begin
dr := dt.Rows[I];
c := flex.Cols.Add;
c.Caption := string(dr['ColumnName']);
c.Name := string(dr['ColumnName']);
c.DataType := System.Type(dr['DataType']);
end;
// populate grid
flex.Rows.Count := 1;
row := 1;
60 · Using the C1FlexGrid Control
cols := dt.Columns.Count;
v := _ System.Array.CreateInstance(typeof(System.Object), cols),
cols);
While myReader.Read() do
begin
myReader.GetValues(v);
_flex.AddItem(v, row, 1);
row := row + 1;
end;
// cleanup
_flex.AutoSizeCols;
myReader.Close;
myConn.Close;
end; //_btnData_Click
Printing Grids
Use the PrintGrid method to print the contents of the grid. The method has parameters that allow you to
select the scaling mode, whether to display print/preview dialogs, set headers and footers, etc.
The PrintParameters property exposes additional printing properties such as the font to use for headers
and footers, and a .NET Framework PrintDocument object that can be used to select the printer, paper
size and orientation, margins, etc.
The code below uses the PrintParameters property to set up the page orientation, margins, header and
footer fonts. Then it calls the PrintGrid method to display a print preview dialog:
•
Visual Basic
' get grid's PrintDocument object
Dim pd As PrintDocument
pd = fg.PrintParameters.PrintDocument()
' set up the page (landscape, 1.5" left margin)
With pd.DefaultPageSettings
.Landscape = True
.Margins.Left = 150
End With
' set up header and footer fonts
fg.PrintParameters.HeaderFont = New Font("Arial Black", 14,
FontStyle.Bold)
fg.PrintParameters.FooterFont = New Font("Arial Narrow", 8,
FontStyle.Italic)
' preview the grid
fg.PrintGrid("VB Tutorial", _
PrintGridFlags.FitToPageWidth + PrintGridFlags.ShowPreviewDialog, _
"VB Tutorial" + Chr(9) + Chr(9) + Format(DateTime.Now, "d"), _
Chr(9) + Chr(9) + "Page {0} of {1}")
•
C#
// get grid's PrintDocument object
PrintDocument pd = fg.PrintParameters.PrintDocument();
// set up the page (landscape, 1.5" left margin)
pd.DefaultPageSettings;
.Landscape = true;
.Margins.Left = 150;
} With
// set up header and footer fonts
FlexGrid Property Groups · 61
fg.PrintParameters.HeaderFont = new Font("Arial Black", 14,
FontStyle.Bold);
fg.PrintParameters.FooterFont = new Font("Arial Narrow", 8,
FontStyle.Italic);
// preview the grid
fg.PrintGrid("VB Tutorial",
PrintGridFlags.FitToPageWidth | PrintGridFlags.ShowPreviewDialog,
"VB Tutorial\t\t" + Format(DateTime.Now, "d"),
"\t\tPage {0} of {1}");
•
Delphi
var
pd: PrintDocument;
begin
// get grid's PrintDocument object
pd := flex.PrintParameters.PrintDocument;
// set up the page (landscape, 1.5" left margin)
With pd.DefaultPageSettings do
begin
Landscape := True;
Margins.Left := 150;
End;
// set up header and footer fonts
flex.PrintParameters.HeaderFont := System.Drawing.Font.Create('Arial
Black', 14, FontStyle.Bold);
flex.PrintParameters.FooterFont := System.Drawing.Font.Create('Arial
Narrow', 8, FontStyle.Italic);
// preview the grid
flex.PrintGrid('VB Tutorial',
PrintGridFlags.FitToPageWidth or PrintGridFlags.ShowPreviewDialog,
'VB Tutorial'#9#9 + Format(DateTime.Now, 'd'),
#9#9 + 'Page {0} of {1}');
end;
FlexGrid Property Groups
The C1FlexGrid control has a rich set of properties, methods, and events. You do not have to know all of
them in order to use the control effectively.
The reference below shows the most important properties, methods, and events grouped by usage type.
Some elements appear in more than one group. For details on specific elements, please refer to the
reference part of this document.
1) Grid Layout
Rows, Cols, AutoSizeCols, ScrollBars, ScrollTrack
2) Cursor and Selection
SelectionMode, Select, ShowCell, Row, Col, RowSel, ColSel, SelectionBeforeMouseDown,
MouseRow, MouseCol,
BeforeRowColChange, AfterRowColChange, BeforeSelChange, AfterSelChange,
KeyActionTab, KeyActionEnter
62 · Using the C1FlexGrid Control
3) Editing
AllowEditing, ComboList, EditMask,
BeforeEdit, StartEdit, ValidateEdit, AfterEdit,
StartEditing, FinishEditing, Editor, CellButtonClick,
KeyDownEdit, KeyPressEdit, KeyUpEdit, ChangeEdit
4) Getting and Setting Values
Item (indexer), GetData, GetDataDisplay, SetData, GetCellRange,
GetCellImage, SetCellImage, Clip, FindRow, Aggregate, CellChanged
5) User Interface
AllowEditing, AllowMerging, AllowResizing, AllowDragging,
AllowSorting, BeforeSort, AfterSort, AutoSearch, AutoSearchDelay
BeforeDragColumn, AfterDragColumn, BeforeDragRow, AfterDragRow,
BeforeResizeColumn, AfterResizeColumn, BeforeResizeRow, AfterResizeRow,
ScrollTips, ScrollTipText, BeforeScrollTip
6) Outlining and Summarizing
Subtotal, Tree, Rows(index).IsNode, Node.Level,
Node.Collapsed, BeforeCollapse, AfterCollapse
7) Merging Cells
AllowMerging, GetMergedRange
8) Data Binding
DataSource, DataMember, AfterDataRefresh, AutoResize, GridError
9) Saving, Loading, and Printing Grids
LoadGrid, SaveGrid, LoadExcel, SaveExcel, ClipSeparators, PrintGrid
10) OLE Drag Drop
DragMode, DropMode, BeforeMouseDown
Visual Basic Samples · 63
FlexGrid Samples
The following samples are included with this product. Various product samples and demos may include
other ComponentOne controls. Although the samples included are used to demonstrate product features
and how the control may be integrated with the rest of the ComponentOne product line, some controls
used in the samples may not be included with the purchase of an individual product.
Visual Basic Samples
AutoSizeEdit
Resize the editor while the user types. This sample uses the
C1FlexGrid control.
BarChart
Draw bar charts using the grid cells. This sample uses the C1FlexGrid
control.
Benchmark
Compares data-binding performance for FlexGrid and MSDataGrid.
This sample uses the C1FlexGrid and C1TrueDBGrid controls.
Blinker
Use CellStyles to make cells blink. This sample uses the C1FlexGrid
control.
BoundDelete
Deletes rows from a bound FlexGrid. This sample uses the C1FlexGrid
control.
BoundFinishEdit
Commit changed to DataRow after editing. This sample uses the
C1FlexGrid control.
BoundImage
Bind the grid to image fields stored as OLE objects. This sample uses
the C1FlexGrid control.
CellBorders
Use OwnerDraw to provide custom cell borders. This sample uses the
C1FlexGrid control.
CellDataType
Assign cell types (and editors) on a per-cell basis. This sample uses
the C1FlexGrid control.
CellMerging
Shows various types of cell-merging in a FlexGrid control. This sample
uses the C1FlexGrid control.
Clipboard
Add clipboard support to the FlexGrid control. This sample uses the
C1FlexGrid control.
ColumnEditor
Expose the FlexGrid design-time column editor in your controls. This
sample uses the C1FlexGrid control.
CustomDataMap
Customize the options in drop-down lists when using DataMaps. This
sample uses the C1FlexGrid control.
CustomEditor
Implement your own cell editor. This sample uses the C1FlexGrid
control.
64 · FlexGrid Samples
CustomMerge
Implement your own merging logic to create a TV-guide display. This
sample calls the C1.Win.C1FlexGrid namespace.
CustomMerge2
Implement your own merging logic to mix merging modes. This sample
calls the C1.Win.C1FlexGrid namespace.
CustomMerge3
Shows how to customize grouping by overriding the GetData method.
This sample calls the C1.Win.C1FlexGrid namespace.
CustomMerge4
Shows how to customize grouping by overriding the GetData method.
This sample calls the C1.Win.C1FlexGrid namespace.
CustomPrint
Use the CreateImage method to print grids with arbitrary row and
column breaks. This sample uses the C1FlexGrid control.
CustomTree
Use the C1FlexGrid control to build a tree. This sample uses the
C1FlexGrid control.
DataIndex
Use the Row.DataIndex property to get the underlying data row. This
sample uses the C1FlexGrid control.
DataMap
Use data-mapped columns when bound to a data source. This sample
uses the C1FlexGrid control.
DataReader
Populate a grid from a DataReader. This sample uses the C1FlexGrid
control.
DataTable
Bind to a DataTable, add and remove rows. This sample uses the
C1FlexGrid control.
DataTableDictionary
Shows how to build DataMaps from DataTable objects. This sample
uses the C1FlexGrid control.
DBDynamicStyles
Assign styles to grid cells based on their contents. This sample uses
the C1FlexGrid control.
DBImageField
Show images stored in a DataTable. This sample uses the C1FlexGrid
control.
DBSchemaChange
Test grid response to changes in the data source object. This sample
uses the C1FlexGrid control.
DBTree
Display bound data in a hierarchical tree view. This sample uses the
C1FlexGrid control.
DragDrop
Customize automatic Drag & Drop. This sample uses the C1FlexGrid
control.
DragRow
Drag rows between grids. This sample uses the C1FlexGrid control.
DynamicStyles
Assign styles to a cell based on the contents of another cell. This
sample uses the C1FlexGrid control.
Editing
Edit cells using textboxes, lists, masks, and checkboxes. This sample
uses the C1FlexGrid control.
Visual Basic Samples · 65
FlexByRow
Set up a grid in 'transposed' format. This sample uses the C1FlexGrid
control.
FlexGroup
Implement Outlook-style grouping and filtering using the FlexGrid. This
sample uses the C1FlexGrid control.
FreezeBottom
Show frozen rows at the bottom of a grid. This sample uses the
C1FlexGrid control.
GridChart
Attach a FlexGrid to a C1Chart control. This sample uses the
C1FlexGrid and C1Chart controls.
HierData
Bind to hierarchical data sources (master-detail style). This sample
uses the C1FlexGrid control.
Hyperlink
Add hyperlinks to cells in the FlexGrid. This sample uses the
C1FlexGrid control.
MapAndGroup
Shows grouping and sorting behavior when using data-mapped
columns. This sample uses the C1FlexGrid control.
MergeStyles
Merge CellStyles assigned to rows, columns, and cells. This sample
uses the C1FlexGrid control.
MultiColumnDropDown
Multi-column drop-down editor for use with the C1FlexGrid. This
sample uses the C1FlexGrid control.
Outline
Hide repeated data in an outline. This sample uses the C1FlexGrid
control.
PrintPreview
Provide print preview with the C1PrintPreview control (in three ways).
This sample uses the C1FlexGrid, C1PrintDocument, C1PrintPreview,
and PreviewToolBarButton controls.
ProductTree
Build a custom tree with product information. This sample uses the
C1FlexGrid control.
RTFGrid
Display RTF text in grid cells. This sample uses the C1FlexGrid control.
ScrollPosition
Shows how the ScrollPosition property works. This sample uses the
C1FlexGrid control.
SelectionMode
Shows the effect of the SelectionMode property. This sample uses the
C1FlexGrid control.
Sorting
Shows several sorting techniques. This sample uses the C1FlexGrid
control.
Splits
Split a C1FlexGrid into multiple views. This sample uses the
C1FlexGrid control.
StartEditing
Implement a grid that stays in cell-editing mode. This sample uses the
C1FlexGrid control.
Styles
Shows how you can use Styles to customize the appearance of the
C1FlexGrid. This sample uses the C1FlexGrid control.
66 · FlexGrid Samples
Subtotals
Create subtotals for multiple columns. This sample uses the
C1FlexGrid control.
Transpose
Transpose data in a grid. This sample uses the C1FlexGrid control.
TreeCheck
Add checkboxes to a grid tree. This sample uses the C1FlexGrid
control.
TreeNode
Manage an outline tree using the FlexGrid Node objects. This sample
uses the C1FlexGrid control.
Tut_Analyze
Provide dynamic sorting and grouping. This sample uses the
C1FlexGrid control.
Tut_Edit
Edit cells using textboxes, lists, masks, and checkboxes. This sample
uses the C1FlexGrid control.
Tut_XMLTree
Populate the grid from an XML document. This sample uses the
C1FlexGrid control.
Validate
Use the ErrorProvider control with the FlexGrid. This sample uses the
C1FlexGrid control.
C# Samples
Analyze
Provide dynamic data sorting and grouping. This sample uses the
C1FlexGrid control.
AutoSizeEdit
Resize the editor while the user types. This sample uses the
C1FlexGrid control.
BarChart
Draw bar charts using the grid cells. This sample uses the C1FlexGrid
control.
Benchmark
Compares data-binding performance for FlexGrid and MSDataGrid.
This sample uses the C1FlexGrid and C1TrueDBGrid controls.
BoundDelete
Deletes rows from a bound FlexGrid. This sample uses the C1FlexGrid
control.
BoundFinishEdit
Commit changed to DataRow after editing. This sample uses the
C1FlexGrid control.
BoundImage
Bind the grid to image fields stored as OLE objects. This sample uses
the C1FlexGrid control.
BoundImageMap
Use the ImageMap property with a data-bound grid. This sample uses
the C1FlexGrid control.
CellBorders
Use OwnerDraw to provide custom cell borders. This sample uses the
C1FlexGrid control.
C# Samples · 67
CellDataType
Assign cell types (and editors) on a per-cell basis. This sample uses
the C1FlexGrid control.
CellLabels
Show labels when text is too long to fit a cell. This sample uses the
C1FlexGrid control.
Clipboard
Add clipboard support to the FlexGrid control. This sample uses the
C1FlexGrid control.
ColumnEditor
Expose the FlexGrid design-time column editor in your controls. This
sample uses the C1FlexGrid control.
ColumnOrder
Position columns dynamically. This sample uses the C1FlexGrid
control.
CustomData
Implement a custom data source object. This sample uses the
C1FlexGrid control.
CustomDataMap
Customize the options in drop-down lists when using DataMaps. This
sample uses the C1FlexGrid control.
CustomDataSource
Implements a custom data source object and binds it to a grid. This
sample uses the C1FlexGrid control.
CustomEditor
Implement your own cell editor. This sample uses the C1FlexGrid
control.
CustomMerge
Implement your own merging logic to create a TV-guide display. This
sample calls the C1.Win.C1FlexGrid namespace.
CustomMerge2
Implement your own merging logic to mix merging modes. This sample
calls the C1.Win.C1FlexGrid namespace.
CustomMerge3
Shows how to customize grouping by overriding the GetData method.
This sample calls the C1.Win.C1FlexGrid namespace.
CustomMerge4
Shows how to customize grouping by overriding the GetData method.
This sample calls the C1.Win.C1FlexGrid namespace.
CustomPrint
Use the CreateImage method to print grids with arbitrary row and
column breaks. This sample uses the C1FlexGrid control.
CustomSelection
Uses OwnerDraw to implement custom (non-rectangular) selection.
This sample calls the C1.Win.C1FlexGrid namespace.
CustomSort
Implement your own sorting logic with a custom IComparer object. This
sample uses the C1FlexGrid control.
DataIndex
Use the Row.DataIndex property to get the underlying data row. This
sample uses the C1FlexGrid control.
DataMap
Use data-mapped columns when bound to a data source. This sample
uses the C1FlexGrid control.
DataReader
Populate a grid from a DataReader. This sample uses the C1FlexGrid
control.
68 · FlexGrid Samples
DataTable
Bind to a DataTable, add and remove rows. This sample uses the
C1FlexGrid control.
DataTableDictionary
Shows how to build DataMaps from DataTable objects. This sample
uses the C1FlexGrid control.
DataTree
Bind the grid to a hierarchical data source and show details in child
grids. This sample calls the C1.Win.C1FlexGrid namespace.
DBDynamicStyles
Assign styles to grid cells based on their contents. This sample uses
the C1FlexGrid control.
DBImageField
Show images stored in a DataTable. This sample uses the C1FlexGrid
control.
DBImages
Bind the grid to a data base with image fields stored as OLE objects.
This sample uses the C1FlexGrid control.
DBSchemaChange
Test grid response to changes in the data source object. This sample
uses the C1FlexGrid control.
DBTree
Display bound data in a hierarchical tree view. This sample uses the
C1FlexGrid control.
DBUpdate
Save changes to the underlying database. This sample uses the
C1FlexGrid control.
DragDrop
Customize automatic Drag & Drop This sample uses the C1FlexGrid
control.
DragMerged
Drag groups of merged columns. This sample uses the C1FlexGrid
control.
DragRow
Drag rows between grids. This sample uses the C1FlexGrid control.
DynamicStyles
Assign styles to a cell based on the contents of another cell. This
sample uses the C1FlexGrid control.
FilterRow
Implement a FilterRow on a FlexGrid control. This sample uses the
C1FlexGrid control.
FindRow
How to find a row in the underlying datasource. This sample uses the
C1FlexGrid control.
FlexByRow
Set up a grid in 'transposed' format. This sample uses the C1FlexGrid
control.
FlexGroup
Implement Outlook-style grouping using the FlexGrid. This sample
uses the C1FlexGrid control.
FlexHierarchical
Implement hierarchical data binding using the FlexGrid. This sample
calls the C1.Win.C1FlexGrid namespace.
FlexHierC1Data
Implement hierarchical data binding using the FlexGrid and C1Data.
This sample uses the C1DataSet and C1SchemaDef controls and calls
the C1.Win.C1FlexGrid namespace.
C# Samples · 69
FreezeBottom
Show frozen rows at the bottom of a grid. This sample uses the
C1FlexGrid control.
GridChart
Attach a FlexGrid to a C1Chart control. This sample uses the
C1FlexGrid and C1Chart controls.
HierData
Bind to hierarchical data sources (master-detail style). This sample
uses the C1FlexGrid control.
HostControls
Host controls in grid cells. This sample uses the C1FlexGrid control.
Hyperlink
Add hyperlinks to cells in the FlexGrid. This sample uses the
C1FlexGrid control.
MasterDetail
Shows how to create and bind master-detail DataSets in code. This
sample calls the C1.Win.C1FlexGrid namespace.
MergeStyles
Merge CellStyles assigned to rows, columns, and cells. This sample
uses the C1FlexGrid control.
MultiColumnDropDown
Multi-column drop-down editor for use with the C1FlexGrid. This
sample uses the C1FlexGrid control.
NumericInput
Implement your own cell editor for numeric input. This sample uses the
C1FlexGrid control.
Outline
Hide repeated data in an outline. This sample uses the C1FlexGrid
control.
PasswordChar
Use the C1FlexGrid to enter and edit passwords. This sample uses the
C1FlexGrid control.
PrintPreview
Provide print preview with the C1PrintPreview control (in three ways).
This sample uses the C1FlexGrid, C1PrintDocument, C1PrintPreview,
and PreviewToolBarButton controls.
RowStateDisplay
Use different styles to display DataRows in different states. This
sample uses the C1FlexGrid control.
RTFGrid
Display RTF text in grid cells. This sample uses the C1FlexGrid control.
ScrollPosition
Shows how the ScrollPosition property works. This sample uses the
C1FlexGrid control.
SelectionMode
Shows the effect of the SelectionMode property. This sample uses the
C1FlexGrid control.
SetupEditor
Use the SetupEditor event to customize the grid editors. This sample
uses the C1FlexGrid control.
Sorting
Shows several sorting techniques. This sample uses the C1FlexGrid
control.
Splits
Split a C1FlexGrid into multiple views. This sample uses the
C1FlexGrid control.
70 · FlexGrid Samples
StartEditing
Implement a grid that stays in cell-editing mode. This sample uses the
C1FlexGrid control.
Subtotals
Create subtotals for multiple columns. This sample uses the
C1FlexGrid control.
Transpose
Transpose data in a grid. This sample uses the C1FlexGrid control.
TreeCheck
Add checkboxes to a grid tree. This sample uses the C1FlexGrid
control.
TreeNode
Manage an outline tree using the FlexGrid Node objects. This sample
uses the C1FlexGrid control.
TriStateBound
Provide three-state (grayable) values in boolean columns. This sample
calls the C1.Win.C1FlexGrid namespace.
ComponentOne FlexGrid for Mobile Devices Samples
Analyze
Provide dynamic data sorting and grouping. This sample uses the C1FlexGrid
control.
BarChart
Draw bar charts using the grid cells. This sample uses the C1FlexGrid control.
EditData
Shows different types of built-in editors and dynamic formatting. This sample uses
the C1FlexGrid control.
Edit Tutorial · 71
FlexGrid Tutorials
The following sections contain tutorials that illustrate some of the main features in the C1FlexGrid
control. The tutorials walk you through the creation of several simple projects, describing each step in
detail. The distribution CD contains more sophisticated samples that can be used as a reference.
The tutorials are:
Edit
Starting with a basic data-entry grid, this tutorial shows how to implement data
formatting, check boxes, drop-down lists, input masks, data validation, and
clipboard support.
Outline
Shows how you can use the C1FlexGrid as an outliner to display structured (or
hierarchical) data.
Data Analysis
Starting with a grid containing sales data for different products, regions, and
salespeople, this tutorial show how to implement dynamic layout (column order),
automatic sorting, cell merging, automatic subtotals, and outlining.
Edit Tutorial
This tutorial starts with a basic data-entry grid, then adds the following features:
1.
Formatting
2.
Check boxes
3.
Drop-down lists
4.
Complex data validation
5.
Clipboard support
6.
Custom editors
Here is what the final application will look like:
72 · FlexGrid Tutorials
Step 1: Create the C1FlexGrid Control
Start a new Visual Basic project and add a C1FlexGrid control to the form by clicking the C1FlexGrid
icon on the toolbox, then clicking on the form and dragging until the object has the proper size.
If you can't find the C1FlexGrid control in the toolbox, right-click on the toolbox and select the
Customize Toolbox option. Then, look for the C1FlexGrid control on the list of .NET components and
make sure it is checked. If you can't find the grid in the component list, you may need to re-install the
product.
Next, use the .NET properties window to set the following control properties:
(Name) = fg
Dock = Fill
Cols.Count = 5
Cols.Fixed = 0
Now double-click the form caption area to open the code window. At the top of the file, add the
following statement:
•
Visual Basic
Imports C1.Win.C1FlexGrid
•
C#
using C1.Win.C1FlexGrid;
•
Delphi
uses C1.Win.C1FlexGrid;
This makes the objects defined in the C1FlexGrid assembly visible to the project and saves a lot of typing.
Next, type (or copy) the following code that sets up the grid when the form loads:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' set up columns
Dim cols As String = "Product|Region|Salesperson|Sales|Bonus"
Dim colNames As String() = cols.Split("|")
Dim i%
For i = 0 To fg.Cols.Count – 1
fg(0, i) = colNames(i)
fg.Cols(i).Name = colNames(i)
Next
End Sub
•
C#
private void Form1_Load( System.object sender, System.EventArgs e)
{
// set up columns
string cols = "Product|Region|Salesperson|Sales|Bonus";
string[]colNames = cols.Split("|");
for (int i = 0; i < fg.Cols.Count; i++)
{
fg[0, i] = colNames[i];
fg.Cols[i].Name = colNames[i];
}
}
Edit Tutorial · 73
•
Delphi
procedure Form1_Load(sender: System.Object;_
e: System.EventArgs);
var
cols: string;
colNames: array of string;
I: Integer;
begin
// set up columns
cols := 'Product|Region|Salesperson|Sales|Bonus';
colNames := cols.Split('|');
For i := 0 To fg.Cols.Count – 1 do
begin
fg[0, i] := colNames[i];
fg.Cols[i].Name := colNames[i];
end;
end;
That's it. Press F5 to run the project, and you can start typing data into the control. Press F2 or the space
bar to edit existing entries, or just type new entries over existing ones.
Step 2: Set Column Types and Formats
When displaying numeric or date values, you will typically want to adopt a consistent format for the
values. The C1FlexGrid control allows you to specify the DataType and Format for each column.
To specify the DataType and Format for the columns, add the following code to the Form_Load event:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' set up columns
Dim cols As String = "Product|Region|Salesperson|Sales|Bonus"
Dim colNames As String() = cols.Split("|")
Dim i%
For i = 0 To fg.Cols.Count – 1
fg(0, i) = colNames(i)
fg.Cols(i).Name = colNames(i)
Next
' set column DataType and Format
Dim c As Column = fg.Cols("Sales")
c.DataType = GetType(Decimal)
c.Format = "c" ' << currency
c = fg.Cols("Bonus")
c.DataType = GetType(Boolean)
c.ImageAlign = ImageAlignEnum.CenterCenter
End Sub
•
C#
private void Form1_Load( System.object sender, System.EventArgs e)
{
// set up columns
string cols = "Product|Region|Salesperson|Sales|Bonus";
string[] colNames = cols.Split('|');
for (int i = 0; i <= fg.Cols.Count – 1; i++)
{
fg[0, i] = colNames[i];
fg.Cols[i].Name = colNames[i];
74 · FlexGrid Tutorials
} //
// set column DataType and Format
Column c = fg.Cols["Sales"];
c.DataType = typeof(Decimal);
c.Format = "c"; // << currency
c = fg.Cols["Bonus"];
c.DataType = typeof(bool);
c.ImageAlign = ImageAlignEnum.CenterCenter;
}
•
Delphi
procedure Form1_Load(sender: System.Object;
e: System.EventArgs);
var
cols: string;
colNames: array of string;
I: Integer;
c: Column;
begin
// set up columns
cols := 'Product|Region|Salesperson|Sales|Bonus';
colNames := cols.Split('|');
for i := 0 to fg.Cols.Count – 1 do
begin
fg[0, i] := colNames[i];
fg.Cols[i].Name := colNames[i];
end;
// set column DataType and Format
Dim c As Column := fg.Cols['Sales'];
c.DataType := typeof(Decimal);
c.Format := 'c'; // << currency
c := fg.Cols['Bonus'];
c.DataType := typeof(Boolean);
c.ImageAlign := ImageAlignEnum.CenterCenter;
end;
The new code formats the "Sales" column to store and display currency values, and the "Bonus" column
to deal with Boolean values.
If you run the project now, you will notice that the grid won't accept non-numeric entries in the "Sales"
column. The Bonus column displays values as checkboxes, which can be toggled with the mouse or with
the keyboard. This is the default behavior for Boolean columns.
Note that the Format property does not affect the data in any way, only how it is displayed.
Step 3: Drop-Down Lists
Entering data is a tedious and error-prone process. Drop-down lists are great because they minimize the
amount of typing you must do, reduce the chance of errors, and increase the consistency of the data.
Let's assume that our sample project only involves sales of three products (Applets, Widgets, and
Gadgets), in four regions (North, South, East, and West), and that there are three full-time sales people
(Mary, Sarah, and Paula).
To use these lists as drop-downs in the C1FlexGrid control, all you have to do is build strings containing
the items in each list (separated by pipe characters) and assign them to the ComboList property of each
column.
Edit Tutorial · 75
To add the combolists, add the following code to the Form_Load event:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' set up columns
Dim cols As String = "Product|Region|Salesperson|Sales|Bonus"
Dim colNames As String() = cols.Split("|")
Dim i%
For i = 0 To fg.Cols.Count – 1
fg(0, i) = colNames(i)
fg.Cols(i).Name = colNames(i)
Next
' set column DataType and Format
Dim c As Column = fg.Cols("Sales")
c.DataType = GetType(Decimal)
c.Format = "c" ' << currency
c = fg.Cols("Bonus")
c.DataType = GetType(Boolean)
c.ImageAlign = ImageAlignEnum.CenterCenter
' set up drop-down lists
fg.Cols("Product").ComboList = "Applets|Wahoos|Gadgets"
fg.Cols("Region").ComboList = "North|South|East|West"
fg.Cols("Salesperson").ComboList = "|Mary|Paula|Sarah"
End Sub
•
C#
private void Form1_Load( System.object sender, System.EventArgs e)
{
// set up columns
string cols = "Product|Region|Salesperson|Sales|Bonus";
string[] colNames = cols.Split("|");
for (int i = 0; i <= fg.Cols.Count – 1; i++)
{
fg[0, i] = colNames[i];
fg.Cols[i].Name = colNames[i];
} //
// set column DataType and Format
Column c = fg.Cols["Sales"];
c.DataType = typeof(Decimal);
c.Format = "c"; // << currency
c = fg.Cols["Bonus"];
c.DataType = typeof(bool);
c.ImageAlign = ImageAlignEnum.CenterCenter;
// set up drop-down lists
fg.Cols["Product"].ComboList = "Applets|Wahoos|Gadgets";
fg.Cols["Region"].ComboList = "North|South|East|West";
fg.Cols["Salesperson"].ComboList = "|Mary|Paula|Sarah";
}
•
Delphi
procedure Form1_Load(sender: System.Object;
e: System.EventArgs);
var
cols: string;
colNames: array of string;
I: Integer;
76 · FlexGrid Tutorials
begin
// set up columns
cols := 'Product|Region|Salesperson|Sales|Bonus';
colNames := cols.Split('|');
for i := 0 to fg.Cols.Count – 1 do
begin
fg[0, i] := colNames[i];
fg.Cols[i].Name := colNames[I];
Next
// set column DataType and Format
c := fg.Cols['Sales'];
c.DataType := typeof(Decimal);
c.Format := 'c' // << currency
c := fg.Cols['Bonus'];
c.DataType := typeof(Boolean);
c.ImageAlign := ImageAlignEnum.CenterCenter;
// set up drop-down lists
fg.Cols['Product'].ComboList := 'Applets|Wahoos|Gadgets';
fg.Cols['Region'].ComboList := 'North|South|East|West';
fg.Cols['Salesperson'].ComboList := '|Mary|Paula|Sarah';
end;
Notice how the last ComboList string starts with a pipe. This allows users to type additional names that
are not on the list. In other words, these values will be edited using a drop-down combo, as opposed to a
simple drop-down list.
Press F5 to run the project again, then move the cursor around. When you move the cursor to one of the
columns that have combo lists, a drop-down button becomes visible. You may click on it to show the list,
or simply type the first letter of an entry to highlight it on the list.
Step 4: Data Validation
If you assign a data type to a grid column, the grid will ensure that only data of the proper type is stored
in that column. This helps prevent errors, but you will often need stricter validation to ensure that the
data entered is correct. For that, you should use the ValidateEdit event.
For example, imagine that anti-trust regulations prevent us from selling our Applets in the North region.
To prevent data-entry mistakes and costly lawsuits, we want to prevent users from entering this
combination into the control.
The following code checks the data after each edit and prevents invalid entries:
•
Visual Basic
Private Sub fg_ValidateEdit(ByVal sender As Object, _
ByVal e As ValidateEditEventArgs) Handles fg.ValidateEdit
Dim rgn As String, prd As String
' collect the data we need
Select Case e.Col
Case 0
prd = fg.Editor.Text
rgn = fg(e.Row, "Region")
Case 1
prd = fg(e.Row, "Product")
rgn = fg.Editor.Text
End Select
' we can't sell Applets in the North Region...
If prd = "Applets" And rgn = "North" Then
MsgBox("Warning: Regulation #12333AS/SDA-23 forbids " & _
Edit Tutorial · 77
"the sale of " & prd & " in region " & rgn & ". " & _
"Please verify input.")
e.Cancel = True
End If
End Sub
•
C#
private void fg_ValidateEdit( object sender,
{
string rgn = string.Empty;
string prd = string.Empty;
ValidateEditEventArgs e)
// collect the data we need
switch (e.Col)
{
case 0:
prd = fg.Editor.Text;
rgn = (string)fg[e.Row, "Region"];
break;
case 1:
prd = (string)fg[e.Row, "Product"];
rgn = fg.Editor.Text;
break;
}
// we can't sell Applets in the North Region...
if ( prd == "Applets" && rgn == "North" ) {
MessageBox.Show("Warning: Regulation #12333AS/SDA-23 forbids "
+
}
"the sale of " + prd + " in region " + rgn + ". " +
"Please verify input.");
e.Cancel = true;
}
•
Delphi
procedure fg_ValidateEdit(sender: System.Object;
e: ValidateEditEventArgs);
var
rgn: string;
prd: string;
begin
// collect the data we need
case e.Col of
0:
begin
prd := fg.Editor.Text;
rgn := fg[e.Row, 'Region'];
end;
1:
begin
prd := fg[e.Row, 'Product'];
rgn := fg.Editor.Text;
end;
end;
// we can't sell Applets in the North Region...
If (prd = 'Applets') And (rgn = 'North') Then
begin
MsgBox('Warning: Regulation #12333AS/SDA-23 forbids ' + _
'the sale of ' + prd + ' in region ' + rgn + ". " + _
'Please verify input.');
e.Cancel := True;
78 · FlexGrid Tutorials
end;
end;
The function starts by gathering the input that needs to be validated. Note that the values being checked
are retrieved using the Editor.Text property. This is necessary because the edits have not yet been applied
to the control. If the test fails, the function displays a warning and then sets the Cancel parameter to True,
which cancels the edits and puts the cell back in edit mode so the user can try again.
Press F5 to run the project again, then try inputting some bad values. You will see that the control will
reject them.
Step 5: Clipboard Support
The Windows clipboard is a very useful device for transferring information between applications.
Adding clipboard support to FlexGrid projects is fairly easy. Simply set the AutoClipboard property to
true and the grid will automatically handle all standard keyboard commands related to the clipboard:
ctrl-X or shift-Delete to cut, ctrl -C or ctrl-Insert to copy, and ctrl-V or shift-Insert to paste.
Another great Windows feature that is closely related to clipboard operations is OLE Drag and Drop.
C1FlexGrid has two properties, DragMode and DropMode, that help implement this feature. Just set
both properties to their automatic settings and you will be able to drag selections by their edges and drop
them into other applications such as Microsoft Excel, or drag ranges from an Excel spreadsheet and drop
them into the C1FlexGrid control.
Press F5 to run the project again, then try copying and pasting some data. Note that you can paste invalid
data, because our paste code does not perform any data validation. This is left as an exercise for the
reader.
Step 6: Custom Editors
The C1FlexGrid has powerful built-in editors for entering text, masked text, selecting from lists,
checkboxes, and more. But in some cases you may want to use a custom editor instead, perhaps one of
the input controls in the C1Input library or a control that you wrote. Starting in version 2.5, the FlexGrid
allows you to easily plug-in custom editors. To attach a custom editor to the Sales column on our sample,
start by adding a NumericUpDown control to the form. Next, use the .NET properties window to
configure the new control setting the following properties:
BorderStyle = None
Visible = False
DecimalPlaces = 2
ThousandsSeparator = True
Maximum = 5000000
Then, right-click the grid and select "Edit Columns…" to bring up the grid's column editor.
Select the third column (where the Sales figures will be), and set the Editor property to
numericUpDown1, as shown in the following image:
Edit Tutorial · 79
Now run the project and try editing some values in the "Sales" column. Notice that the grid uses the
NumericUpDown control instead of the built-in editors. The control is properly positioned, initialized,
and managed. When you move the focus to a different cell, the value is stored in the grid.
But the custom editor doesn't behave exactly like the built-in ones. For example:
1.
When you start editing by typing a number, the old value isn't cleared.
2.
The size of the editor isn't exactly right (it looks a bit too small).
3.
There's an annoying beep when you press Enter to finish editing.
You can overcome these problems in a couple of ways. One would be to use the editor's events, but that
would make it difficult to reuse the control in other projects. Another would be to create a derived class
and implement some methods in the IC1EmbeddedEditor interface.
For example, the code below implements three methods:
C1EditorInitialize is called to initialize the editor. It sets the initial value and then selects the whole entry.
This will take care of the first problem. Because the whole entry is selected, typing the first character will
now replace the current contents as we want.
C1EditorUpdateBounds is called to position the editor over the cell being edited. The height of the
NumericUpDown control is set automatically based on the font size, though (that is why it looks too
short for the cell). The code sets the editor's FontHeight property so it will be positioned exactly over the
cell.
Finally, the code overrides the ProcessDialogKey method to suppress the annoying beeps when the user
presses the Enter key.
•
Visual Basic
Public Class MyUpDown
Inherits NumericUpDown
80 · FlexGrid Tutorials
' set initial value
Public Sub C1EditorInitialize(ByVal value As Object, _
ByVal editorAttributes As IDictionary)
value = Convert.ChangeType(value, GetType(Decimal))
MyBase.Select(0, Int32.MaxValue)
End Sub
' set FontHeight so the control honors the rectangle height
Public Sub C1EditorUpdateBounds(ByVal rc As Rectangle)
MyBase.FontHeight = rc.Height
Bounds = rc
End Sub
' suppress annoying beeps when user hits enter
Protected Overrides Function ProcessDialogKey(ByVal keyData As
Keys) As Boolean
If (keyData = Keys.Enter) Then
Parent.Focus()
If (Parent.Focused) Then SendKeys.Send("{Down}")
Return True
End If
Return MyBase.ProcessDialogKey(keyData)
End Function
End Class
•
C#
internal class MyUpDown : NumericUpDown
{
// set initial value
public void C1EditorInitialize(object value, IDictionary
editorAttributes)
{
// apply initial value
Value = (decimal)Convert.ChangeType(value, typeof(decimal));
}
// select the whole entry
Select(0, int.MaxValue);
// set FontHeight so the control honors the rectangle height
public void C1EditorUpdateBounds(Rectangle rc)
{
base.FontHeight = rc.Height;
Bounds = rc;
}
// suppress annoying beeps when user hits enter
override protected bool ProcessDialogKey(Keys keyData)
{
if (keyData == Keys.Enter)
{
Parent.Focus();
if (Parent.Focused) SendKeys.Send("{Down}");
return true;
}
return base.ProcessDialogKey(keyData);
}
}
•
Delphi
type TMyUpDown = class(NumericUpDown)
public
Outline Tutorial · 81
procedure C1EditorInitialize(value: System.Object; editorAttributes:
IDictionary);
procedure C1EditorUpdateBounds(rc: Rectangle);
function ProcessDialogKey(keyData: Keys): boolean;
end;
procedure TMyUpDown.C1EditorInitialize(value: System.Object;
editorAttributes: IDictionary);
begin
// apply initial value
value := Currency(Convert.ChangeType(value, TypeOf(Currency)));
// select the whole entry
Select(0, System.Int32.MaxValue);
end;
procedure TMyUpDown.C1EditorUpdateBounds(rc: Rectangle);
begin
inherited FontHeight := rc.Height;
Bounds := rc;
end;
function TMyUpDown.ProcessDialogKey(keyData: Keys): boolean;
begin
if (keyData = Keys.Enter) then
begin
Parent.Focus;
if (Parent.Focused) then
SendKeys.Send(‘{Down}’);
Result := true;
Exit;
end;
Result := inherited ProcessDialogKey(keyData);
end;
Outline Tutorial
This sample shows how you can use the C1FlexGrid as an outliner to display structured (or hierarchical)
data. When used as an outliner, the C1FlexGrid control behaves like a Tree control, displaying nodes that
can be collapsed or expanded to show branches containing subordinate data.
The sample allows you to load an XML document into the grid, where it is displayed as a tree. Here is
what the final application will look like:
82 · FlexGrid Tutorials
Step 1: Create the Controls
Start a new Visual Basic project and add two controls:
1.
A command button near the top of the form, and
2.
A C1FlexGrid control in the area below the button.
If you can't find the C1FlexGrid control in the toolbox, right-click on the toolbox and select the
Customize Toolbox option. Then, look for the C1FlexGrid control on the list of .NET components and
make sure it is checked. If you can't find the grid in the component list, you may need to re-install the
product.
Next, use the .NET properties window to set the following properties:
1.
Command button
Text = "Open XML File…"
Dock = Top
2.
C1FlexGrid
(Name) = fg
Dock = Fill
Now double-click the form caption area to open the code window. At the top of the file, add the
following statement:
•
Visual Basic
Imports C1.Win.C1FlexGrid
•
C#
using C1.Win.C1FlexGrid;
•
Delphi
uses C1.Win.C1FlexGrid;
This makes the objects defined in the C1FlexGrid assembly visible to the project and saves a lot of typing.
Next, type (or copy) the following code that sets up the grid when the form loads:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' initialize grid
fg.Rows.Count = 1
fg.Cols.Count = 2
fg.Cols.Fixed = 0
fg.ExtendLastCol = True
fg(0, 0) = "Element"
fg(0, 1) = "Text"
' initialize outline tree
fg.Tree.Column = 0
fg.Tree.Style = TreeStyleFlags.SimpleLeaf
fg.Cols(0).AllowEditing = False
' initialize styles
fg.Styles.Normal.Border.Style = BorderStyleEnum.None
fg.Styles.Normal.TextAlign = TextAlignEnum.LeftCenter
fg.Styles.Normal.WordWrap = False
Outline Tutorial · 83
Dim cs As CellStyle = fg.Styles.Add("Data")
cs.BackColor = SystemColors.Control
End Sub
•
C#
private void Form1_Load( System.object sender,
{
// initialize grid
fg.Rows.Count = 1;
fg.Cols.Count = 2;
fg.Cols.Fixed = 0;
fg.ExtendLastCol = true;
fg[0, 0] = "Element";
fg[0, 1] = "Text";
System.EventArgs e)
// initialize outline tree
fg.Tree.Column = 0;
fg.Tree.Style = TreeStyleFlags.SimpleLeaf;
fg.Cols[0].AllowEditing = false;
// initialize styles
fg.Styles.Normal.Border.Style = BorderStyleEnum.None;
fg.Styles.Normal.TextAlign = TextAlignEnum.LeftCenter;
fg.Styles.Normal.WordWrap = false;
CellStyle cs = fg.Styles.Add("Data");
cs.BackColor = SystemColors.Control;
}
•
Delphi
procedure Form1_Load(sender: System.Object;
e: System.EventArgs);
var
cs: CellStyle;
begin
// initialize grid
fg.Rows.Count := 1;
fg.Cols.Count := 2;
fg.Cols.Fixed := 0;
fg.ExtendLastCol := True;
fg[0, 0] := 'Element';
fg[0, 1] := 'Text';
// initialize outline tree
fg.Tree.Column := 0;
fg.Tree.Style := TreeStyleFlags.SimpleLeaf;
fg.Cols[0].AllowEditing := False;
// initialize styles
fg.Styles.Normal.Border.Style := BorderStyleEnum.None;
fg.Styles.Normal.TextAlign := TextAlignEnum.LeftCenter;
fg.Styles.Normal.WordWrap := False;
cs := fg.Styles.Add('Data');
cs.BackColor := SystemColors.Control;
End;
The code starts by setting up the grid layout and column heading text.
Next, it initializes the outline tree using the Tree property and prevents editing of the XML nodes by
setting the AllowEditing property of the first column to False. Note that the user can still edit data in the
second column, which contains the data in each XML node.
84 · FlexGrid Tutorials
Now the control is ready. We can start adding some code to it.
Step 2: Read the Data and Build the Outline
Double-click the command button and add the following code to the Button1_Click event:
•
Visual Basic
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' get file name
Dim fo As OpenFileDialog = New OpenFileDialog()
fo.DefaultExt = "xml"
fo.Filter = "XML Files (*.xml)|*.xml"
If fo.ShowDialog() <> DialogResult.OK Then Exit Sub
' load XML file
Dim xdoc As Xml.XmlDocument = New Xml.XmlDocument()
xdoc.Load(fo.FileName)
' stop redrawing to improve speed
fg.Redraw = False
' populate grid
fg.Rows.Count = 1
GetXMLData(xdoc.ChildNodes(1), 0)
' autosize tree column
fg.AutoSizeCol(0)
' show levels 0,1,2
fg.Tree.Show(2)
' ready to redraw
fg.Redraw = True
End Sub
•
C#
private void Button1_Click( System.object sender, System.EventArgs e)
{
// get file name
OpenFileDialog fo = new OpenFileDialog();
fo.DefaultExt = "xml";
fo.Filter = "XML Files (*.xml)|*.xml";
if ( fo.ShowDialog() != DialogResult.OK ) return
// load XML file
Xml.XmlDocument xdoc = new Xml.XmlDocument();
xdoc.Load(fo.FileName);
// stop redrawing to improve speed
fg.Redraw = false;
// populate grid
fg.Rows.Count = 1;
GetXMLData(xdoc.ChildNodes[1], 0)
// autosize tree column
fg.AutoSizeCol(0);
// show levels 0,1,2
fg.Tree.Show(2);
Outline Tutorial · 85
}
•
// ready to redraw
fg.Redraw = true;
Delphi
procedure Button1_Click(sender: System.Object;
e: System.EventArgs);
var
fo: OpenFileDialog;
xdoc: Xml.XmlDocument;
begin
// get file name
fo := OpenFileDialog.Create;
fo.DefaultExt := 'xml';
fo.Filter := 'XML Files (*.xml)|*.xml';
If fo.ShowDialog <> System.Windows.Forms.DialogResult.OK Then
exit;
// load XML file
xdoc := Xml.XmlDocument.Create;
xdoc.Load(fo.FileName);
// stop redrawing to improve speed
fg.Redraw := False;
// populate grid
fg.Rows.Count := 1;
GetXMLData(xdoc.ChildNodes[1], 0);
// autosize tree column
fg.AutoSizeCol(0);
// show levels 0,1,2
fg.Tree.Show(2);
// ready to redraw
fg.Redraw := True;
end;
The routine starts by showing an OpenFileDialog that allows the user to select an XML file to load into
the grid. When the file is selected, the routine loads it into an XmlDocument object, which parses the
contents of the file into memory.
The routine then sets the grid's Redraw property to False to suspend repainting while the control is
populated. This technique improves performance significantly, and you should always use it when
adding substantial amounts of data to the C1FlexGrid.
Next, the routine clears any data by setting Rows.Count = 1, and calls the GetXMLData routine to
populate the control with the contents of the XmlDocument. The GetXMLData routine is the main one in
this sample, and is listed below.
After the grid has been populated, the routine uses the AutoSize method to adjust the width of the first
column based on its contents, and the Tree.Show method to expand the outline and show levels 0, 1, and
2. The routine then sets the Redraw property back to True so the grid starts repainting normally.
The GetXMLData routine is the most interesting one in this sample. It traverses the XMLDocument
object and builds the outline tree. Here is the code:
•
Visual Basic
Private Sub GetXMLData(ByVal node As Xml.XmlNode, ByVal level As
Integer)
86 · FlexGrid Tutorials
' skip comment nodes
If node.NodeType = Xml.XmlNodeType.Comment Then
Exit Sub
End If
' add new row for this node
Dim row As Integer = fg.Rows.Count
fg.Rows.Add()
' add data to new row
fg(row, 0) = node.Name
If node.ChildNodes.Count = 1 Then
fg(row, 1) = node.InnerText
fg.SetCellStyle(row, 1, fg.Styles("Data"))
End If
' if the node has a "Name" subnode, save it to use as a tooltip
If node.ChildNodes.Count > 0 Then
Dim ndName As Xml.XmlNode = node.SelectSingleNode("Name")
If Not (ndName Is Nothing) Then
fg.Rows(row).UserData = ndName.InnerText
End If
End If
' if this node has children, get them as well
If node.ChildNodes.Count > 1 Then
' make this row a node
fg.Rows(row).IsNode = True
fg.Rows(row).Node.Level = level
' recurse to get children
Dim child As Xml.XmlNode
For Each child In node.ChildNodes
GetXMLData(child, level + 1)
Next
End If
End Sub
•
C#
private void GetXMLData( Xml.XmlNode node, int level)
{
// skip comment nodes
if ( node.NodeType == Xml.XmlNodeType.Comment )
return;
}
// add new row for this node
int row = fg.Rows.Count;
fg.Rows.Add();
// add data to new row
fg(row, 0) = node.Name;
if ( node.ChildNodes.Count = 1 ) {
fg(row, 1) = node.InnerText;
fg.SetCellStyle(row, 1, fg.Styles["Data"]);
}
// if the node has a "Name" subnode, save it to use as a tooltip
if (node.ChildNodes.Count > 0) {
Xml.XmlNode ndName = node.SelectSingleNode("Name");
if (ndName != null) {
fg.Rows[row].UserData = ndName.InnerText;
}
Outline Tutorial · 87
}
// if this node has children, get them as well
if ( node.ChildNodes.Count > 1 ) {
// make this row a node
fg.Rows[row].IsNode = true;
fg.Rows[row].Node.Level = level;
}
// recurse to get children
Xml.XmlNode child;
foreach ( child In node.ChildNodes )
GetXMLData(child, level + 1)
}
•
Delphi
procedure GetXMLData(node: Xml.XmlNode; level: Integer);
var
r: Integer;
ndName: Xml.XmlNode;
child: Xml.XmlNode;
begin
// skip comment nodes
if node.NodeType = Xml.XmlNodeType.Comment then
exit;
// add new row for this node
r := fg.Rows.Count;
fg.Rows.Add;
// add data to new row
fg[row, 0] := node.Name;
if node.ChildNodes.Count = 1 then
begin
fg[row, 1] := node.InnerText;
fg.SetCellStyle(row, 1, fg.Styles['Data']);
end;
// if the node has a "Name" subnode, save it to use as a tooltip
if node.ChildNodes.Count > 0 then
begin
ndName := node.SelectSingleNode('Name');
if ndName <> nil then
begin
fg.Rows[row].UserData := ndName.InnerText;
end;
end;
// if this node has children, get them as well
if node.ChildNodes.Count > 1 then
begin
// make this row a node
fg.Rows[row].IsNode := True;
fg.Rows[row].Node.Level := level;
// recurse to get children
for I := 0 to node.ChildNodes.Count – 1 do
GetXMLData(node.ChildNodes[I], level + 1);
end;
end;
88 · FlexGrid Tutorials
The routine starts by skipping XML comment nodes. Then it uses the Rows.Add method to add a new
row to the grid.
Next, the routine sets the node name and checks whether the node has exactly one child. In this case, the
node is interpreted as a data node, and the node's InnerText property is copied to the second column on
the new row. The code also sets the style of cells containing data to the custom style "Data" created when
the form was loaded.
The next block of code checks to see whether this node has a subnode called "Name". If it does, then the
contents of the "Name" node are assigned to the new row's UserData property. This value will be used
later to implement tooltips, so users can see the node name even when it is collapsed.
Finally, if the node has children, the GetXMLData routine calls itself to add the child nodes to the grid as
well.
If you run the project now, you will see that it can already load XML files and display them, and the user
can collapse and expand nodes by clicking on them. The next steps add a few improvements to make the
application easier to use.
Step 3: Custom Mouse and Keyboard Handling
The C1FlexGrid provides the expanding and collapsing for you, but you may extend and customize its
behavior. Every time a branch is expanded or collapsed, the control fires the BeforeCollapse and
AfterCollapse events so you may take actions in response to that. Furthermore, you may use the
Node.Collapsed property to get and set the collapsed state of each branch in code.
In this sample, we will trap the DoubleClick and KeyPress events to expand and collapse nodes when
the user double clicks or presses the Enter key. Here is the code:
•
Visual Basic
Private Sub fg_DoubleClick(ByVal sender As Object, _
ByVal e As EventArgs) Handles fg.DoubleClick
If fg.MouseCol = 0 Then
ToggleNodeState()
End If
End Sub
Private Sub fg_KeyPress(ByVal sender As Object, _
ByVal e As KeyPressEventArgs) Handles fg.KeyPress
If e.KeyChar = vbCr Then
ToggleNodeState()
End If
End Sub
Private Sub ToggleNodeState()
' if the current row is not a node, no work
Dim r As Row = fg.Rows(fg.Row)
If Not r.IsNode Then Exit Sub
' toggle collapsed state
r.Node.Collapsed = Not r.Node.Collapsed
End Sub
•
C#
private void fg_DoubleClick( object sender,
fg.DoubleClick {
if ( fg.MouseCol == 0 ) {
ToggleNodeState();
}
EventArgs e)
Outline Tutorial · 89
}
private void fg_KeyPress( object sender,
fg.KeyPress {
if ( e.KeyChar == 13 ) {
ToggleNodeState();
}
}
KeyPressEventArgs e)
private void ToggleNodeState() {
// if the current row is not a node, no work
Row r = fg.Rows[fg.Row];
if (! r.IsNode ) return;
}
•
// toggle collapsed state
r.Node.Collapsed = !r.Node.Collapsed;
Delphi
procedure fg_DoubleClick(sender: System.Object;
e: System.EventArgs);
begin
If fg.MouseCol = 0 Then
ToggleNodeState;
end;
procedure fg_KeyPress(sender: System.Object;
e: KeyPressEventArgs);
begin
If e.KeyChar = #13 Then
ToggleNodeState;
end;
procedure ToggleNodeState;
var
r: Row;
begin
// if the current row is not a node, no work
r := fg.Rows[fg.Row];
If Not r.IsNode Then
exit;
// toggle collapsed state
r.Node.Collapsed := Not r.Node.Collapsed;
end;
The event handlers check whether the user double-clicked the first column or hit the enter key, then call
the ToggleNodeState routine. ToggleNodeState checks whether the current row is a node row, and
toggles the value of the Node.Collapsed property if it is.
Step 4: Allow/Prevent Editing
Recall that we set the AllowEditing property of the first column to False in the Form_Load event. This
prevents users from editing any cells in the first column. We would also like to prevent users from
entering data in the second column of node rows. To do this, add the following code to handle the
BeforeEdit event:
•
Visual Basic
Private Sub fg_BeforeEdit(ByVal sender As Object, _
ByVal e As RowColEventArgs) Handles fg.BeforeEdit
90 · FlexGrid Tutorials
' if the current row is a node, don't edit it
Dim r As Row = fg.Rows(fg.Row)
If r.IsNode Then e.Cancel = True
End Sub
•
C#
private void fg_BeforeEdit( object sender,
fg.BeforeEdit {
RowColEventArgs e)
// if the current row is a node, don't edit it
Row r = fg.Rows[fg.Row];
if (r.IsNode ) e.Cancel = true;
}
•
Delphi
procedure fg_BeforeEdit(sender: System.Object;
e: RowColEventArgs);
var
r: Row;
begin
// if the current row is a node, don't edit it
r := fg.Rows[fg.Row];
If r.IsNode Then
e.Cancel := True;
end;
Step 5: Implement ToolTips
To conclude this tutorial, we will add tooltips to the outline. The tooltips will display the text that was
stored in each row's UserData property by the GetXMLData routine described above. The tooltips will
show the contents of the "Name" node when the user moves the mouse over its parent node. This is
useful when the parent node is collapsed and the "Name" node is not visible.
To add the tooltips, start by adding a ToolTip control to the form. Then, add the following code to handle
the grid's MouseMove event:
•
Visual Basic
Private Sub fg_MouseMove(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles fg.MouseMove
' check tooltip for this cell
Dim tip As String
If fg.MouseCol = 0 And fg.MouseRow > 0 Then
tip = fg.Rows(fg.MouseRow).UserData
End If
' set it if different from current
If tip <> ToolTip1.GetToolTip(fg) Then
ToolTip1.SetToolTip(fg, tip)
End If
End Sub
•
C#
private void fg_MouseMove( object sender,
fg.MouseMove {
MouseEventArgs e)
// check tooltip for this cell
string tip;
if ( fg.MouseCol == 0 && fg.MouseRow > 0 ) {
tip = fg.Rows[fg.MouseRow].UserData;
}
Data Analysis Tutorial · 91
}
•
// set it if different from current
if ( tip != ToolTip1.GetToolTip(fg) ) {
ToolTip1.SetToolTip(fg, tip);
}
Delphi
procedure fg_MouseMove(sender: System.Object;
e: System.MouseEventArgs);
var
tip: string;
begin
// check tooltip for this cell
If (fg.MouseCol = 0) And (fg.MouseRow > 0) Then
tip := fg.Rows[fg.MouseRow].UserData;
// set it if different from current
If tip <> ToolTip1.GetToolTip(fg) Then
ToolTip1.SetToolTip(fg, tip);
end;
The code starts by checking the cell under the mouse using the MouseRow and MouseCol properties. If
the mouse is over the first column on a row that contains text for the tooltip, it retrieves the text.
Otherwise, the tooltip text is set to Nothing.
Then the routine compares the new and current tooltip text, and updates the text if necessary, by calling
the SetToolTip method on the tooltip control.
This concludes this tutorial. You can extend this project in many ways, including saving edits back into
the XML document, adding, deleting, and moving nodes, using different styles for different types of data,
etc.
Data Analysis Tutorial
This tutorial combines some of the most useful features in the C1FlexGrid control to provide a dynamic
view of a data table. The application starts with a simple data-bound grid containing sales data (from the
NorthWind database), then adds the following features:
•
Dynamic layout (column order)
•
Automatic sorting
•
Cell merging
•
Automatic subtotals
•
Outlining
The picture below shows what the final application looks like. The user can drag the first three columns
to group the data by salesperson, country, and product name. When a column is dragged, the totals are
automatically recalculated and the outline tree is rebuilt.
92 · FlexGrid Tutorials
Step 1: Create the C1FlexGrid Control
Start a new Visual Basic project and add a C1FlexGrid control to the form by clicking the C1FlexGrid
icon on the toolbox, then clicking on the form and dragging until the object has the proper size.
If you can't find the C1FlexGrid control in the toolbox, right-click on the toolbox and select the
Customize Toolbox option. Then, look for the C1FlexGrid control on the list of .NET components and
make sure it is checked. If you can't find the grid in the component list, you may need to re-install the
product.
Next, use the Visual Basic properties window to set the following control properties:
(Name) = fg
Dock = Fill
Now double-click the form caption area to open the code window. At the top of the file, add the
following statements:
•
Visual Basic
Imports System.Data.OleDb
Imports C1.Win.C1FlexGrid
•
C#
using System.Data.OleDb;
using C1.Win.C1FlexGrid;
•
Delphi
uses System.Data.OleDb,
C1.Win.C1FlexGrid;
Data Analysis Tutorial · 93
This makes the objects defined in the C1FlexGrid and OleDb assemblies visible to the project and saves a
lot of typing.
Step 2: Initialize and populate the grid
To set up the grid and populate the grid with the sales data we want to analyze, add the following code
to the Form_Load event:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As EventArgs) Handles MyBase.Load
' set up grid layout/behavior
fg.AllowEditing = False
fg.AllowSorting = AllowSortingEnum.None
fg.AllowMerging = AllowMergingEnum.Nodes
fg.SelectionMode = SelectionModeEnum.Cell
fg.ExtendLastCol = True
fg.Cols(0).Width = fg.Cols.DefaultSize / 4
fg.Tree.Style = TreeStyleFlags.Simple
fg.Tree.Column = 1
' set up grid styles
fg.Styles.Normal.Border.Style = BorderStyleEnum.None
fg.Styles.Normal.Trimming = StringTrimming.EllipsisCharacter
Dim s As CellStyle = fg.Styles(CellStyleEnum.GrandTotal)
s.BackColor = Color.Black
s.ForeColor = Color.White
s = fg.Styles(CellStyleEnum.Subtotal0)
s.BackColor = Color.Gold
s.ForeColor = Color.Black
s = fg.Styles(CellStyleEnum.Subtotal1)
s.BackColor = Color.Khaki
s.ForeColor = Color.Black
s = fg.Styles(CellStyleEnum.Subtotal2)
s.BackColor = Color.LightGoldenrodYellow
s.ForeColor = Color.Black
' bind flex to data source
fg.DataSource = GetDataSource()
' prevent user from dragging last three columns
fg.Cols(4).AllowDragging = False
fg.Cols(5).AllowDragging = False
fg.Cols(6).AllowDragging = False
End Sub
•
C#
private void Form1_Load( System.object sender,
{
// set up grid layout/behavior
fg.AllowEditing = False
fg.AllowSorting = AllowSortingEnum.None;
fg.AllowMerging = AllowMergingEnum.Nodes;
fg.SelectionMode = SelectionModeEnum.Cell;
fg.ExtendLastCol = true;
fg.Cols[0].Width = fg.Cols.DefaultSize / 4;
fg.Tree.Style = TreeStyleFlags.Simple;
fg.Tree.Column = 1;
// set up grid styles
EventArgs e)
base.Load
94 · FlexGrid Tutorials
fg.Styles.Normal.Border.Style = BorderStyleEnum.None;
fg.Styles.Normal.Trimming = StringTrimming.EllipsisCharacter;
CellStyle s = fg.Styles[CellStyleEnum.GrandTotal];
s.BackColor = Color.Black;
s.ForeColor = Color.White;
s = fg.Styles[CellStyleEnum.Subtotal0];
s.BackColor = Color.Gold;
s.ForeColor = Color.Black;
s = fg.Styles[CellStyleEnum.Subtotal1];
s.BackColor = Color.Khaki;
s.ForeColor = Color.Black;
s = fg.Styles[CellStyleEnum.Subtotal2];
s.BackColor = Color.LightGoldenrodYellow;
s.ForeColor = Color.Black;
// bind flex to data source
fg.DataSource = GetDataSource();
}
•
// prevent user from dragging last three columns
fg.Cols[4].AllowDragging = false;
fg.Cols[5].AllowDragging = false;
fg.Cols[6].AllowDragging = false;
Delphi
procedure Form1_Load(sender: System.Object;
e: System.EventArgs);
var
s: CellStyle;
begin
// set up grid layout/behavior
fg.AllowEditing = False
fg.AllowSorting := AllowSortingEnum.None;
fg.AllowMerging := AllowMergingEnum.Nodes;
fg.SelectionMode := SelectionModeEnum.Cell;
fg.ExtendLastCol := True;
fg.Cols[0].Width := fg.Cols.DefaultSize / 4;
fg.Tree.Style := TreeStyleFlags.Simple;
fg.Tree.Column := 1;
// set up grid styles
fg.Styles.Normal.Border.Style := BorderStyleEnum.None;
fg.Styles.Normal.Trimming := StringTrimming.EllipsisCharacter;
s := fg.Styles[CellStyleEnum.GrandTotal];
s.BackColor := Color.Black;
s.ForeColor := Color.White;
s = fg.Styles[CellStyleEnum.Subtotal0];
s.BackColor := Color.Gold;
s.ForeColor := Color.Black;
s := fg.Styles[CellStyleEnum.Subtotal1];
s.BackColor := Color.Khaki;
s.ForeColor := Color.Black;
s := fg.Styles[CellStyleEnum.Subtotal2];
s.BackColor := Color.LightGoldenrodYellow;
s.ForeColor := Color.Black;
// bind flex to data source
fg.DataSource := GetDataSource;
// prevent user from dragging last three columns
fg.Cols[4].AllowDragging := False;
fg.Cols[5].AllowDragging := False;
Data Analysis Tutorial · 95
fg.Cols[6].AllowDragging := False;
end;
The routine starts by setting up the grid layout and some styles. Note that you can set up these properties
at design time, if you prefer, using the built-in grid editors.
After setting up the grid, the routine binds it to a data source created by the GetDataSource method,
listed below. Finally the last three columns are locked in place by setting their AllowDragging property
to False. This is done to prevent the user from grouping the data in these columns (the values in these
columns are distinct for each row).
The GetDataSource method creates the data table that is displayed by the grid. The routine is very
simple, except for the SQL statement that retrieves the data. Most people don't write these SQL
statements manually, but use visual designers such as the one in Visual Studio or Microsoft Access to do
that.
Note that you may have to change the connection string slightly, because it has a reference to the
NorthWind database and that file might be in a different folder in your system:
•
Visual Basic
Private Function GetDataSource() As DataTable
' set up connection string
Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft Visual
Studio\VB98\NWIND.MDB;"
& _
' set up SQL statement
Dim rs As String = _
"SELECT Employees.LastName,Orders.ShipCountry," & _
"Categories.CategoryName,Products.ProductName,Orders.OrderDate,"
"[Quantity]*[Products].[UnitPrice] AS [Sale Amount] " & _
"FROM (Categories INNER JOIN Products " & _
"ON Categories.CategoryID = Products.CategoryID) " & _
"INNER JOIN ((Employees INNER JOIN Orders " & _
"ON Employees.EmployeeID = Orders.EmployeeID) " & _
"INNER JOIN [Order Details] " & _
"ON Orders.OrderID = [Order Details].OrderID) " & _
"ON Products.ProductID = [Order Details].ProductID "
"ORDER BY Employees.LastName,Orders.ShipCountry," & _
"Categories.CategoryName;"
' retrieve data into DataSet
Dim da As OleDbDataAdapter = New OleDbDataAdapter(rs, conn)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
' return data table
GetDataSource = ds.Tables(0)
End Function
•
C#
private DataTable GetDataSource() {
// set up connection string
string conn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data
Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB;";
// set up SQL statement
string rs =
"SELECT Employees.LastName,Orders.ShipCountry," +
96 · FlexGrid Tutorials
"Categories.CategoryName,Products.ProductName,Orders.OrderDate,"
+
"[Quantity]*[Products].[UnitPrice] AS [Sale Amount] " +
"FROM (Categories INNER JOIN Products " +
"ON Categories.CategoryID = Products.CategoryID) " +
"INNER JOIN ((Employees INNER JOIN Orders " +
"ON Employees.EmployeeID = Orders.EmployeeID) " +
"INNER JOIN [Order Details] " +
"ON Orders.OrderID = [Order Details].OrderID) " +
"ON Products.ProductID = [Order Details].ProductID " +
"ORDER BY Employees.LastName,Orders.ShipCountry," +
"Categories.CategoryName;";
// retrieve data into DataSet
OleDbDataAdapter OleDbDataAdapter da = new OleDbDataAdapter(rs,
conn);
DataSet DataSet ds = new DataSet();
da.Fill(ds);
// return data table
GetDataSource = ds.Tables[0]
}
•
Delphi
function Class1.GetDataSource: DataTable;
var
DataSet: DataSet;
OleDbDataAdapter: OleDbDataAdapter;
rs: string;
conn: string;
begin
conn := ('Provider=Microsoft.Jet.OLEDB.4.0;' + 'Data
Source=C:\Program Files Microsoft Visual Studio B98 WIND.MDB;');
+
// set up SQL statement
rs :=
'SELECT Employees.LastName,Orders.ShipCountry,' +
'Categories.CategoryName,Products.ProductName,Orders.OrderDate,'
'[Quantity]*[Products].[UnitPrice] AS [Sale Amount] ' +
'FROM (Categories INNER JOIN Products ' +
'ON Categories.CategoryID = Products.CategoryID) ' +
'INNER JOIN ((Employees INNER JOIN Orders ' +
'ON Employees.EmployeeID = Orders.EmployeeID) ' +
'INNER JOIN [Order Details] ' +
'ON Orders.OrderID = [Order Details].OrderID) ' +
'ON Products.ProductID = [Order Details].ProductID ' +
'ORDER BY Employees.LastName,Orders.ShipCountry,' +
'Categories.CategoryName;';
da := OleDbDataAdapter.Create(rs, conn);
ds := DataSet.Create;
da.Fill(ds);
Self.GetDataSource := ds.Tables[0];
end;
If you run the project now, you will see a plain-looking grid that allows you to move columns around
and browse through the data. However, the data is not structured in a clear way, and this table contains a
couple of thousand records, so it is pretty difficult to get an overview of what the data means.
Data Analysis Tutorial · 97
Step 3: Automatic Sorting
The first step in organizing the data is sorting it. Furthermore, we would like the data to be sorted
automatically whenever the user reorders the columns.
After the user reorders the columns, the C1FlexGrid control fires the AfterDragColumn event. We will
add an event handler to sort the data in the underlying data table. (If the grid were being used in
unbound mode, we would accomplish this using the Sort method.)
The code is very simple:
•
Visual Basic
Private Sub fg_AfterDragColumn(ByVal sender As Object, _
ByVal e As DragRowColEventArgs) Handles fg.AfterDragColumn
' sort the recordset when the user drags columns
' this will cause a data refresh, removing all subtotals and
' firing the AfterDataRefresh event, which rebuilds the subtotals.
Dim sort As String = fg.Cols(1).Name & ", " & _
fg.Cols(2).Name & ", " & _
fg.Cols(3).Name
Dim dt As DataTable = fg.DataSource
dt.DefaultView.Sort = sort
End Sub
•
C#
private void fg_AfterDragColumn( object sender,
fg.AfterDragColumn {
}
•
DragRowColEventArgs e)
// sort the recordset when the user drags columns
// this will cause a data refresh, removing all subtotals and
// firing the AfterDataRefresh event, which rebuilds the subtotals.
string sort = fg.Cols[1].Name + ", " +
fg.Cols[2].Name + ", " +
fg.Cols(3).Name;
DataTable dt = fg.DataSource;
dt.DefaultView.Sort = sort;
Delphi
procedure fg_AfterDragColumn(sender: Object;
e: DragRowColEventArgs);
var
sort: string;
dt: DataTable;
begin
// sort the recordset when the user drags columns
// this will cause a data refresh, removing all subtotals and
// firing the AfterDataRefresh event, which rebuilds the subtotals.
sort := fg.Cols[1].Name + ', ' +
fg.Cols[2].Name + ', ' +
fg.Cols[3].Name;
dt := fg.DataSource;
dt.DefaultView.Sort := sort;
end;
Run the project and try reordering the first three columns by dragging their headings around. Whenever
you move a column, the data is automatically sorted, which makes it easier to interpret.
In the next step, we will add subtotals and an outline tree.
98 · FlexGrid Tutorials
Step 4: Subtotals and Outline Tree
When the grid is used in bound mode, any changes to the data source cause the grid to fire the
AfterDataRefresh event. This event is the ideal place to put the code that inserts the subtotals and builds
the outline tree for the grid.
Here is the AfterDataRefresh event handler:
•
Visual Basic
Private Sub fg_AfterDataRefresh(ByVal sender As Object, _
ByVal e As ListChangedEventArgs) Handles fg.AfterDataRefresh
' total on Sale Amount
Dim totalOn As Integer = fg.Cols("Sale Amount").SafeIndex
Dim caption As String = "Total for {0}"
' calculate three levels of totals
fg.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption)
fg.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption)
fg.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption)
' collapse outline to level 2
fg.Tree.Show(2)
' autosize the grid to accommodate tree
fg.AutoSizeCols(1, 1, 1000, 3, 30, AutoSizeFlags.IgnoreHidden)
End Sub
•
C#
private void fg_AfterDataRefresh( object sender,
e) fg.AfterDataRefresh {
ListChangedEventArgs
// total on Sale Amount
int totalOn = fg.Cols["Sale Amount"].SafeIndex;
string caption = "Total for {0}";
// calculate three levels of totals
fg.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption);
fg.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption);
fg.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption);
// collapse outline to level 2
fg.Tree.Show(2);
// autosize the grid to accommodate tree
fg.AutoSizeCols(1, 1, 1000, 3, 30, AutoSizeFlags.IgnoreHidden);
}
•
Delphi
procedure fg_AfterDataRefresh(sender: System.Object;
e: ListChangedEventArgs);
var
totalOn: Integer;
caption: string;
begin
// total on Sale Amount
totalOn := fg.Cols['Sale Amount'].SafeIndex;
caption := 'Total for {0}';
// calculate three levels of totals
fg.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption);
fg.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption);
Data Analysis Tutorial · 99
fg.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption);
// collapse outline to level 2
fg.Tree.Show(2);
// autosize the grid to accommodate tree
fg.AutoSizeCols(1, 1, 1000, 3, 30, AutoSizeFlags.IgnoreHidden);
end;
The code is very simple. It starts by getting the index of the "Sale Amount" column. In this sample, the
index will always be the same (column 6). Looking up the index is usually better than hardwiring it,
though, because if someone added a couple of fields to the SQL statement the index would change.
The code then calls the Subtotal method to group the data and insert new rows with the subtotals. The
new rows are automatically configured as outline nodes (their IsNode property is set to True), so the
subtotals are collapsible.
Try running the project again and dragging columns around. You can easily see the totals by country,
product category, or salesperson. You can also expand tree benches to drill down into the data if you
want to see more detail.
Note also that the grid is editable. If you change some values in the "Sale Amount" column, that will
cause the AfterDataRefresh event to fire again, and the totals will be automatically updated.
This concludes this tutorial.
C1FlexGrid Class · 101
C1FlexGrid Reference
The C1FlexGrid component provides the following properties, events, and methods:
C1FlexGrid Class
The C1FlexGrid control allows you to display, edit, group and summarize data in a grid format. The grid
can be bound to a data source or it can manage its own data.
All C1FlexGrid Members
C1FlexGrid Public Properties
AllowAddNew
Gets or sets whether the grid should display a new
row template after the last data row.
AllowDelete
Gets or sets whether the grid should monitor the
keyboard and handle the Delete key.
AllowDragging
Supported by the .NET Compact Framework.
Specifies whether the user can drag rows and/or
columns with the mouse.
AllowEditing
Supported by the .NET Compact Framework.
Specifies whether the user can edit cells.
AllowFreezing
Specifies whether the user can freeze rows or
columns with the mouse.
AllowMerging
Supported by the .NET Compact Framework.
Specifies whether cells with similar contents will be
merged.
AllowResizing
Supported by the .NET Compact Framework.
Specifies whether the user can resize rows or
columns with the mouse.
AllowSorting
Supported by the .NET Compact Framework.
Specifies whether the user can sort columns with the
mouse.
AutoClipboard
Gets or sets whether the grid should handle the
clipboard keys and automatically perform cut, copy,
paste, and delete operations.
AutoResize
Gets or sets whether column widths are
automatically adjusted when data is loaded.
AutoSearch
Supported by the .NET Compact Framework.
Specifies whether the grid should move the cursor
searching for entries as the user types.
AutoSearchDelay
Supported by the .NET Compact Framework.
Specifies the time (in seconds) that elapses before
the AutoSearch buffer is reset.
BottomRow
Supported by the .NET Compact Framework.
Returns the last row visible on the grid.
BorderStyle
Gets or sets the border style of the control.
CellButtonImage
Supported by the .NET Compact Framework.
Specifies the image used in cell buttons.
102 · C1FlexGrid Reference
Clip
Supported by the .NET Compact Framework.
Gets or sets the contents of a cell range.
ClipSeparators
Supported by the .NET Compact Framework.
Gets or sets the characters used as row and column
separators in clip strings.
Col
Supported by the .NET Compact Framework.
Gets or sets the index of the selected column.
Cols
Supported by the .NET Compact Framework.
Gets the collection of columns in the grid.
ColSel
Supported by the .NET Compact Framework.
Gets or sets the index of the last column in the
current selection.
ComboList
Supported by the .NET Compact Framework.
Gets or sets the list of items to be used by the dropdown editor.
CursorCell
Supported by the .NET Compact Framework.
Gets a CellRange object that contains the anchor
cell in the current selection.
CustomComparer
Gets or sets a custom IComparer object used by the
grid to perform grouping, merging, and searching
operations.
DataMember
Gets or sets the specific list in a DataSource object
that the grid should display.
DataSource
Supported by the .NET Compact Framework.
Gets or sets the data source for the control.
DoubleBuffer
If this property is set to true, drawing is performed in
a buffer, and after it completes, the result is output to
the screen. This prevents flicker caused by the
redrawing of the control.
DragMode
Supported by the .NET Compact Framework.
Gets or sets a value indicating whether the user can
drag data from the control.
DrawMode
Supported by the .NET Compact Framework.
Specifies whether you want to provide custom
drawing for cells on the grid.
DropMode
Supported by the .NET Compact Framework.
Gets or sets a value indicating whether the control
can accept data that the user drags onto it.
EditMask
Supported by the .NET Compact Framework.
Gets or sets the input mask to use when editing
cells.
Editor
Supported by the .NET Compact Framework.
Gets the cell editor that is currently active or sets a
control to be used as an editor (can only be set while
handling the StartEdit event)
EditOptions
Contains flags that allow customization of the built-in
editing behavior.
ExtendLastCol
Supported by the .NET Compact Framework.
Specifies whether the width of the last column should
be adjusted to fill the width of the control.
FocusRect
Supported by the .NET Compact Framework.
Specifies the type of focus rectangle to be displayed
around the current cell.
GetCellCheck
Gets a value indicating whether a cell has a
checkbox in it.
C1FlexGrid Class · 103
HighLight
Supported by the .NET Compact Framework.
Specifies when to highlight the selected cells.
Item
Supported by the .NET Compact Framework.
Gets or sets the data in a grid cell.
KeyActionEnter
Supported by the .NET Compact Framework.
Specifies the action to be performed when the user
presses the Enter key.
KeyActionTab
Supported by the .NET Compact Framework.
Specifies the action to be performed when the user
presses the Tab key.
LeftCol
Supported by the .NET Compact Framework.
Gets or sets the index of the leftmost non-fixed
column.
MouseCol
Supported by the .NET Compact Framework.
Gets the index of the column under the mouse.
MouseRow
Supported by the .NET Compact Framework.
Gets the index of the column under the mouse.
PrintParameters
Gets a GridPrinter object that specifies printing
parameters for the grid.
Redraw
Supported by the .NET Compact Framework.
Specifies whether the grid should paint its contents.
RightCol
Supported by the .NET Compact Framework.
Gets the index of the rightmost column.
Row
Supported by the .NET Compact Framework.
Gets or sets the index of the selected row.
Rows
Supported by the .NET Compact Framework.
Gets the collection of rows in the grid.
RowSel
Supported by the .NET Compact Framework.
Gets or sets the index of the last row in the current
selection.
ScrollBars
Gets or sets which scroll bars should appear in the
grid.
ScrollPosition
Gets or sets the scroll position.
ScrollTrack
Specifies the grid behavior when the user drags the
scrollbar thumb.
ScrollTips
Returns or sets whether tool tips are shown on the
vertical scrollbar while the user drags the scroll
thumb.
ScrollTipText
Gets or sets the tooltip text displayed as the user
scrolls vertically.
Selection
Supported by the .NET Compact Framework.
Gets a CellRange object that corresponds to the
current selection.
SelectionMode
Supported by the .NET Compact Framework.
Specifies the selection behavior of the grid.
SetCellCheck
Sets the state of the checkbox in a cell.
ShowButtons
Specifies when the grid should display drop down
and popup buttons in editable cells.
104 · C1FlexGrid Reference
ShowCursor
Specifies whether the grid should display a record
selector image.
Styles
Supported by the .NET Compact Framework.
Gets the collection of cell styles in the grid.
SubTotalPosition
Specifies whether the Subtotal method should add
node rows above or below the data being
summarized.
TopRow
Supported by the .NET Compact Framework.
Gets or sets the index of the topmost non-fixed
visible row.
Tree
Supported by the .NET Compact Framework.
Gets the GridTree object that controls the
appearance of the outline tree in the grid.
C1FlexGrid Public Methods
AddItem
Supported by the .NET Compact Framework.
Adds a row to the control and populates the row with
the given data.
Aggregate
Supported by the .NET Compact Framework.
Calculates aggregate statistics for a range of cells.
AutoSizeCol
Supported by the .NET Compact Framework.
Adjusts the width of a column to fit the current data.
AutoSizeCols
Supported by the .NET Compact Framework.
Adjusts the width of all columns to fit the current
data.
AutoSizeRow
Supported by the .NET Compact Framework.
Adjusts the height of a single row to fit the current
data.
AutoSizeRows
Supported by the .NET Compact Framework.
Adjusts the height of a range of rows to fit the current
data.
Clear
Supported by the .NET Compact Framework.
Clears the contents of the grid.
CreateImage
Supported by the .NET Compact Framework.
Creates an image of the entire grid or range.
FindRow
Supported by the .NET Compact Framework.
Finds a row that contains a given string or object.
FinishEditing
Supported by the .NET Compact Framework.
Finishes editing the current cell and takes the grid
out of edit mode.
GetCellImage
Supported by the .NET Compact Framework.
Gets the image assigned to a cell.
GetCellRange
Supported by the .NET Compact Framework.
Returns a CellRange object that can be used to
format and manipulate a range.
GetCellRect
Supported by the .NET Compact Framework.
Returns a Rectangle object with the coordinates of
the cell on the screen.
GetCellStyle
Supported by the .NET Compact Framework.
Returns a custom style associated with a cell, or null
if the cell doesn't have a custom style.
C1FlexGrid Class · 105
GetCellStyleDisplay
Supported by the .NET Compact Framework.
Returns the style used to render a cell.
GetCellCheck
Supported by the .NET Compact Framework.
Returns the state of the checkbox in a grid cell.
GetData
Supported by the .NET Compact Framework.
Returns the data in a grid cell.
GetDataDisplay
Supported by the .NET Compact Framework.
Returns the data in a grid cell, formatted as a string.
GetMergedRange
Supported by the .NET Compact Framework.
Returns the merged range of cells that includes a
given cell.
HitTest
Returns information about the control at a given
point on the control surface.
Invalidate
Supported by the .NET Compact Framework.
Invalidates a specific region of the grid and causes
a paint message to be sent to the control.
LoadExcel
Loads a grid from a Microsoft Excel file (xls).
LoadExcelSheetNames
Gets a list of all worksheets in a Microsoft Excel file
(xls).
LoadGrid
Loads a grid from a file.
PrintGrid
Supported by the .NET Compact Framework.
Prints the grid, optionally showing a print preview
dialog.
RemoveItem
Removes a row from the control.
SaveExcel
Saves a grid to a Microsoft Excel file (xls).
SaveGrid
Saves a grid to a file.
Select
Supported by the .NET Compact Framework.
Selects a cell or range of cells.
SetCellImage
Supported by the .NET Compact Framework.
Assigns an image to a cell.
SetCellStyle
Supported by the .NET Compact Framework.
Assigns a custom CellStyle to a cell.
SetCellCheck
Supported by the .NET Compact Framework.
Sets the type and state of the checkbox that is
displayed in a cell.
SetData
Supported by the .NET Compact Framework.
Assigns data to a grid cell.
SetDataBinding
Sets the DataSource and DataMember properties.
ShowCell
Supported by the .NET Compact Framework.
Brings a cell into view, scrolling the grid is
necessary.
ShowSortAt
Shows a sorting glyph at a specific column,
Sort
Supported by the .NET Compact Framework.
Sorts the entire grid or a range of rows based on the
contents of one or more columns.
StartEditing
Supported by the .NET Compact Framework.
Puts the grid in edit mode and starts editing a cell.
106 · C1FlexGrid Reference
Subtotal
Groups and totals rows based on their contents.
C1FlexGrid Public Events
AfterAddRow
Fires when the AllowAddNew property is set to
true, after the user adds a new row to the grid.
AfterDataRefresh
Supported by the .NET Compact Framework.
Fires in a bound mode, after the grid changes as a
result of changes in the data source.
AfterDeleteRow
Fires when the AllowDelete property is set to true,
after the user deletes a row from the grid.
AfterDragColumn
Supported by the .NET Compact Framework.
Fires after the user drags a column using the
mouse.
AfterDragRow
Supported by the .NET Compact Framework.
Fires after the user drags a row using the mouse.
AfterEdit
Supported by the .NET Compact Framework.
Fires after the user finishes editing a cell.
AfterFreezeColumn
Fires after the user freezes columns with the
mouse.
AfterFreezeRow
Fired after the user freezes rows with the mouse.
AfterResizeColumn
Supported by the .NET Compact Framework.
Fires after a column is resized by the user.
AfterResizeRow
Supported by the .NET Compact Framework.
Fires after a row is resized by the user.
AfterRowColChange
Supported by the .NET Compact Framework.
Fires after the selection anchor moves to a new cell.
AfterScroll
Supported by the .NET Compact Framework.
Fires after the grid scrolls.
AfterSelChange
Supported by the .NET Compact Framework.
Fires after the selection changes.
AfterSort
Supported by the .NET Compact Framework.
Fires after a column is sorted when the user clicks
on a column header.
BeforeAddRow
Fires when the AllowAddNew property is set to
true, before the user adds a new row to the grid.
BeforeAutoSizeColumn
Fires before a column is automatically resized in
response to a double click.
BeforeAutoSizeRow
Fires before a row is automatically resized in
response to a double click.
BeforeDeleteRow
Fires when the AllowDelete property is set to true,
before the user deletes a row from the grid.
BeforeDragColumn
Supported by the .NET Compact Framework.
Fires when the user drags a column using the
mouse, before the column is moved to the new
position.
C1FlexGrid Class · 107
BeforeDragRow
Supported by the .NET Compact Framework.
Fires when the user drags a column using the
mouse, before the column is moved to the new
position.
BeforeEdit
Supported by the .NET Compact Framework.
Fires before the control enters edit mode.
BeforeFreezeColumn
Fires before the user freezes columns with the
mouse.
BeforeFreezeRow
Fired before the user freezes rows with the mouse.
BeforeMouseDown
Supported by the .NET Compact Framework.
Fires before the control processes the MouseDown
event.
BeforePageBreak
Supported by the .NET Compact Framework.
Fires while the control is being printed, to allow
control over page breaks.
BeforeResizeColumn
Supported by the .NET Compact Framework.
Fires before a column is resized.
BeforeResizeRow
Supported by the .NET Compact Framework.
Fires before a row is resized.
BeforeRowColChange
Supported by the .NET Compact Framework.
Fires before the current cell (Row, Col) changes to
a different cell.
BeforeScroll
Supported by the .NET Compact Framework.
Fires before the control scrolls.
BeforeScrollTip
Supported by the .NET Compact Framework.
Fires before a scroll tip is shown so you can set the
ScrollTipText property.
BeforeSelChange
Supported by the .NET Compact Framework.
Fires before the selected range (RowSel, ColSel)
changes.
BeforeSort
Supported by the .NET Compact Framework.
Fires before a column is sorted by a click on the
column header.
BeginPrint
Supported by the .NET Compact Framework.
Fires when the grid starts printing.
CancelAddRow
Fires when the AllowAddNew property is set to
true, after the user adds a row and then removes it
by exiting the new row without making any changes.
CellButtonClick
Supported by the .NET Compact Framework.
Fires after the user clicks a cell button.
CellChanged
Fires after the contents of a cell change.
ChangeEdit
Supported by the .NET Compact Framework.
Fires after the text in the editor has changed.
ComboCloseUp
Supported by the .NET Compact Framework.
Fires while the grid is in edit mode, before the user
drops down the combo list.
ComboDropDown
Supported by the .NET Compact Framework.
Fires while the grid is in edit mode, before the user
drops down the combo list.
EndPrint
Supported by the .NET Compact Framework.
Fires when the grid detects an error condition.
108 · C1FlexGrid Reference
EnterCell
Supported by the .NET Compact Framework.
Fires when a cell becomes active.
GetUnboundValue
Fires when the grid is bound and needs to retrieve a
value from an unbound column.
GridChanged
Fires when the grid changes in any way.
GridError
Supported by the .NET Compact Framework.
Fires when the grid detects an error condition.
KeyDownEdit
Supported by the .NET Compact Framework.
Fires when the user presses a key in cell-editing
mode.
KeyPressEdit
Supported by the .NET Compact Framework.
Fires when the user presses a key in cell-editing
mode.
KeyUpEdit
Supported by the .NET Compact Framework.
Fires when the user presses a key in cell-editing
mode.
LeaveCell
Supported by the .NET Compact Framework.
Fires before the current cell changes to a different
cell.
OwnerDrawCell
Supported by the .NET Compact Framework.
Fires before the grid draws a cell, when the
DrawMode property is set to OwnerDraw.
PrintPage
Supported by the .NET Compact Framework.
Fires when the grid finishes printing a page.
RowColChange
Supported by the .NET Compact Framework.
Fires when the current cell (Row, Col) changes to a
different cell.
SelChange
Supported by the .NET Compact Framework.
Fires after the selected range (RowSel, ColSel)
changes.
SetUnboundValue
Fires when the grid is bound and needs to set a
value in an unbound column.
SetupEditor
Supported by the .NET Compact Framework.
Fires after the built-in editor is initialized but before it
is displayed.
StartEdit
Supported by the .NET Compact Framework.
Fires when the control enters cell edit mode (after
BeforeEdit).
ValidateEdit
Supported by the .NET Compact Framework.
Fires before the control exits cell edit mode.
C1FlexGrid Properties
AllowAddNew Property
Gets or sets whether the grid should display a new row template after the last data row. If the user enters
data into the new row template, a new row is automatically added to the grid.
Syntax
[VB]
Public AllowAddNew As Boolean
[C#]
public bool AllowAddNew { get; set;}
AllowDelete Property · 109
[Delphi]
property AllowAddNew: Boolean;
Remarks
This property works in bound mode (if the data source supports adding new rows) and in unbound
mode.
Note that if this property is set to true, the Rows.Count property will return a value that includes the new
row template. If you set the Rows.Count property, the grid will set the number of data rows and will
automatically add the new row template. For example:
•
Visual Basic
flex.AllowAddNew = True
flex.Rows.Count = 10
Console.WriteLine(_flex.Rows.Count)
•
C#
flex.AllowAddNew = true;
flex.Rows.Count = 10;
Console.WriteLine(_flex.Rows.Count);
•
Delphi
begin
flex.AllowAddNew := True;
flex.Rows.Count := 10;
Console.WriteLine(_flex.Rows.Count);
end;
This will print out "11" (10 data rows plus the new row template).
See Also
C1FlexGrid Class (page 101)
AllowDelete Property
Gets or sets whether the grid should monitor the keyboard and handle the Delete key. If this property is
set to true, the user can delete rows by selecting them and then pressing the Delete key.
Syntax
[VB]
Public AllowDelete As Boolean
[C#]
public bool AllowDelete { get; set;}
[Delphi]
property AllowDelete: Boolean;
Remarks
This property works in bound mode (if the data source supports deleting rows) and in unbound mode.
110 · C1FlexGrid Reference
See Also
C1FlexGrid Class (page 101)
AllowDragging Property
Specifies whether the user can drag rows and/or columns with the mouse.
Syntax
[VB]
Public AllowDragging As AllowDraggingEnum
[C#]
public AllowDraggingEnum AllowDragging {get; set;}
[Delphi]
property AllowDragging: AllowDraggingEnum;
Property Value
One of the AllowDraggingEnum values. The default is AllowDraggingEnum.Columns.
Member Name
Description
None
The user cannot drag rows and columns with the mouse.
Columns
The user can drag columns to new positions with the mouse.
Rows
The user can drag rows to new positions with the mouse.
Both
The user can drag rows and columns to new positions with the mouse.
Remarks
You can prevent specific rows and columns from being dragged by setting their AllowDragging property
to false. For example:
•
Visual Basic
flex.AllowDragging = AllowDraggingEnum.Columns
flex.Cols(2).AllowDragging = False
•
C#
flex.AllowDragging = AllowDraggingEnum.Columns;
flex.Cols[2].AllowDragging = false;
•
Delphi
flex.AllowDragging := AllowDraggingEnum.Columns;
flex.Cols[2].AllowDragging := false;
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
AllowEditing Property (C1FlexGrid) · 111
AllowEditing Property (C1FlexGrid)
Specifies whether the user can edit cells.
Syntax
[VB]
Public AllowEditing As Boolean
[C#]
public bool AllowEditing { get; set;}
[Delphi]
property AllowEditing: Boolean;
Property Value
The default value is true.
Remarks
You can prevent specific rows and columns from being edited by setting their AllowEditing property to
false. For example:
•
Visual Basic
flex.AllowEditing = True
flex.Cols(2).AllowEditing = False ' prevent editing column 2
•
C#
flex.AllowEditing = true;
flex.Cols[2].AllowEditing = false; // prevent editing column 2
•
Delphi
flex.AllowEditing := true;
flex.Cols[2].AllowEditing := false; // prevent editing column 2
For more details and examples on cell editing, see Editing Cells (page 34.)
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
AllowFreezing Property
Specifies whether the user can freeze rows or columns with the mouse.
Syntax
[VB]
Public AllowFreezing As AllowFreezingEnum
[C#]
public AllowFreezingEnum AllowFreezing { get; set;}
112 · C1FlexGrid Reference
[Delphi]
property AllowFreezing: AllowFreezingEnum;
Property Value
One of the AllowFreezingEnum values. The default is AllowFreezingEnum.None.
Remarks
Frozen cells remain on the screen when the user scrolls the control (like fixed cells), but they are selectable
and editable (like scrollable cells). They are painted using the Styles.Frozen style.
To freeze rows or columns, the mouse must be near the edge of the frozen area. The mouse pointer will
then change into a 'freeze' pointer (looks like a padlock) and the user can drag the frozen boundary to a
new row or column.
See Also
C1FlexGrid Class (page 101)
AllowMerging Property
Specifies whether cells with similar contents will be merged.
Syntax
[VB]
Public AllowMerging As AllowMergingEnum
[C#]
public AllowMergingEnum AllowMerging {get; set;}
[Delphi]
property AllowMerging: AllowMergingEnum;
Property Value
One of the AllowMergingEnum values. The default is AllowMergingEnum.None.
Member Name
Description
None
Do not merge cells.
Free
Merge any adjacent cells with same contents.
RestrictRows
Merge rows only if cells above are also merged.
RestrictCols
Merge columns only if cells to the left are also merged.
RestrictAll
Merge cells only if cells above or to the left are also merged.
FixedOnly
Merge only fixed cells. This setting is useful for setting up complex headers for
the data and preventing the data itself from being merged.
Spill
Allow long entries to spill into empty adjacent cells.
Nodes
Allow entries in Node rows to spill into empty adjacent cells.
AllowResizing Property · 113
Remarks
Merging cells allows you to display data in a clear, appealing way because it highlights groups of
identical information. It also gives you flexibility to build tables similar to the ones you can create in
HTML or using Microsoft Word, both of which support merged cells.
To create tables with merged cells, you must set the AllowMerging property to a value other than
AllowMergingEnum.None, and then set the AllowMerging property of individual rows and columns
true for the rows and columns you wish to merge. After these properties are set, the grid will
automatically merge neighboring cells that have the same contents. Whenever the cell contents change,
the grid updates the merging state.
Example
The code below causes the grid to merge adjacent cells with the same data in column 1:
•
Visual Basic
flex.AllowMerging = AllowMergingEnum.Free
flex.Cols(1).AllowMerging = True ' merge values in column 1
•
C#
flex.AllowMerging = AllowMergingEnum.Free;
flex.Cols[1].AllowMerging = true; // merge values in column 1
•
Delphi
flex.AllowMerging := AllowMergingEnum.Free;
flex.Cols[1].AllowMerging := true; // merge values in column 1
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
AllowResizing Property
Specifies whether the user can resize rows or columns with the mouse.
Syntax
[VB]
Public AllowResizing As AllowResizingEnum
[C#]
public AllowResizingEnum AllowResizing {get; set;}
[Delphi]
property AllowResizing: AllowResizingEnum;
Property Value
One of the AllowResizingEnum values. The default is AllowResizingEnum.Columns.
Member Name
Description
None
The user may not resize rows or columns.
114 · C1FlexGrid Reference
Member Name
Description
Columns
The user may resize columns by dragging the edges of the fixed cells along the
top of the grid. Double clicking the edge of the fixed cells adjusts the column to fit
the widest entry in the column.
ColumnsUniform
The user may resize columns with the mouse. When a column is resized, the
new column height is applied to all columns.
Rows
The user may resize rows by dragging the edges of the fixed cells along the left
of the grid. Double clicking the edge of the fixed cells adjusts the row to fit the
tallest entry in the row.
Both
The user may resize rows and columns with the mouse.
RowsUniform
The user may resize rows with the mouse. When a row is resized, the new row
height is applied to all rows.
BothUniform
The user may resize rows and columns with the mouse. When a row or column is
resized, the new size is applied to all rows or columns.
Remarks
To resize rows or columns, the mouse must be over the fixed area of the grid, and close to a border
between rows or columns. The mouse pointer will then change into a sizing pointer and the user can drag
the row or column to change the row height or column width.
If a group of columns is selected (from first to last row) and the user resizes one of them, all selected
columns are resized. The same applies to rows.
If column sizing is allowed, users may double-click the resizing area to resize a column so it will
automatically fit the longest entry.
Rows with zero height and columns with zero width cannot be resized by the user. If you want to make
them very small but still resizable, set their height or width to one pixel, not to zero.
The BeforeResizeRow and BeforeResizeColumn events fire before resizing starts, and may be used to
prevent resizing of specific rows and columns. The AfterResizeRow and AfterResizeColumn fire after
resizing, and may be used to validate the user's action and to update the display.
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
AllowSorting Property (C1FlexGrid)
Specifies whether the user can sort columns with the mouse.
Syntax
[VB]
Public AllowSorting As AllowSortingEnum
[C#]
public AllowSortingEnum AllowSorting {get; set;}
AutoClipboard Property · 115
[Delphi]
property AllowSorting: AllowSortingEnum;
Property Value
One of the AllowSortingEnum values. The default is AllowSortingEnum.SingleColumn.
Member Name
Description
None
The user cannot sort columns with the mouse.
SingleColumn
The user can sort columns with the mouse. Clicking on a column header sorts
that column in ascending or descending order.
This setting provides the behavior seen in most standard applications such as
the Windows Explorer.
MultiColumn
The user can sort columns with the mouse. Clicking on a column header sorts all
columns form the first to the one that was clicked in ascending or descending
order.
This setting is useful when data is grouped by categories, from left to right, and
you want to preserve the grouping when the data is sorted.
Remarks
When the grid is used in bound mode, the sorting is performed on the underlying data table.
When the grid is unbound, you can also sort data using the Sort method.
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
AutoClipboard Property
Gets or sets whether the grid should handle the clipboard keys and automatically perform cut, copy,
paste, and delete operations.
Syntax
[VB]
Public AutoClipboard As Boolean
[C#]
public bool AutoClipboard {get; set;}
[Delphi]
property AutoClipboard: Boolean;
Remarks
Setting this property to true causes the grid to monitor the keyboard for the following clipboard keys:
116 · C1FlexGrid Reference
Clipboard Action
Keys
Copy
control-Insert, control-C
Cut
control-X, shift-Delete
Paste
control-V, shift-Insert
Delete
Delete
Paste, Cut, and Delete actions are performed only if the AllowEditing property is set to True.
If you want to handle only a subset of the supported keys, add a handler to the KeyDown event and set
the Handled parameter to true to disable some of the keys.
Automatic clipboard operations only affect the grid data. Styles and images are not copied, pasted, or
deleted.
See Also
C1FlexGrid Class (page 101)
AutoResize Property
Gets or sets whether column widths are automatically adjusted when data is loaded.
Syntax
[VB]
Public AutoResize As Boolean
[C#]
public bool AutoResize {get; set;}
[Delphi]
property AutoResize: Boolean;
Remarks
This property works when the control is bound to a DataSource. If AutoResize is set to True, the control
automatically resizes its columns to fit the widest entry every time new data is read from the data source.
You may use the AutoSizeCols method to adjust column widths with code.
See Also
C1FlexGrid Class (page 101)
AutoSearch Property
Specifies whether the grid should move the cursor searching for entries as the user types.
Syntax
[VB]
Public AutoSearch As AutoSearchEnum
AutoSearchDelay Property · 117
[C#]
public AutoSearchEnum AutoSearch {get; set;}
[Delphi]
property AutoSearch: AutoSearchEnum;
Property Value
One of the AutoSearchEnum values. The default is AutoSearchEnum.None.
Remarks
If AutoSearch is on, the grid will search the current column as the user types, automatically moving the
cursor and highlighting matches using the Styles.Search cell style. The search is case-insensitive. The
search is canceled when the user presses the Escape key or moves the selection with the mouse or cursor
keys.
When the user stops typing for about a second, the search buffer is reset. This amount of time can be
changed by setting the AutoSearchDelay property.
If AutoSearch is on and the AllowEditing property is set to true, the user will need to hit Enter, Space, or
F2 to start editing cells. Other keys are used for searching.
See Also
C1FlexGrid Class (page 101)
AutoSearchDelay Property
Specifies the time (in seconds) that elapses before the AutoSearch buffer is reset.
Syntax
[VB]
Public AutoSearchDelay As double
[C#]
public double AutoSearchDelay {get; set;}
[Delphi]
property AutoSearchDelay: Double;
Remarks
See the AutoSearch property.
See Also
C1FlexGrid Class (page 101)
BottomRow Property
Returns the last row visible on the grid.
118 · C1FlexGrid Reference
Syntax
[VB]
Public BottomRow As Integer
[C#]
public int BottomRow {get;}
[Delphi]
property BottomRow: Integer;
Remarks
The bottom row returned may be only partially visible.
You cannot set this property. To scroll the contents of the grid using code, set the TopRow and LeftCol
properties. To ensure that a given cell is visible, use the ShowCell method.
See Also
C1FlexGrid Class (page 101)
BorderStyle Property
Gets or sets the border style of the control.
Syntax
[VB]
Public BorderStyle As BorderStyleEnum
[C#]
public BorderStyleEnum BorderStyle {get; set;}
[Delphi]
property BorderStyle: BorderStyleEnum;
Property Value
One of the BorderStyleEnum values. The default is BorderStyleEnum.Fixed3D.
Remarks
In addition to the standard FixedSingle and Fixed3D settings, you can use a Light3D border that is onepixel wide.
See Also
C1FlexGrid Class (page 101)
CellButtonImage Property
Specifies the image used in cell buttons.
Clip Property · 119
Syntax
[VB]
Public CellButtonImage As Image
[C#]
public Image CellButtonImage {get; set;}
[Delphi]
property CellButtonImage: Image;
Remarks
This property allows you to customize the appearance of cell buttons. For details on how to create and
handle cell buttons, see the CellButtonClick event.
If you want to use a single picture for all cell buttons on the grid, assign the picture to the
CellButtonImage property at design time. To change pictures depending on the row, column, or cell
being edited, trap the BeforeEdit event and set the picture accordingly.
The pictures used for cell buttons should fit within the button (larger pictures are truncated). They should
also be transparent, so the button face can be seen through the empty parts of the picture. For best results,
use small icons (16 x 16 pixels) and draw the picture in the upper left 12 x 12 rectangle within the icon.
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
Clip Property
Gets or sets the contents of a cell range.
Syntax
[VB]
Public Clip As String
[C#]
public string Clip {get; set;}
[Delphi]
property Clip: string;
Remarks
The string assigned to (or returned by) the Clip property may contain multiple cells. By default, tab
characters (\t) indicate column breaks, and carriage return characters (\n) indicate row breaks.
The default row and column delimiters may be changed using the ClipSeparators property.
When a string is assigned to the Clip property, only the selected cells are affected. If there are more cells
in the selected region than are described in the clip string, the remaining cells are ignored. If there are
more cells described in the clip string than in the selected region, the extraneous portion of the clip string
is ignored. Empty entries in the Clip string will clear existing cell contents.
120 · C1FlexGrid Reference
The example below puts text into a selected area two rows high and two columns wide.
•
Visual Basic
' build clip string
Dim s As String = "1st" + vbTab + "a" +vbLf + "2nd" +vbTab + "b"
' paste it over current selection
flex.Clip = s
•
C#
// build clip string
string s = "1st" + "\t" + "a" + "\n" + "2nd" + "\t" + "b";
// paste it over current selection
flex.Clip = s;
•
Delphi
var
s: string;
begin
s := '1st' + #9 + 'a' + #10 + '2nd' + #9 + 'b';
flex.Clip := s;
end;
You may also retrieve or set a clip string for an arbitrary (not necessarily selected) range using CellRange
objects. For example:
•
Visual Basic
' build clip string
Dim rg As CellRange = flex.GetCellRange(1, 1, 10, 10)
MessageBox.Show(rg.Text)
•
C#
// build clip string
CellRange rg = flex.GetCellRange(1,1,10,10);
MessageBox.Show(rg.Text);
•
Delphi
var
rg: CellRange;
begin
rg := flex.GetCellRange(1, 1, 10, 10);
MessageBox.Show(rg.Text);
end;
See Also
C1FlexGrid Class (page 101)
ClipSeparators Property
Gets or sets the characters used as row and column separators in clip strings.
Syntax
[VB]
Public ClipSeparators As String
Col Property · 121
[C#]
public string ClipSeparators {get; set;}
[Delphi]
property ClipSeparators: string;
Remarks
See the Clip property.
See Also
C1FlexGrid Class (page 101)
Col Property
Gets or sets the index of the selected column.
Syntax
[VB]
Public Col As Integer
[C#]
public int Col {get; set;}
[Delphi]
property Col: Integer;
Remarks
Use the Row and Col properties to make a cell current or to find out which row or column contains the
current cell. Columns and rows are numbered from zero, beginning at the top for rows and at the left for
columns.
The Col property may be set to -1 to hide the selection, to a value between zero and Cols.Fixed-1 to select
a cell in a fixed column, or to a value between Cols.Fixed and Cols.Count-1 to select a cell in a scrollable
column.
Setting the Row and Col properties automatically collapsed the selection to a single cell, resetting the
RowSel and ColSel properties. To specify a block selection, you must set Row and Col, then RowSel and
ColSel. Or you may use the Select method to select an arbitrary range with a single statement.
Setting the Row and Col properties does not ensure that the current cell is visible. To do that, use the
ShowCell method.
See Also
C1FlexGrid Class (page 101)
Cols Property
Gets the collection of columns in the grid.
122 · C1FlexGrid Reference
Syntax
[VB]
Public Cols As ColumnCollection
[C#]
public ColumnCollection Cols {get;}
[Delphi]
property Cols: ColumnCollection;
Remarks
The Cols property enables you to obtain a reference to the list of columns that are currently stored in the
grid. With this reference, you can add, remove, move, and count the columns. For more information on
the tasks that can be performed with this collection, see the ColumnCollection class reference topics.
This property is read-only. The grid creates and manages the collection.
Upgrade Note: In the VSFlexGrid ActiveX control, the Cols and FixedCols properties corresponded to
the number of columns and fixed columns on the grid. In C1FlexGrid, use Cols.Count and Cols.Fixed.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
ColSel Property
Gets or sets the index of the last column in the current selection.
Syntax
[VB]
Public ColSel As Integer
[C#]
public int ColSel {get; set;}
[Delphi]
property ColSel: Integer;
Remarks
Use the RowSel and ColSel properties to modify a selection or to determine which cells are currently
selected. Columns and rows are numbered from zero, beginning at the top for rows and at the left for
columns.
Setting the Row and Col properties automatically collapses the selection to a single cell, resetting the
RowSel and ColSel properties. Therefore, to specify a block selection, you must Row and Col, then
RowSel and ColSel. Alternatively, you may use the Select method to select a range with a single
statement.
When a range is selected, the value of Row may be greater than or less than RowSel, and Col may be
greater than or less than ColSel. This is inconvenient when you need to set up bounds for loops. In these
ComboList Property · 123
cases, you can use the Selection property to retrieve a normalized CellRange object, where r1 <= r2 and
c1 <= c2.
Example
The code below loops though the cells in the current selection:
•
Visual Basic
Dim rg As CellRange = flex.Selection
Dim r As Integer
For r = rg.r1 To rg.r2
Dim c As Integer
For c = rg.c1 To rg.c2
Console.WriteLine("the value at {0} {1} is {2}", r, c, flex(r,
c))
Next c
Next r
•
C#
CellRange rg = flex.Selection;
for (int r = rg.r1; r <= rg.r2; r++)
for (int c = rg.c1; c <= rg.c2; c++)
Console.WriteLine("the value at {0} {1} is {2}", r, c, flex[r, c]);
•
Delphi
var
c: Integer;
r: Integer;
rg: CellRange;
begin
rg := flex.Selection;
for r := rg.r1 to rg.r2 do
for c := rg.c1 to rg.c2 do
Console.WriteLine('the value at {0} {1} is {2}', r, c, flex[r]);
end;
See Also
C1FlexGrid Class (page 101)
ComboList Property
Gets or sets the list of items to be used by the drop-down editor.
Syntax
[VB]
Public ComboList As String
[C#]
public string ComboList {get; set;}
[Delphi]
property ComboList: string;
Remarks
The ComboList property specifies the type of editor to be used when editing a cell. You may use a text
box, drop-down list, drop-down combo, or an edit button to pop up custom editor forms.
124 · C1FlexGrid Reference
To use the ComboList property, set the AllowEditing property to True, and respond to the BeforeEdit
event by setting the ComboList property to a string that describes the type of editing you want to use for
that cell. The options are described below:
1.
To edit the cell using a regular text box, set the ComboList property to an empty string ("").
2.
To edit the cell using a drop-down list, set the ComboList property to a string containing the
available options, separated by pipe characters ("|"). For example:
•
Visual Basic
flex.ComboList = "ListItem 1|ListItem 2"
•
C#
flex.ComboList = "ListItem 1|ListItem 2";
•
Delphi
flex.ComboList := 'ListItem 1|ListItem 2';
3.
To edit the cell using a drop-down combo, set the ComboList property to a string containing the
available options, separated by pipe characters ("|") and starting with a pipe character. For
example:
•
Visual Basic
flex.ComboList = "|ComboItem 1|ComboItem 2"
•
C#
flex.ComboList = "|ComboItem 1|ComboItem 2";
•
Delphi
flex.ComboList := '|ComboItem 1|ComboItem 2';
4.
To display an edit button, set the ComboList property to a string containing an ellipsis ("..."). Edit
buttons look like regular push buttons, aligned to the right of the cell, with an ellipsis as a
caption. When the user clicks on the edit button, the grid fires the CellButtonClick event. In this
case, the user cannot edit the cell contents directly. For example:
•
Visual Basic
flexComboList = "..."
•
C#
flexComboList = "...";
•
Delphi
flexComboList := '...';
5.
To display an edit button next to an editable cell, set the ComboList property to a string
containing a pipe and an ellipsis ("|..."). In this case, you get a regular edit button but the user can
also edit the cell contents directly. For example:
•
Visual Basic
flexComboList = "|..."
•
C#
flexComboList = "|...";
CursorCell Property · 125
•
Delphi
flexComboList := '|...';
The ComboList property is especially useful in cases where different rows in the same column may
contain different types of data (for example a control such as the Microsoft PropertyGrid). In this case, the
ComboList property allows you to adjust the type of editing you want to provide depending on the
current row.
If all rows in the column contain the same type of data, use the Column’s ComboList property. This way,
the grid will automatically select the appropriate ComboList for the column and you don't need to
handle any events.
Example
The code below handles the BeforeEdit event and assigns a value to the ComboList property so that the
grid displays buttons on every other row.
•
Visual Basic
Private Sub _flex_BeforeEdit(sender As Object, e As RowColEventArgs)
_flex.ComboList = ""
If e.Row Mod 2 = 0 Then
flex.ComboList = "..."
Else
flex.ComboList = ""
End If
End Sub '_flex_BeforeEdit
•
C#
private void _flex_BeforeEdit(object sender, RowColEventArgs e)
{
_flex.ComboList = (e.Row % 2 == 0)? "..." : "";
}
•
Delphi
procedure _flex_BeforeEdit(sender: System.Object; e: RowColEventArgs);
begin
_flex.ComboList := '';
If (e.Row Mod 2) = 0 Then
flex.ComboList = '...'
Else
flex.ComboList = '';
end; //_flex_BeforeEdit
For more details and examples on cell editing, see Editing Cells (page 34.)
See Also
C1FlexGrid Class (page 101)
CursorCell Property
Gets a CellRange object that contains the cell at coordinates Row, Col.
Syntax
[VB]
Public CursorCell As CellRange
126 · C1FlexGrid Reference
[C#]
public CellRange CursorCell {get;}
[Delphi]
property CursorCell: CellRange;
Property Value
A CellRange object that can be used to manipulate the cells in the selection.
Remarks
To get a CellRange object that spans the entire selection (defined by the Row, Col, RowSel, and ColSel
properties), use the Selection property.
See Also
C1FlexGrid Class (page 101)
CustomComparer Property
Gets or sets a custom IComparer object used by the grid to perform grouping, merging, and searching
operations.
Syntax
[VB]
Public CustomComparer As IComparer
[C#]
public IComparer CustomComparer {get;set;}
[Delphi]
property CustomComparer: IComparer;
Remarks
The grid has a default IComparer implementation that is used to compare cells and determine if their
contents are equivalent. This implementation is used when merging, grouping, or searching for values
(see the AllowMerging property and the Subtotal and FindRow methods).
The default implementation is case-sensitive and takes leading and trailing blanks into account.
If you want to merge cells using a case-insensitive comparison and trimming blanks, write a custom class
that implements IComparer and assign it to the CustomComparer property.
Setting this property to null (Nothing in Visual Basic) restores the default behavior.
See Also
C1FlexGrid Class (page 101)
DataMember Property
Gets or sets the specific list in a DataSource object that the grid should display.
DataSource Property (C1FlexGrid) · 127
Syntax
[VB]
Public DataMember As String
[C#]
public string DataMember {get;set;}
[Delphi]
property DataMember: string;
Remarks
If a DataSource contains multiple sources of data, you should set the DataMember property to one of the
sources. For example, if the DataSource is a DataSet or DataViewManager that contains three tables
named Customers, Orders, and OrderDetails, you must specify one of the tables to bind to. If the DataSet or
DataViewManager contains only one DataTable, you may set the DataMember property to an empty
string.
See Also
C1FlexGrid Class (page 101)
DataSource Property (C1FlexGrid)
Gets or sets the data source for the grid.
Syntax
[VB]
Public DataSource As object
[C#]
public object DataSource {get; set;}
[Delphi]
property DataSource: object;
Remarks
The following ADO.NET data sources are valid: DataTable, DataView, DataSet, DataViewManager.
The following ComponentOne DataObjects components are also valid data sources: C1ExpressTable,
C1ExpressVew, C1ExpressConnection, C1DataView, C1DataTableSource and C1DataSet.
If the DataSource reference contains more than one table, you must set the DataMember property a
string that specifies the table to bind to. For example, if the DataSource is a DataSet or
DataViewManager that contains three tables named Customers, Orders, and OrderDetails, you must
specify one of the tables to bind to.
You can also assign another C1FlexGrid object to the DataSource property. In this case, the controls will
share the same grid model, including the data, display styles, selection, etc. This can be used to
implement split views, where different controls display different parts of the data.
128 · C1FlexGrid Reference
Example
This code binds the grid to an ADO.NET data source:
•
Visual Basic
' replace with actual connection string
Dim conn As String = "
Provider=Microsoft.Jet.OLEDB.4.0;UserID=Admin;... "
'
Dim rs As String = "select * from customers"
Dim da As New OleDbDataAdapter(rs, conn)
Dim ds As New DataSet()
da.Fill(ds)
flex.DataSource = ds.Tables(0)
•
C#
// replace with actual connection string
string conn = @"Provider=Microsoft.Jet.OLEDB.4.0; User ID=Admin; ...";
string rs = "select * from customers";
OleDbDataAdapter da = new OleDbDataAdapter(rs, conn);
DataSet ds = new DataSet();
da.Fill(ds);
flex.DataSource = ds.Tables[0];
•
Delphi
var
ds: DataSet;
da: OleDbDataAdapter;
rs: string;
conn: string;
begin
conn := 'Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;
...';
rs := 'select * from customers';
da := OleDbDataAdapter.Create(rs, conn);
ds := DataSet.Create;
da.Fill(ds);
flex.DataSource := ds.Tables[0];
end;
This code binds two grids (fgLeft and fgRight) together and synchronizes their scrolling in the vertical
direction (the user can scroll the independently in the horizontal direction).
•
Visual Basic
' bind grids together
fgRight.DataSource = fgLeft
fgLeft.ScrollBars = ScrollBars.Horizontal
' synchronize vertical scrolling
Private Sub flex_AfterScroll(sender As Object,
e As C1.Win.C1FlexGrid.RangeEventArgs)
Dim fg As C1FlexGrid = CType(sender, C1FlexGrid)
fg.Update()
Dim y As Integer = fg.ScrollPosition.Y
If fg = fgLeft Then
fgRight.ScrollPosition = New Point(fgRight.ScrollPosition.X, y)
Else
fgLeft.ScrollPosition = New Point(fgLeft.ScrollPosition.X, y)
End If
End Sub
DoubleBuffer Property · 129
•
C#
// bind grids together
fgRight.DataSource = fgLeft;
fgLeft.ScrollBars = ScrollBars.Horizontal;
// synchronize vertical scrolling
private void flex_AfterScroll(object sender,
C1.Win.C1FlexGrid.RangeEventArgs e)
{
C1FlexGrid fg = (C1FlexGrid)sender;
fg.Update();
int y = fg.ScrollPosition.Y;
if (fg == fgLeft)
fgRight.ScrollPosition = new Point(fgRight.ScrollPosition.X,
y);
else
fgLeft.ScrollPosition = new Point(fgLeft.ScrollPosition.X, y);
}
}
•
Delphi
// bind grids together
fgRight.DataSource := fgLeft;
fgLeft.ScrollBars := ScrollBars.Horizontal;
procedure Class1.flex_AfterScroll(sender: System.Object; e:
C1.Win.C1FlexGrid.RangeEventArgs);
var
y: Integer;
fg: C1FlexGrid;
begin
fg := C1FlexGrid(sender);
fg.Update;
y := fg.ScrollPosition.Y;
if (fg = fgLeft) then
fgRight.ScrollPosition := Point.Create(fgRight.ScrollPosition.X, y)
else
fgLeft.ScrollPosition := Point.Create(fgLeft.ScrollPosition.X, y);
end;
See Also
C1FlexGrid Class (page 101)
DoubleBuffer Property
If this property is set to true, drawing is performed in a buffer, and after it completes, the result is output
to the screen. his prevents flicker caused by the redrawing of the control.
Syntax
[VB]
Public Property DoubleBuffer As Boolean
[C#]
public Bool DoubleBuffer {get; set;}
130 · C1FlexGrid Reference
[Delphi]
property DoubleBuffer: Boolean;
Property Value
Member of C1.Win.C1FlexGrid.C1FlexGridBase
Remarks
Do not set DoubleBuffer to false if the grid has:
•
Merged cells, or
•
Transparent areas, or
•
A Background image.
You may want to set DoubleBuffer to false to increase performance when deploying applications that run
on terminal servers.
See Also
C1FlexGrid Class (page 101)
C1FlexGridBase
DragMode Property
Gets or sets a value indicating whether the user can drag data from the control.
Syntax
[VB]
Public DragMode As DragModeEnum
[C#]
public DragModeEnum DragMode {get; set;}
[Delphi]
property DragMode: DragModeEnum;
Property Value
One of the DragModeEnum values.
Remarks
This property allows you to use the control as a source for OLE drag-drop operations. If set to any of the
automatic settings, the control provides the following services:
1.
Detect when the mouse is near the edge of a selected cell or range and display the OLE drag
cursor.
2.
If the user clicks the mouse while the OLE drag cursor is displayed, initiate a drag operation with
a data object containing the current selection.
In manual mode, the programmer is responsible for starting drag-drop operations using the
System.Windows.Forms.Control.DoDragDrop method.
DrawMode Property · 131
See Also
DropMode Property (page 131)
C1FlexGrid Class (page 101)
DrawMode Property
Specifies whether you want to provide custom drawing for cells on the grid.
Syntax
[VB]
Public DrawMode As DrawModeEnum
[C#]
public DrawModeEnum DrawMode {get; set;}
[Delphi]
property DrawMode: DrawModeEnum;
Property Value
One of the DrawModeEnum values. The default is DrawModeEnum.Default.
Remarks
If you set this property to DrawModeEnum OwnerDraw, the grid will fire the OwnerDrawCell event.
You can handle the event and customize the way each cell is drawn, by changing the cell contents or style
on-the-fly, or by taking over the painting and performing it yourself.
For more details and examples, see the OwnerDrawCell event.
See Also
C1FlexGrid Class (page 101)
DropMode Property
Gets or sets a value indicating whether the control can accept data that the user drags onto it.
Syntax
[VB]
Public DropMode As DropModeEnum
[C#]
public DropModeEnum DropMode {get; set;}
[Delphi]
property DropMode: DropModeEnum;
Property Value
One of the DropModeEnum values.
132 · C1FlexGrid Reference
Remarks
This property allows you to use the control as a target for OLE drag-drop operations.
If set to None (the default value), the control does not act as a drop target.
If set to Manual, the control fires the standard drag-drop events and the programmer is responsible for
handling them. The main events involved are DragOver and DragDrop. These events are provided by
the standard System.Windows.Forms.Control object.
If set to Automatic, the control handles the DragOver and DragDrop events automatically by performing
the following actions:
1.
Query the data object for data in text or filename formats.
2.
Scroll if the user drags an object near the edges of the control.
3.
Paste the contents of the data object when the user drops valid data on the control.
NOTE: This property extends and replaces the AllowDrop property that is provided by the base
Windows.Forms.Control object.
See Also
C1FlexGrid Class (page 101)
EditMask Property (C1FlexGrid)
Gets or sets the input mask to use when editing cells.
Syntax
[VB]
Public EditMask As String
[C#]
public string EditMask {get; set;}
[Delphi]
property EditMask: string;
Remarks
The EditMask property allows you to specify an input mask for automatic input formatting and
validation. The mask syntax is similar to the one used by the Microsoft MaskedEdit ActiveX control and
by Microsoft Access and is described below.
Set the EditMask property in response to the BeforeEdit event, in the same way you would set the
ComboList property.
If the same mask is used to edit all values in a column, use the column’s EditMask property. This
simplifies your code because you don't need to handle the BeforeEdit event.
When the user is done editing a cell with a mask, the ValidateEdit event will fire. The Cancel property on
the event will be set to true if the mask was not filled out properly, so in most cases you don't event need
to implement the handler. The default behavior ensures that only valid data will be entered.
Editor Property (C1FlexGrid) · 133
The EditMask must be a string composed of the following symbols:
1) Wildcards
0 digit
9 digit or space
# digit or sign
L letter
? letter or space
A letter or digit
a letter, digit, or space
& any character
2) Localized characters
.
localized decimal separator
,
localized thousand separator
:
localized time separator
/ localized date separator
3) Command characters
\ next character is taken as a literal
> translate letters to uppercase
< translate letters to lowercase
4) Placeholder specification
;
next character is used as a placeholder (the default is an underscore)
For example:
•
Visual Basic
' set the mask so the user can enter a phone number,
' with optional area code, and a state in uppercase letters.
' use an asterisk as a placeholder
flex.EditMask = "(###) 000-0000 St" + "ate" > LL '
•
C#
// set the mask so the user can enter a phone number,
// with optional area code, and a state in uppercase letters.
// use an asterisk as a placeholder
flex.EditMask = "(###) 000-0000 St\ate\: >LL;*";
•
Delphi
// set the mask so the user can enter a phone number,
// with optional area code, and a state in uppercase letters.
// use an asterisk as a placeholder
flex.EditMask := '(###) 000-0000 St'#7'te >LL;*';
For more details and examples on cell editing, see Editing Cells (page 34.)
See Also
C1FlexGrid Class (page 101)
Editor Property (C1FlexGrid)
Gets the cell editor that is currently active or sets a control to be used as an editor (can only be set while
handling the StartEdit event).
134 · C1FlexGrid Reference
Syntax
[VB]
Public Editor As Control
[C#]
public Control Editor {get;set;}
[Delphi]
property Editor: Control;
Remarks
The Editor property returns a reference to the cell editor that is currently active. This may be one of the
built-in editors (a TextBox, a ComboBox, or a DateTimePicker control), an external editor, or null (if the
grid is not in edit mode).
You can use this property to programmatically access the editor or to find out if the grid is in edit mode.
If you don't want to use the grid's built-in editors, you can use any other control instead. To do this, either
associate the external editor with a specific grid Row, Column, or CellStyle using their Editor properties,
which you can get and set at any time.
Alternatively, you can handle the StartEdit event and assign any control directly to the grid's Editor
property. (Note that the grid's Editor property can only be assigned while handling the StartEdit event
and is automatically reset to null when the grid exits edit mode.)
Any control can be used as an external editor, but to achieve complete integration with the grid, the
external editor should implement the IC1EmbeddedEditor interface. Some controls implement this
interface natively and do not require any extra code to be used as grid editors (like the ones in the
C1Input library). Most, however, will require you to implement at least a few of the methods in
IC1EmbeddedEditor.
For examples of custom editors, please see Using Custom Editors (page 42 )and Creating Custom Editors
(page 44 )in this documentation, or visit our on-line sample library and download the "CustomEditors"
sample.
Example
This code uses the Editor property to check whether the control is in edit mode and prevents the user
from scrolling the grid while a cell is being edited:
•
Visual Basic
Private flex_ As Sub New(sender As Object, e As RangeEventArgs)
If Not (flex.Editor Is Nothing) Then
e.Cancel = True
End If
End Sub 'New
•
C#
private void flex_ BeforeScroll(object sender, RangeEventArgs e)
{
if (flex.Editor != null)
e.Cancel = true;
}
EditOptions Property · 135
•
Delphi
procedure flex_BeforeScroll(sender: System.Object; e: RangeEventArgs);
begin
If flex.Editor <> nil Then
e.Cancel := True
end; // New
See Also
C1FlexGrid Class (page 101)
EditOptions Property
Contains flags that allow customization of the built-in editing behavior.
Syntax
[VB]
Public Property EditOptions As EditFlags
[C#]
public EditFlags EditOptions {get; set;}
[Delphi]
property EditOptions: EditFlags;
Property Value
One of the EditFlags values. The default is EditFlags.All, which enables auto-searching and auto-cycling
in combo boxes, and selection-wide toggles for checkboxes.
See Also
C1FlexGrid Class (page 101)
ExtendLastCol Property
Specifies whether the width of the last column should be adjusted to fill the width of the control.
Syntax
[VB]
Public ExtendLastCol As Boolean
[C#]
public bool ExtendLastCol {get; set;}
[Delphi]
property ExtendLastCol: Boolean;
Remarks
This property only affects painting. It does not modify the Width.Column Class property of the last
column.
136 · C1FlexGrid Reference
See Also
C1FlexGrid Class (page 101)
FocusRect Property
Specifies the type of focus rectangle to be displayed around the current cell.
Syntax
[VB]
Public FocusRect As FocusRectEnum
[C#]
public FocusRectEnum FocusRect {get; set;}
[Delphi]
property FocusRect: FocusRectEnum;
Property Value
One of the FocusRectEnum values. The default is FocusRectEnum.Light.
Remarks
If the focus rectangle is drawn, then the current cell is painted using the Focus style, which by default
looks like a regular scrollable cell (as in most spreadsheets and grids).
If the focus rectangle is hidden (using the FocusRectEnum.None setting), the current cell is painted using
the Highlight style.
See Also
C1FlexGrid Class (page 101)
GetCellCheck Property
Gets a value indicating whether a cell has a checkbox in it.
Syntax
[VB]
Public GetCellCheck As CheckEnum
[C#]
public CheckEnum GetCellCheck(int row, int col)
[Delphi]
property GetCellCheck: CheckEnum
Remarks
This method retrieves checkbox values assigned to a cell using the SetCellCheck property.
See Also
C1FlexGrid Class (page 101)
Glyphs Property · 137
Glyphs Property
Allows you to customize all built-in images displayed by the grid.
Syntax
[VB]
Public Glyphs As GridGlyphs
[C#]
public GridGlyphs Glyphs {get;}
[Delphi]
property Glyphs: GridGlyphs;
Remarks
The Glyphs property returns a GridGlyphs object with an indexer of type GlyphEnum that gets or sets
the images used to indicate column sorting, collapsed and expanded outline groups, checkboxes, cursors,
error information, etc.
For example, the code below causes the grid to use custom images to display the column sorting order
(instead of the built-in hollow triangles):
•
Visual Basic
_flex.Glyphs(GlyphEnum.Ascending) = imgAscending '
_flex.Glyphs(GlyphEnum.Descending) = imgDescending '
•
C#
_flex.Glyphs[GlyphEnum.Ascending] = imgAscending;
_flex.Glyphs[GlyphEnum.Descending] = imgDescending;
•
Delphi
_flex.Glyphs[GlyphEnum.Ascending] := imgAscending;
_flex.Glyphs[GlyphEnum.Descending] := imgDescending;
NOTE: Setting a glyph to null restores the default (built-in) image. If you want to make a glyph invisible,
set it to a small blank image instead.
See Also
C1FlexGrid Class (page 101)
HighLight Property
Specifies when to highlight the selected cells.
Syntax
[VB]
Public HighLight As HighLightEnum
[C#]
public HighLightEnum HighLight {get; set;}
138 · C1FlexGrid Reference
[Delphi]
property HighLight: HighLightEnum;
Property Value
One of the HighLightEnum values. The default is HighLightEnum.Always.
Remarks
Highlighted cells are drawn using the Highlight style.
See Also
C1FlexGrid Class (page 101)
Item Property
Gets or sets the data in a grid cell.
Syntax
[VB]
Public Item(Row As Integer, Col As Integer) As object
Public Item(Row As Integer, Col As String) As object
[C#]
public object this [ int row, int col ] {get; set;}
public object this [ int row, string col ] {get; set;}
[Delphi]
property Item(Row: Integer; Col: Integer): Object;
property Item(Row: Integer; Col: string): Object;
Remarks
This property is the indexer for the C1FlexGrid control.
You can index cells using the row and column indices or using the row index and column name (see
example below). Using integer indices is more efficient, because the grid doesn't have to lookup the
column. Using names is more flexible, because references remain valid even if the user moves columns to
a new position.
When assigning a value to a cell, the grid tries to convert it into the type specified for the column (see the
Column’s DataType property). If the grid cannot convert the value, it fires the GridError event and the
assignment fails.
See also the GetData and SetData methods.
Upgrade Note: In the VSFlexGrid ActiveX control, you used the TextMatrix property to access cell
contents, and the ColIndex property to index columns by name. In C1FlexGrid, use the indexers.
•
Visual Basic
' create a column, assign it a name and get the new index
Dim myCol As Column = flex.Cols.Add()
myCol.Name = "address"
myCol.DataType = GetType(String)
KeyActionEnter Property · 139
Dim colIndex As Integer = myCol.Index
' assign a value to a cell using cell coordinates:
flex(1, colIndex) = "555, Broadway" '
' get the value using the column name
MessageBox.Show(("The address is " + flex(1, "address").ToString()))
•
C#
// create a column, assign it a name and get the new index
Column myCol = flex.Cols.Add();
myCol.Name = "address";
myCol.DataType = typeof(string);
int colIndex = myCol.Index;
// assign a value to a cell using cell coordinates:
flex[1, colIndex] = "555, Broadway";
// get the value using the column name
MessageBox.Show("The address is " + flex[1, "address"].ToString());
•
Delphi
var
colIndex: Integer;
myCol: Column;
begin
myCol := flex.Cols.Add;
myCol.Name := 'address';
myCol.DataType := TypeOf(string);
colIndex := myCol.Index;
flex[1] := '555, Broadway';
MessageBox.Show(('The address is ' + flex[1].ToString);
end;
See Also
C1FlexGrid Class (page 101)
Column Class (page 320)
Row Class (page 306)
KeyActionEnter Property
Specifies the action to be performed when the user presses the Enter key.
Syntax
[VB]
Public KeyActionEnter As KeyActionEnum
[C#]
public KeyActionEnum KeyActionEnter {get; set;}
[Delphi]
property KeyActionEnter: KeyActionEnum;
Property Value
One of the KeyActionEnum values. The default is KeyActionEnum.MoveDown.
140 · C1FlexGrid Reference
Member Name
Description
None
No special action (allow system to handle the cell). For example, the Tab key is
normally used to cycle through the controls on a form.
MoveDown
Move to the next row when the key is pressed.
MoveAcross
Move to the next column when the key is pressed. At the end of the column, move
to the next row and back to the first column.
MoveAcrossOut
Move to the next column when the key is pressed. At the end of the column, move
to the next row and back to the first column. At the end of the last column, move the
focus to the next control on the form.
Remarks
By default, the grid will move the selection to the next visible row when the user presses the Enter key. If
the grid is editable, pressing Enter will cause the grid to enter edit mode, and pressing Enter while in edit
mode will cause the cursor to move down.
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
KeyActionTab Property
Specifies the action to be performed when the user presses the Tab key.
Syntax
[VB]
Public KeyActionTab As KeyActionEnum
[C#]
public KeyActionEnum KeyActionTab {get; set;}
[Delphi]
property KeyActionTab: KeyActionEnum;
Property Value
One of the KeyActionEnum values. The default is KeyActionEnum.None.
Member Name
Description
None
No special action (allow system to handle the cell). For example, the Tab key is
normally used to cycle through the controls on a form.
MoveDown
Move to the next row when the key is pressed.
MoveAcross
Move to the next column when the key is pressed. At the end of the column, move
to the next row and back to the first column.
MoveAcrossOut
Move to the next column when the key is pressed. At the end of the column, move
to the next row and back to the first column. At the end of the last column, move the
focus to the next control on the form.
KeyActionTab Property · 141
Remarks
By default, the grid will ignore the Tab key and it will be handled by the form, moving the focus to the
next control. If you set the KeyActionTab property to a value other than KeyActionEnum.None, the grid
will trap the Tab key and use it for navigating cells.
Example
The code below changes the value of the KeyActionTab property based on the current cell. The user can
press the Tab key to navigate across cells until he reaches the last cell on the grid. If he pressed Tab again,
the focus will move to the next control.
•
Visual Basic
Private Sub flex_Enter(sender As Object, e As System.EventArgs)
flex.Select(flex.Rows.Fixed, flex.Cols.Fixed)
End Sub 'flex_Enter
Private Sub flex_RowColChange(sender As Object, e As System.EventArgs)
Dim lastCell As Boolean
lastCell = flex.Col = flex.Cols.Count - 1 And _
flex.Row = flex.Rows.Count - 1
If lastCell Then
flex.KeyActionTab = KeyActionEnum.None
Else
flex.KeyActionTab = KeyActionEnum.MoveAcross
End If
End Sub 'flex_RowColChange
•
C#
private void flex_Enter(object sender, System.EventArgs e)
{
flex.Select(flex.Rows.Fixed, flex.Cols.Fixed);
}
private void flex_RowColChange(object sender, System.EventArgs e)
{
bool lastCell = (flex.Col == flex.Cols.Count-1 &&
flex.Row == flex.Rows.Count-1);
flex.KeyActionTab = (lastCell)
? KeyActionEnum.None
: KeyActionEnum.MoveAcross;
}
•
Delphi
procedure Class1.flex_Enter(sender: System.Object; e:
System.EventArgs);
begin
flex.Select(flex.Rows.Fixed, flex.Cols.Fixed);
end;
procedure flex_RowColChange(sender: System.Object; e:
System.EventArgs);
var
lastCell: Boolean;
begin
lastCell := (flex.Col = flex.Cols.Count – 1_ And
(flex.Row = flex.Rows.Count – 1);
If lastCell Then
flex.KeyActionTab := KeyActionEnum.None
Else
flex.KeyActionTab := KeyActionEnum.MoveAcross;
end; // flex_RowColChange
142 · C1FlexGrid Reference
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
LeftCol Property
Gets or sets the index of the leftmost non-fixed column.
Syntax
[VB]
Public LeftCol As Integer
[C#]
public int LeftCol {get; set;}
[Delphi]
property LeftCol: Integer;
Remarks
Setting the LeftCol property causes the grid to scroll horizontally so that the given column becomes the
leftmost visible column. This is often useful when you want to synchronize two or more grids so that
when one of them scrolls, the other scrolls as well. To scroll vertically, use the TopRow property.
When setting this property, the largest possible column number is the total number of columns minus the
number of columns that will fit the display. Attempting to set LeftCol to a greater value will cause the
grid to set it to the largest possible value (no error will occur).
The value returned by the LeftCol and TopRow properties may correspond to partially visible rows or
columns.
Use the LeftCol and TopRow properties to scroll using cells as units. Use the ScrollPosition property to
scroll the grid using pixel units.
To ensure that a given cell is visible, use the ShowCell method.
See Also
C1FlexGrid Class (page 101)
MouseCol Property
Gets the index of the column under the mouse.
Syntax
[VB]
Public MouseCol As Integer
[C#]
public int MouseCol {get;}
MouseCol Property · 143
[Delphi]
property MouseCol: Integer;
Remarks
The MouseRow and MouseCol properties are often useful when handling the BeforeMouseDown event,
to provide custom mouse handling. They are also useful when handling mouse events that do not change
the selection and for detecting clicks on the fixed areas of the grid.
Typical uses for these properties include displaying help information or tooltips when the user moves the
mouse over a selection, and the implementation of manual drag-and-drop manipulation of OLE objects.
The MouseRow and MouseCol properties return –1 if the mouse is not over any cells.
Example
This code will display a tooltip showing the coordinates of the cell under the cursor:
•
Visual Basic
Private Sub flex_MouseMove(sender As Object, e As
System.Windows.Forms.MouseEventArgs)
' build tooltip text
Dim str As String = String.Format("This is cell {0}, {1}",
flex.MouseRow, flex.MouseCol)
' ttip is a Windows.Forms.ToolTip component
If str <> ttip.GetToolTip(flex) Then
ttip.SetToolTip(flex, str)
End If
End Sub 'flex_MouseMove
•
C#
private void flex_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
// build tooltip text
string str = string.Format("This is cell {0}, {1}",
flex.MouseRow, flex.MouseCol);
// ttip is a Windows.Forms.ToolTip component
if (str != ttip.GetToolTip(flex))
ttip.SetToolTip(flex, str);
}
•
Delphi
procedure flex_MouseMove(sender: System.Object; e:
System.Windows.Forms.MouseEventArgs);
var
str: string;
begin
// build tooltip text
str := String.Format('This is cell {0}, {1}', flex.MouseRow,
flex.MouseCol);
// ttip is a Windows.Forms.ToolTip component
If str <> ttip.GetToolTip(flex) Then
ttip.SetToolTip(flex, str);
end; // flex_MouseMove
See Also
C1FlexGrid Class (page 101)
144 · C1FlexGrid Reference
MouseRow Property
Gets the index of the column under the mouse.
Syntax
[VB]
Public MouseRow As Integer
[C#]
public int MouseRow {get;}
[Delphi]
property MouseRow: Integer;
Remarks
The MouseRow and MouseCol properties return –1 if the mouse is not over any cells.
For details and an example, see the MouseCol property.
See Also
C1FlexGrid Class (page 101)
PrintParameters Property
Gets a GridPrinter object that specifies printing parameters for the grid.
Syntax
[VB]
Public PrintParameters As GridPrinter
[C#]
public GridPrinter PrintParameters {get;}
[Delphi]
property PrintParameters: GridPrinter;
Remarks
Use the PrintGrid method to print the grid and specify the document name, common printing options,
headers and footers. Use the PrintParameters property to specify less common printing options such as
header and footer fonts, page margins, orientation, etc.
See Also
C1FlexGrid Class (page 101)
Redraw Property
Specifies whether the grid should paint its contents.
Redraw Property · 145
Syntax
[VB]
Public Redraw As Boolean
[C#]
public bool Redraw {get; set;}
[Delphi]
property Redraw: Boolean;
Remarks
The Redraw property is used to optimize the performance of the grid. Before making extensive changes,
set Redraw to false to suspend repainting. When the changes are done, set Redraw back to true. This will
reduce flicker and increase performance. This optimization is especially effective when adding large
numbers of rows to the grid, because it needs to recalculate ranges and update scrollbars each time a row
is added.
Example
This code turns repainting off, changes the contents of the grid, and then turns repainting back on to
show the results.
•
Visual Basic
Private Function UpdateGrid(flex As c1FlexGrid) As function
flex.Redraw = False ' suspend painting to avoid flicker
flex.Rows.Count = 1
Dim i As Integer
For i = 1 To 9999
flex.AddItem(("Row " + i.ToString()))
Next i
flex.Redraw = True ' resume painting
End Function 'UpdateGrid
•
C#
private function UpdateGrid(c1FlexGrid flex)
{
flex.Redraw = false; // suspend painting to avoid flicker
flex.Rows.Count = 1;
for (int i = 1; i < 10000; i++)
flex.AddItem("Row " + i.ToString());
flex.Redraw = true; // resume painting
}
•
Delphi
function Class1.UpdateGrid(flex: c1FlexGrid): &function;
var
i: Integer;
begin
flex.Redraw := False;
flex.Rows.Count := 1;
for I := 1 to 9999 do
flex.AddItem('Row ' + System.Object(i).ToString);
flex.Redraw := True;
end;
146 · C1FlexGrid Reference
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
RightCol Property
Gets the index of the rightmost column.
Syntax
[VB]
Public RightCol As Integer
[C#]
public int RightCol {get;}
[Delphi]
property RightCol: Integer;
Remarks
The right column returned may be only partially visible.
You cannot set this property. To scroll the contents of the grid, set the TopRow and LeftCol properties.
To ensure that a cell is visible, use the ShowCell method.
See Also
C1FlexGrid Class (page 101)
Row Property
Gets or sets the index of the selected row.
Syntax
[VB]
Public Row As Integer
[C#]
public int Row {get; set;}
[Delphi]
property Row: Integer;
Remarks
Use the Row and Col properties to make a cell current or to find out which row or column contains the
current cell. Columns and rows are numbered from zero, beginning at the top for rows and at the left for
columns.
The Row property may be set to -1 to hide the selection, to a value between zero and Rows.Fixed-1 to
select a cell in a fixed column, or to a value between Rows.Fixed and Rows.Count-1 to select a cell in a
scrollable column.
Rows Property · 147
Setting the Row and Col properties automatically collapsed the selection to a single cell, resetting the
RowSel and ColSel properties. To specify a block selection, you must set Row and Col, then RowSel and
ColSel. Or use the Select method to select an arbitrary range with a single statement.
Setting the Row and Col properties does not ensure that the current cell is visible. To do that, use the
ShowCell method.
See Also
C1FlexGrid Class (page 101)
Rows Property
Gets the collection of rows in the grid.
Syntax
[VB]
Public Rows As RowCollection
[C#]
public RowCollection Rows {get;}
[Delphi]
property Rows: RowCollection;
Remarks
The Rows property returns a reference to the list of rows that make up the grid. With this reference, you
can add, remove, move, and count the rows. For more information on the tasks that can be performed
with this collection, see the RowCollection class reference topics.
This property is read-only. The grid creates and manages the row collection for you.
Upgrade Note: In the VSFlexGrid ActiveX control, the Rows and FixedRows properties corresponded to
the number of Rows and fixed Rows on the grid. In C1FlexGrid, use Rows.Count and Rows.Fixed.
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
RowSel Property
Gets or sets the index of the last row in the current selection.
Syntax
[VB]
Public RowSel As Integer
[C#]
public int RowSel {get; set;}
148 · C1FlexGrid Reference
[Delphi]
property RowSel: Integer;
Remarks
Use the RowSel and ColSel properties to modify a selection or to determine which cells are currently
selected. Columns and rows are numbered from zero, beginning at the top for rows and at the left for
columns.
Setting the Row and Col properties automatically collapses the selection to a single cell, resetting the
RowSel and ColSel properties. Therefore, to specify a block selection, you must Row and Col, then
RowSel and ColSel. Alternatively, you may use the Select method to select a range with a single
statement.
If the SelectionMode property is set to Listbox, you should use the Selected property on individual row
objects to select and deselect rows.
When a range is selected, the value of Row may be greater than or less than RowSel, and Col may be
greater than or less than ColSel. This is inconvenient when you need to set up bounds for loops. In these
cases, you can use the Selection property to retrieve a normalized CellRange object, where r1 <= r2 and
c1 <= c2.
See the ColSel property for an example.
See Also
C1FlexGrid Class (page 101)
ScrollBars Property
Gets or sets which scroll bars should appear in the grid.
Syntax
[VB]
Public ScrollBars As ScrollBars
[C#]
public ScrollBars ScrollBars {get; set;}
[Delphi]
property ScrollBars: ScrollBars;
Property Value
One of the ScrollBars enumeration values that indicates whether the grid should have no scroll bars, a
horizontal scroll bar, a vertical scroll bar, or both. The default is ScrollBars.Both.
Remarks
Scroll bars are displayed only if the contents of the control extend beyond its borders. For example, if
ScrollBars is set to ScrollBars.Horizontal, a horizontal scroll bar is displayed only if the control is not
wide enough to display all columns at once.
Even when it has no scrollbars, the control will still scroll to keep the selection visible. If you want to
prevent scrolling, trap the BeforeScroll event and set its Cancel parameter to true.
ScrollBars Property · 149
Note that setting the ScrollBars property to ScrollBars.Both doesn't mean that both scrollbars will always
be visible. They will only appear if the grid has more rows (or columns) than will fit in the control. To
determine whether the scrollbars are currently visible, you can use code such as:
•
Visual Basic
Function CheckScrollBars(fg As C1.Win.C1FlexGrid.C1FlexGrid) As
ScrollBars
Dim SBWID As Integer = SystemInformation.VerticalScrollBarWidth
Dim SBHEI As Integer = SystemInformation.HorizontalScrollBarHeight
Dim rcCtl As Rectangle = fg.Bounds
Dim rcClient As Rectangle = fg.ClientRectangle
Dim vbar As Boolean = rcCtl.Width - rcClient.Width >= SBWID
Dim hbar As Boolean = rcCtl.Height - rcClient.Height >= SBHEI
If vbar And hbar Then
Return ScrollBars.Both
End If
If vbar Then
Return ScrollBars.Vertical
End If
If hbar Then
Return ScrollBars.Horizontal
End If
Return ScrollBars.None
End Function 'CheckScrollBars
•
C#
ScrollBars CheckScrollBars(C1.Win.C1FlexGrid.C1FlexGrid fg)
{
int SBWID = SystemInformation.VerticalScrollBarWidth;
int SBHEI = SystemInformation.HorizontalScrollBarHeight;
Rectangle rcCtl = fg.Bounds;
Rectangle rcClient = fg.ClientRectangle;
bool vbar = (rcCtl.Width - rcClient.Width >=SBWID);
bool hbar = (rcCtl.Height - rcClient.Height >= SBHEI);
if (vbar && hbar) return ScrollBars.Both;
if (vbar) return ScrollBars.Vertical;
if (hbar) return ScrollBars.Horizontal;
return ScrollBars.None;
}
•
Delphi
function CheckScrollBars(fg: C1.Win.C1FlexGrid.C1FlexGrid): ScrollBars;
var
hbar: Boolean;
vbar: Boolean;
rcClient: Rectangle;
rcCtl: Rectangle;
SBHEI: Integer;
SBWID: Integer;
CheckScrollBars: ScrollBars;
begin
SBWID := SystemInformation.VerticalScrollBarWidth;
SBHEI := SystemInformation.HorizontalScrollBarHeight;
rcCtl := fg.Bounds;
rcClient := fg.ClientRectangle;
150 · C1FlexGrid Reference
vbar := rcCtl.Width - rcClient.Width >= SBWID;
hbar := rcCtl.Height - rcClient.Height >= SBHEI;
if vbar And hbar then
begin
Result := ScrollBars.Both;
exit;
end;
if vbar then
begin
Result := ScrollBars.Vertical;
exit;
end;
if hbar then
begin
Result := ScrollBars.Horizontal;
exit;
end;
Result := ScrollBars.None;
end; // CheckScrollBars
See Also
C1FlexGrid Class (page 101)
ScrollPosition Property
Gets or sets the scroll position.
Syntax
[VB]
Public ScrollPosition As Point
[C#]
public Point ScrollPosition {get; set;}
[Delphi]
property ScrollPosition: Point;
Property Value
A Point object that represents the scroll position in pixels.
Remarks
Use the ScrollPosition property to get or set the scroll position using pixel coordinates.
Use the TopRow and LeftCol properties to get or set the scroll position using cell coordinates.
Example
This code binds two grids (fgLeft and fgRight) together and synchronizes their scrolling in the vertical
direction (the user can scroll the independently in the horizontal direction).
•
Visual Basic
' bind grids together
ScrollPosition Property · 151
fgRight.DataSource = fgLeft
fgLeft.ScrollBars = ScrollBars.Horizontal
' synchronize vertical scrolling
Private Sub flex_AfterScroll(sender As Object, _
e As C1.Win.C1FlexGrid.RangeEventArgs)
' update sender grid (could be fgLeft or fgRight)
Dim fg As C1FlexGrid.C1FlexGrid = CType(sender, C1FlexGrid) '
fg.Update()
' get new vertical position from sender grid
Dim y As Integer = fg.ScrollPosition.Y
' apply new vertical position to the other grid
If fg = fgLeft Then
fgRight.ScrollPosition = New Point(fgRight.ScrollPosition.X, y)
Else
fgLeft.ScrollPosition = New Point(fgLeft.ScrollPosition.X, y)
End If
End Sub 'flex_AfterScroll
•
C#
// bind grids together
fgRight.DataSource = fgLeft;
fgLeft.ScrollBars = ScrollBars.Horizontal;
// synchronize vertical scrolling
private void flex_AfterScroll(object sender,
C1.Win.C1FlexGrid.RangeEventArgs e)
{
// update sender grid (could be fgLeft or fgRight)
C1FlexGrid.C1FlexGrid fg = ((C1FlexGrid)sender);
fg.Update();
// get new vertical position from sender grid
int y = fg.ScrollPosition.Y;
}
•
// apply new vertical position to the other grid
if (fg == fgLeft)
fgRight.ScrollPosition = new Point(fgRight.ScrollPosition.X, y);
else
fgLeft.ScrollPosition = new Point(fgLeft.ScrollPosition.X, y);
Delphi
// bind grids together
fgRight.DataSource := fgLeft;
fgLeft.ScrollBars := ScrollBars.Horizontal;
// synchronize vertical scrolling
procedure flex_AfterScroll(sender: System.Object;
e: C1.Win.C1FlexGrid.RangeEventArgs);
var
fg: C1FlexGrid;
begin
// update sender grid (could be fgLeft or fgRight)
fg := C1FlexGrid (sender);
fg.Update;
// get new vertical position from sender grid
152 · C1FlexGrid Reference
y := fg.ScrollPosition.Y;
// apply new vertical position to the other grid
if fg = fgLeft then
fgRight.ScrollPosition := Point.Create(fgRight.ScrollPosition.X, y)
else
fgLeft.ScrollPosition := Point.Create(fgLeft.ScrollPosition.X, y);
end; // flex_AfterScroll
Upgrade Note: The VSFlexGrid control scrolled one whole cell at a time, and did not have anything
equivalent to the ScrollPosition property. The C1FlexGrid is capable of scrolling one pixel at a time.
See Also
C1FlexGrid Class (page 101)
ScrollTrack Property
Specifies the grid behavior when the user drags the scrollbar thumb.
Syntax
[VB]
Public ScrollTrack As Boolean
[C#]
public bool ScrollTrack {get; set;}
[Delphi]
property ScrollTrack: Boolean;
Remarks
If ScrollTrack is set to true (the default value), the grid scrolls while the user drags the scrollbar thumb.
If ScrollTrack is set to false, the grid does not update the display until the user releases the scrollbar
thumb.
If the grid is very large and contains a lot of data, you may want to make scrolling faster by setting
ScrollTrack to false. In this case, you should consider using the ScrollTips property to provide some
feed-back while the user scrolls the grid.
See Also
C1FlexGrid Class (page 101)
ScrollTips Property
Returns or sets whether tool tips are shown on the vertical scrollbar while the user drags the scrollbar
thumb.
Syntax
[VB]
Public ScrollTips As Boolean
ScrollTips Property · 153
[C#]
public bool ScrollTips
[Delphi]
property ScrollTips: Boolean;
Remarks
Use the ScrollTips property to display a tooltip over the vertical scrollbar as the user moves the scroll
thumb. This allows the user to see which row will become visible when he releases the scroll thumb. This
feature makes it easy for users to browse and find specific rows on large data sets. This feature is
especially useful if the ScrollTrack property is set to false, because then the control will not scroll until
the thumb track is released.
To implement this feature in your programs, you must do two things:
1.
Set the ScrollTips property to true.
2.
Respond to the BeforeScrollTip event by setting the ScrollTipText property to text that describes
the given row.
Example
This code causes the grid to display scroll tip containing the index and data on the row that would
become the topmost visible row if the user releases the scrollbar thumb.
•
Visual Basic
flex.ScrollTips = True
flex.ScrollTrack = False
Private Sub flex_BeforeScrollTip(sender As Object, e As
RowColEventArgs)
Dim tip As String = String.Format("Row {0}" + ControlChars.Lf +
"{1}", e.Row, flex(e.Row, 1))
flex.ScrollTipText = tip
End Sub 'flex_BeforeScrollTip
•
C#
flex.ScrollTips = True
flex.ScrollTrack = False
Private Sub flex_BeforeScrollTip(sender As Object, e As
RowColEventArgs)
Dim tip As String
tip = String.Format("Row {0}" + ControlChars.Lf + "{1}", _
e.Row, flex(e.Row, 1))
flex.ScrollTipText = tip
End Sub 'flex_BeforeScrollTip
•
Delphi
flex.ScrollTips := True;
flex.ScrollTrack := False;
procedure Class1.flex_BeforeScrollTip(sender: System.Object; e:
RowColEventArgs);
var
tip: string;
begin
154 · C1FlexGrid Reference
tip := Format('Row {0}'#10'{1}', e.Row, flex[e.Row]);
flex.ScrollTipText := tip;
end;
Scrolltips are a special type of tooltip that is attached to the vertical scrollbar. To display general tooltips
(associated with grid cells, for example) use a ToolTip control. For example:
•
Visual Basic
Private ttip As New ToolTip(Me.components)
Private Sub flex_MouseMove(sender As Object, e As
System.Windows.Forms.MouseEventArgs)
Dim str As String
str = String.Format("This is cell {0}, {1}", _
flex.MouseRow, flex.MouseCol)
If str <> ttip.GetToolTip(flex) Then
ttip.SetToolTip(flex, str)
End If
End Sub 'flex_MouseMove
•
C#
private ToolTip ttip = new ToolTip(this.components);
private void flex_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
string str = string.Format("This is cell {0}, {1}",
flex.MouseRow, flex.MouseCol);
if (str != ttip.GetToolTip(flex))
ttip.SetToolTip(flex, str);
}
•
Delphi
private
ttip: ToolTip;
procedure flex_MouseMove(sender: System.Object; e:
System.Windows.Forms.MouseEventArgs);
var
str: string;
begin
str := System.String.Format('This is cell {0}, {1}', _
flex.MouseRow, flex.MouseCol);
if str <> ttip.GetToolTip(flex) then
ttip.SetToolTip(flex, str);
end; // flex_MouseMove
See Also
C1FlexGrid Class (page 101)
ScrollTipText Property
Gets or sets the tooltip text displayed as the user scrolls vertically.
Syntax
[VB]
Public ScrollTipText As String
Selection Property · 155
[C#]
public string ScrollTipText {get; set;}
[Delphi]
property ScrollTipText: string;
Remarks
Set this property in response to the BeforeScrollTip event to display information describing a given row
as the user scrolls the contents of the control.
For more details and examples, see the ScrollTips property.
See Also
C1FlexGrid Class (page 101)
Selection Property
Gets a CellRange object that corresponds to the current selection.
Syntax
[VB]
Public Selection As CellRange
[C#]
public CellRange Selection {get;}
[Delphi]
property Selection: CellRange;
Property Value
A CellRange object that can be used to manipulate the cells in the selection.
Remarks
The range corresponds to the current selection, defined by the Row, Col, RowSel, and ColSel properties.
The range is normalized, so r1 <= r2 and c1 <= c2. This makes it easy to loop through the selection.
•
Visual Basic
' select a range, show it
flex.Select(1, 1, 5, 5)
Console.WriteLine("Cursor {0}, Selection {1}", flex.CursorCell,
flex.Selection)
' select another range, show it
flex.Select(5, 5, 1, 1)
Console.WriteLine("Cursor {0}, Selection {1}", flex.CursorCell,
flex.Selection)
•
C#
// select a range, show it
flex.Select(1, 1, 5, 5);
Console.WriteLine("Cursor {0}, Selection {1}", flex.CursorCell,
flex.Selection);
156 · C1FlexGrid Reference
// select another range, show it
flex.Select(5, 5, 1, 1);
Console.WriteLine("Cursor {0}, Selection {1}", flex.CursorCell,
flex.Selection);
•
Delphi
// select a range, show it
flex.Select(1, 1, 5, 5)
Console.WriteLine('Cursor {0}, Selection {1}', flex.CursorCell,
flex.Selection);
// select another range, show it
flex.Select(5, 5, 1, 1);
Console.WriteLine('Cursor {0}, Selection {1}', flex.CursorCell,
flex.Selection);
Running this code creates the following output:
Cursor CellRange: (1,1)-(1,1), Selection CellRange: (1,1)-(5,5)
Cursor CellRange: (5,5)-(5,5), Selection CellRange: (1,1)-(5,5)
See Also
C1FlexGrid Class (page 101)
SelectionMode Property
Specifies the selection behavior of the grid.
Syntax
[VB]
Public SelectionMode As SelectionModeEnum
[C#]
public SelectionModeEnum SelectionMode {get; set;}
[Delphi]
property SelectionMode: SelectionModeEnum;
Property Value
One of the SelectionModeEnum values. The default is SelectionModeEnum.Default.
Remarks
In most selection modes, you can obtain the current selection using the Selection property. When
SelectionMode is set to SelectionModeEnum.ListBox, however, the selection may not consist of a
continuous range of rows. In this case, you can check the selection state of individual rows using the
Row’s Selected property or obtain a collection of selected rows using the Row’s Selected property.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
SetCellCheck Property · 157
SetCellCheck Property
Sets the state of the checkbox in a cell.
Syntax
[VB]
Public SetCellCheck As Integer
[C#]
public Integer SetCellCheck {get; set;}
[Delphi]
property SetCellCheck: Integer;
Remarks
In addition to the usual cell contents, you can display checkboxes in cells. There are two methods for
showing checkboxes in cells:
1.
You can use the SetCellCheck and GetCellCheck properties to assign checkboxes directly to the
cells. In this case, the cell contents and the checkboxes are independent. In this mode, you can use
tow or three-state checkboxes.
2.
You can use set DataType property of the Column object to Boolean, and all values on the
column will be displayed as two-state checkboxes.
In either mode, if the AllowEditing property is set to True, the user will be able to check and uncheck the
boxes using the mouse and the keyboard.
See Also
C1FlexGrid Class (page 101)
ShowButtons Property
Specifies when the grid should display drop down and popup buttons in editable cells.
Syntax
[VB]
Public ShowButtons As ShowButtonsEnum
[C#]
public ShowButtonsEnum ShowButtons {get;}
[Delphi]
property ShowButtons: ShowButtonsEnum;
Property Value
One of the ShowButtonsEnum values. The default is ShowButtonsEnum.WithFocus.
See Also
C1FlexGrid Class (page 101)
158 · C1FlexGrid Reference
ShowCursor Property
Specifies whether the grid should display a record selector image.
Syntax
[VB]
Public ShowCursor As Boolean
[C#]
public bool ShowCursor {get; set;}
[Delphi]
property ShowCursor: Boolean;
Remarks
Specifies whether the grid should display a record selector image on the first fixed column of the current
row. The record selector is a small triangle similar to the one used in Access and most data base grids.
See Also
C1FlexGrid Class (page 101)
ShowErrors Property
Gets or sets whether the grid should monitor and display errors in the data source. The errors are
provided by the data source object using the IDataErrorInfo interface (ADO.NET and C1Data support
this).
Syntax
[VB]
Public ShowErrors As Boolean
[C#]
public bool ShowErrors {get; set;}
[Delphi]
property ShowErrors: Boolean;
Remarks
If this property is enabled, cells with errors will display an error icon (customizable via the SetGlyph
method). When the user moves the mouse over the error icon, the control will display a tooltip containing
the error description. For example:
•
Visual Basic
Me._flex.ShowErrors = True
dt.Rows(3).SetColumnError(_dt.Columns(0), "row 3, col 0 is bad") '
dt.Rows(4).SetColumnError(_dt.Columns(1), "this cell is bad too") '
dt.Rows(5).RowError = "This whole row is bad" '
•
C#
this._flex.ShowErrors = true;
Styles Property · 159
dt.Rows[3].SetColumnError(_dt.Columns[0], "row 3, col 0 is bad");
dt.Rows[4].SetColumnError(_dt.Columns[1], "this cell is bad too");
dt.Rows[5].RowError = "This whole row is bad";
•
Delphi
Self._flex.ShowErrors := True;
dt.Rows[3].SetColumnError(_dt.Columns[0], 'row 3, col 0 is bad');
dt.Rows[4].SetColumnError(_dt.Columns[1], 'this cell is bad too');
dt.Rows[5].RowError := 'This whole row is bad';
See Also
C1FlexGrid Class (page 101)
Styles Property
Gets the collection of cell styles in the grid.
Syntax
[VB]
Public Styles As CellStyleCollection
[C#]
public CellStyleCollection Styles {get;}
[Delphi]
property Styles: CellStyleCollection;
Remarks
The Styles property enables you to obtain a reference to the list of styles that are currently defined in the
grid. With this reference, you can add, remove, and count the styles. For more information on the tasks
that can be performed with this collection, see the CellStyleCollection class reference topics. For
information on cell formatting, see the CellStyle reference topics.
This property is read-only. The grid creates and manages the collection for you.
Upgrade Note: The VSFlexGrid ActiveX control had many properties that affected the way the grid was
displayed (e.g. BackColor, BackColorAlternate, BackColorBkg, BackColorFixed, BackColorFrozen,
BackColorSel, and so on). The C1FlexGrid control replaces all these properties with a
CellStyleCollection of CellStyle objects. This makes the object model simpler, more consistent, and more
powerful. You can change the stock styles or define your own, and assign them to rows, columns, or
arbitrary cell ranges.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
SubTotalPosition Property
Specifies whether the Subtotal method should add node rows above or below the data being
summarized.
160 · C1FlexGrid Reference
Syntax
[VB]
Public SubTotalPosition As SubTotalPositionEnum
[C#]
public SubTotalPositionEnum SubTotalPosition {get; set;}
[Delphi]
property SubTotalPosition: SubTotalPositionEnum;
Property Value
One of the SubTotalPositionEnum values. The default is SubTotalPositionEnum.AboveData.
Remarks
This property also determines how the outline tree is drawn. Changing this property removes any node
rows present on the grid.
See Also
C1FlexGrid Class (page 101)
TopRow Property
Gets or sets the index of the topmost non-fixed visible row.
Syntax
[VB]
Public TopRow As Integer
[C#]
public int TopRow {get; set;}
[Delphi]
property TopRow: Integer;
Remarks
Setting the TopRow property causes the grid to scroll vertically so that the given row becomes the
topmost visible row. This is often useful when you want to synchronize two or more grids so that when
one of them scrolls, the other scrolls as well. To scroll horizontally, use the LeftCol property.
When setting this property, the largest possible row number is the total number of rows minus the
number of rows that will fit the display. Attempting to set TopRow to a greater value will cause the grid
to set it to the largest possible value (no error will occur).
The value returned by the LeftCol and TopRow properties may correspond to partially visible rows or
columns.
Use the LeftCol and TopRow properties to scroll using cells as units. Use the ScrollPosition property to
scroll the grid using pixel units.
To ensure that a given cell is visible, use the ShowCell method.
Tree Property · 161
See Also
C1FlexGrid Class (page 101)
Tree Property
Gets the GridTree object that controls the appearance of the outline tree in the grid.
Syntax
[VB]
Public Tree As GridTree
[C#]
public GridTree Tree {get;}
[Delphi]
property Tree: GridTree;
Remarks
The C1FlexGrid control can group data hierarchically and display it with a collapsible tree similar to the
one in the Microsoft TreeView control. The GridTree object is used to specify the position and
appearance of the outline tree.
This property is read-only.
See Also
C1FlexGrid Class (page 101)
C1FlexGrid Methods
AddItem Method
Adds a row to the control and populates the row with the given data.
Syntax
[VB]
Public Function AddItem(item As String) As Row
Public Function AddItem(item As String, index As Integer) As Row
Public Function AddItem(items As Object( )) As Row
Public Function AddItem(items As Object( ), rowIndex As Integer, colIndex As Integer) As Row
[C#]
public Row AddItem (String item )
public Row AddItem (String item , Int index )
public Row AddItem ( object[] items )
public Row AddItem ( object[] items , Int rowIndex , Int colIndex )
162 · C1FlexGrid Reference
[Delphi]
function AddItem(item: string): Row;
function AddItem(item: string; index: Integer): Row;
function AddItem(items: Object): Row;
function AddItems(items: Object; rowIndex: Integer; colIndex: Integer): Row;
Parameter
Description
Item
String containing data for each cell on the new row. Items are separated by
Tab characters by default. You can change the separator character using
ClipSeparators property.
index
Position where the new row will be inserted. If this parameter is omitted, the
new row is added at the bottom of the grid.
items
Array of objects that will be assigned to the new row.
colIndex
First column to populate with the items in the items array. This parameter will
normally be set to zero or to the first scrollable column.
Remarks
You can also add and remove rows using the Rows collection. The AddItem method provides a concise
syntax for inserting a row with the Row’s Insert method and then populating each cell.
Example
The code bellows adds three rows to the grid.
•
Visual Basic
' add row at the bottom, using tabs as separators
flex.ClipSeparators = vbTab + vbLf ' << default value
flex.AddItem("col 0" + vbTab + "col1" + vbTab + "col2")
' add row at the top, using pipes as separators
flex.ClipSeparators = "|;"
flex.AddItem("col 0|col1|col2", 0)
' add row at the bottom, using an object array
Dim items As Object() = {"col0", "col1", 12}
flex.AddItem(items, flex.Rows.Count, 0)
•
C#
// add row at the bottom, using tabs as separators
flex.ClipSeparators = "\t\n"; // << default value
flex.AddItem("col 0\tcol1\tcol2");
// add row at the top, using pipes as separators
flex.ClipSeparators = "|;";
flex.AddItem("col 0|col1|col2", 0);
// add row at the bottom, using an object array
object[] items = { "col0", "col1", 12 };
flex.AddItem(items, flex.Rows.Count, 0);
Aggregate Method · 163
•
Delphi
var
items: array of System.Object;
begin
flex.ClipSeparators := #9#10;
flex.AddItem('col 0'#9'col1'#9'col2');
flex.ClipSeparators := '|;';
flex.AddItem('col 0|col1|col2', 0);
SetLength(items, 3);
items[0] := 'col0';
items[1] := 'col1';
items[2] := System.Object(12);
flex.AddItem(items, flex.Rows.Count, 0);
end;
For more examples, see the Redraw property and the Saving and Loading Grids to Text Files (page 57)
topic.
See Also
C1FlexGrid Class (page 101)
Aggregate Method
Calculates aggregate statistics for a range of cells.
Syntax
[VB]
Public Function Aggregate(aggType As AggregateEnum) As Double
Public Function Aggregate(aggType As AggregateEnum, flags As AggregateFlags) As Double
Public Function Aggregate(aggType As.AggregateEnum, rg As CellRange) As Double
Public Function Aggregate(aggType As AggregateEnum, rg As CellRange, flags As AggregateFlags) As
Double
Public Function Aggregate(aggType As AggregateEnum, r1 As Integer, c1 As Integer, r2 As Integer, c2
As Integer) As Double
Public Function Aggregate(aggType As AggregateEnum, r1 As Integer, c1 As Integer, r2 As Integer, c2
As Integer, flags As AggregateFlags) As Double
[C#]
public Double Aggregate (AggregateEnum aggType, int r1, int c1, int r2, int c2)
public Double Aggregate (AggregateEnum aggType )
public Double Aggregate (AggregateEnum aggType, CellRange rg )
public Double Aggregate (AggregateEnum aggType, int r1, int c1, int r2, int c2, AggregateFlags flags)
public Double Aggregate (AggregateEnum aggType, AggregateFlags flags)
public Double Aggregate (AggregateEnum aggType, CellRange rg, AggregateFlags flags)
164 · C1FlexGrid Reference
[Delphi]
function Aggregate(aggType: AggregateEnum): Double;
function Aggregate(aggType: AggregateEnum; flags: AggregateFlags): Double;
function Aggregate(aggType: AggregateEnum; rg: CellRange): Double;
function Aggregate(aggType: AggregateEnum; rg: CellRange; flags: AggregateFlags): Double;
function Aggregate(aggType: AggregateEnum; r1: Integer; c1:Integer; r2: Integer; c2: Integer): Double;
function Aggregate(aggType: AggregateEnum; r1: Integer; c1:Integer; r2: Integer; c2: Integer; flags:
AggregateFlags): Double;
Parameter
Description
Function
One of the AggregateEnum values. This parameter specifies the type of
aggregate to calculate.
row1, col1, row2, col2
Four integers that define the range of cells to aggregate over.
Rg
A CellRange object that defines the range of cells to aggregate over.
flags
A combination of values from the AggregateFlags enumeration. The default
value is AggregateFlags.None.
Return Value
A Double value for the calculated aggregate.
Example
This code uses the Aggregate method to calculate aggregate statistics for arbitrary ranges. Whenever the
grid selection changes, aggregates are calculated and written to the console.
•
Visual Basic
Private Sub flex_SelChange(sender As Object, e As System.EventArgs)
Dim fmt As String = "Count {0:0}, Sum {1:#,##0.00}, " & _
"Avg {2:#,##0.00}, Stdev {3:#,##0.00}"
Dim agg As String = String.Format(fmt, _
flex.Aggregate(AggregateEnum.Count), _
flex.Aggregate(AggregateEnum.Sum), _
flex.Aggregate(AggregateEnum.Average), _
flex.Aggregate(AggregateEnum.Std))
Console.WriteLine(agg)
End Sub 'flex_SelChange
•
C#
private void flex_SelChange(object sender, System.EventArgs e)
{
string fmt = "Count {0:0}, Sum {1:#,##0.00}, " +
"Avg {2:#,##0.00}, Stdev {3:#,##0.00}";
string agg = string.Format(fmt,
flex.Aggregate(AggregateEnum.Count),
flex.Aggregate(AggregateEnum.Sum),
flex.Aggregate(AggregateEnum.Average),
flex.Aggregate(AggregateEnum.Std));
Console.WriteLine(agg);
}
AutoSizeCol Method · 165
•
Delphi
procedure Class1.flex_SelChange(sender: System.Object; e:
System.EventArgs);
var
agg: string;
fmt: string;
begin
fmt := ('Count {0:0}, Sum {1:#,##0.00}, ' + 'Avg {2:#,##0.00}, Stdev
{3:#,##0.00}');
agg := System.String.Format(fmt, flex.Aggregate(AggregateEnum.Count),
flex.Aggregate(AggregateEnum.Sum),
flex.Aggregate(AggregateEnum.Average),
flex.Aggregate(AggregateEnum.Std));
Console.WriteLine(agg);
end;
See Also
C1FlexGrid Class (page 101)
AutoSizeCol Method
Adjusts the width of a column to fit the current data.
Syntax
[VB]
Public Sub AutoSizeCol(col As Integer)
Public Sub AutoSizeCol(col As Integer, extraSpace As Integer)
[C#]
public virtual void AutoSizeCol ( int col )
public virtual void AutoSizeCol ( int col , int extraSpace )
[Delphi]
procedure AutoSizeCol(col: Integer);
procedure AutoSizeCol(col: Integer, extraSpace: Integer);
Parameter
Description
col
The index of the column to be resized.
extraSpace
The amount of extra space, in pixels, to add to the column width.
Remarks
This method measures every cell in the column, taking into account the cell contents and style. If the grid
has a large number of rows, consider using the AutoSizeCols method, which allows you to specify which
rows and columns to measure.
See Also
C1FlexGrid Class (page 101)
166 · C1FlexGrid Reference
AutoSizeCols Method
Adjusts the width of all columns to fit the current data.
Syntax
[VB]
Public Sub AutoSizeCols()
Public Sub AutoSizeCols(extraSpace As Integer)
Public Sub AutoSizeCols(col1 As Integer, col2 As Integer, extraSpace As Integer)
Public Sub AutoSizeCols(row1 As Integer, col1 As Integer, row2 As Integer, col2 As Integer, extraSpace
As Integer, flags As AutoSizeFlags)
Protected Sub AutoSizeCols(g As Graphics, row1 As Integer, col1 As Integer, row2 As Integer, col2 As
Integer, extra As Integer, flags As AutoSizeFlags)
[C#]
public virtual void AutoSizeCols ( )
public virtual void AutoSizeCols ( int extraSpace )
public virtual void AutoSizeCols ( int col1 , int col2 , int extraSpace )
public virtual void AutoSizeCols ( int row1 , int col1 , int row2 , int col2 , int extraSpace , AutoSizeFlags
flags )
public protected internal virtual void AutoSizeCols (Graphics g , int row1 , int col1 , int row2 , int col2 ,
int extra ,AutoSizeFlags flags )
[Delphi]
procedure AutoSizeCols;
procedure AutoSizeCols(extraSpace: Integer);
procedure AutoSizeCols(col1: Integer; col2: Integer; extraSpace: Integer);
procedure AutoSizeCols(row1: Integer; col1: Integer; row2: Integer; col2: Integer; extraSpace: Integer;
flags: AutoSizeFlags);
procedure AutoSizeCols(g: Graphics; row1: Integer; col1: Integer; row2: Integer; col2: Integer; extra:
Integer; flags: AutoSizeFlags);
Parameter
Description
col1, col2
The index of the first and last columns to be resized.
row1, row2
The rows to use when measuring the data. If not specified, the grid uses all rows.
extraSpace
The amount of extra space, in pixels, to add to the column widths.
flags
A combination of values from the AutoSizeFlags enumeration. The flags specify
options such as ignore hidden or merged columns, or make all column widths the
same.
AutoSizeRow Method · 167
Remarks
By default, this method measures every cell in the column, taking into account the cell contents and style.
If the grid has a large number of rows, consider using the version that allows you to specify the row
range. You can include only a few hundred rows in the process, and add some extra spacing for safety.
See Also
C1FlexGrid Class (page 101)
AutoSizeRow Method
Adjusts the height of a single row to fit the current data.
Syntax
[VB]
Public Sub AutoSizeRow(row As Integer)
[C#]
public virtual void AutoSizeRow ( int row )
[Delphi]
procedure AutoSizeRow(row: Integer);
Parameter
Description
row
The index of the row to be resized.
Remarks
This method measures every cell in the row, taking into account the cell contents and style. To resize
many rows at once, use the AutoSizeRows method.
Example
See the ChangeEdit event.
See Also
C1FlexGrid Class (page 101)
AutoSizeRows Method
Adjusts the height of a range of rows to fit the current data.
Syntax
[VB]
Public Sub AutoSizeRows()
Public Sub AutoSizeRows(row1 As Integer, col1 As Integer, row2 As Integer, col2 As Integer, extra As
Integer, flags As AutoSizeFlags)
168 · C1FlexGrid Reference
[C#]
public virtual void AutoSizeRows ( )
public protected internal virtual void AutoSizeRows (Graphics g , int row1 , int col1 , int row2 , int col2 ,
int extra , AutoSizeFlags flags )
[Delphi]
procedure AutoSizeRows;
procedure AutoSizeRows(g: Graphics; row1: Integer; col1: Integer; row2: Integer; col2: Integer; extra:
Integer; flags: AutoSizeFlags);
Parameter
Description
col
The index of the column to be resized.
extraSpace
The amount of extra space, in pixels, to add to the column width.
Remarks
This method measures every cell in the column, taking into account the cell contents and style. To resize a
single row, use the AutoSizeRow method.
See Also
C1FlexGrid Class (page 101)
Clear Method (C1FlexGrid)
Clears the contents of the grid.
Syntax
[VB]
Public Sub Clear()
Public Sub Clear(clearFlags As ClearFlags)
Public Sub Clear(clearFlags As ClearFlags, rg As CellRange)
Public Sub Clear(clearFlags As ClearFlags, row As Integer, col As Integer)
Public Sub Clear(clearFlags As ClearFlags, row1 As Integer, col1 As Integer, row2 As Integer, col2 As
Integer)
[C#]
public void Clear ()
public void Clear (ClearFlags clearFlags )
public void Clear (ClearFlags clearFlags , int row , int col )
public void Clear (ClearFlags clearFlags , int row1 , int col1 , int row2 , int col2 )
public void Clear (ClearFlags clearFlags , CellRange rg )
CreateImage Method · 169
[Delphi]
procedure Clear;
procedure Clear(clearFlags: ClearFlags);
procedure Clear(clearFlags: ClearFlags; row: Integer; col: Integer);
procedure Clear(clearFlags: ClearFlags; row1: Integer; col1: Integer; row2: Integer; col2: Integer);
procedure Clear(clearFlags: ClearFlags; rg: CellRange);
Parameter
Description
flags
A combination of values from the ClearFlags enumeration. The flags specify
what to clear (data, formatting, etc). The default is ClearFlags.All, which
removes all data, styles, and user data from all cells, rows, and columns.
rg
A CellRange object that specifies the range to clear. By default, the whole grid
is cleared.
row1, col1, row2, col2
Four indices that specify the range to clear. By default, the whole grid is
cleared.
Remarks
The Clear method does not affect the number of rows and columns on the grid, and cannot be used to
clear data when the grid is bound to a data source.
See the ClearFlags topic for detailed information on what grid elements get cleared when you call this
method.
See Also
C1FlexGrid Class (page 101)
CreateImage Method
Creates an image of the entire grid or range.
Syntax
[VB]
Public Function CreateImage() As Image
Public Function CreateImage(rg As CellRange) As Image
Public Function CreateImage(rg As CellRange, emfType As EmfType) As Image
Public Function CreateImage(row1 As Integer, col1 As Integer, row2 As Integer, col2 As Integer) As
Image
Public Function CreateImage(row1 As Integer, col1 As Integer, row2 As Integer, col2 As Integer,
emfType As EmfType) As Image
[C#]
public Image CreateImage ( )
170 · C1FlexGrid Reference
public Image CreateImage (CellRange rg )
public Image CreateImage (CellRange rg , EmfType emfType )
public Image CreateImage ( int row1 , System.Int32 col1 , int row2 , int col2 )
public Image CreateImage ( int row1 , int col1 , int row2 , int col2 , EmfType emfType )
[Delphi]
function CreateImage: Image;
function CreateImage(rg: CellRange): Image;
function CreateImage(rg: CellRange; emfType: EmfType): Integer;
function CreateImage(row1: Integer; col1: Integer; row2: Integer; col2: Integer): Image;
function CreateImage(row1: Integer; col1: Integer; row2: Integer; col2: Integer; emfType: EmfType):
Image;
Parameter
Description
Range
A CellRange object that specifies the range that should be included in the
image. By default, the method returns an image of the whole grid.
row1, col1, row2, col2
Four indices that specify the range that should be included in the image. By
default, the method returns an image of the whole grid.
emfType
A value from the EmfType enumeration that specifies the type of metafile to
create (GDI, GDI+, or dual). The default value for this parameter is
EmfType.EmfOnly.
Return Value
An Image object containing a metafile image of the grid.
Remarks
Use this method to copy grid images to the clipboard so you can paste them into other applications.
For example, the code below creates an image of a grid range and saves it to a png file that can be
included in other documents such as web pages:
•
Visual Basic
Private Sub button1_Click(sender As Object, e As System.EventArgs)
Dim img As Image = _flex.CreateImage(0, 0, 10, 5)
img.Save("c:\temp\flex.png") '
End Sub 'button1_Click
•
C#
private void button1_Click(object sender, System.EventArgs e)
{
Image img = _flex.CreateImage(0,0,10,5);
img.Save(@"c:\temp\flex.png",
System.Drawing.Imaging.ImageFormat.Png);
}
DrawCell Method · 171
•
Delphi
procedure Class1.button1_Click(sender: System.Object; e:
System.EventArgs);
var
img: Image;
begin
img := _flex.CreateImage(0, 0, 10, 5);
img.Save('c:\temp\flex.png', System.Drawing.Imaging.ImageFormat.Png);
end;
See Also
C1FlexGrid Class (page 101)
DrawCell Method
Draws a whole cell or parts of it.
Syntax
[VB]
Public Sub DrawCell()
Public Sub DrawCell(flags As DrawCellFlags)
[C#]
public void DrawCell ( )
public void DrawCell (DrawCellFlags flags )
[Delphi]
procedure DrawCell;
procedure DrawCell(flags: DrawCellFlags);
Remarks
This method is used in routines that handle the OwnerDrawCell event, which fires when the DrawMode
property is set to OwnerDraw. The DrawCell method is useful when you want to draw parts of the cell
yourself, combining them with the default grid painting routines.
The flags parameter determines which cell elements should be painted. The options are:
Parameter
Description
Background
The control paints the background area.
Border
The control paints the border.
Content
The control paints the cell content (text and image).
All
The control paints the whole cell.
Typically, your code will either (1) paint the cell background and call DrawCell to paint the cell borders
and content, or (2) call DrawCell to paint the background and borders and then use custom code to paint
the cell contents.
172 · C1FlexGrid Reference
See Also
OwnerDrawCellEventArgs Class (page 271)
FindRow Method
Finds a row that contains a given string or object.
Syntax
[VB]
Public Function FindRow(objFind As Object, rowStart As Integer, col As Integer, wrap As Boolean) As
Integer
Public Function FindRow(strFind As String, rowStart As Integer, col As Integer, caseSensitive As
Boolean, fullMatch As Boolean, wrap As Boolean) As Integer
[C#]
public Integer FindRow (Object objFind , int rowStart , int col , Boolean wrap )
public Integer FindRow (String strFind , int rowStart , int col , Boolean caseSensitive , Boolean fullMatch ,
Boolean wrap )
[Delphi]
function FindRow(objFind: Object; rowStart: Integer; col: Integer; wrap: Boolean): Integer;
function FindRow(strFind: string; rowStart: Integer; col: Integer; caseSensitive: Boolean; fullMatch:
Boolean; wrap: Boolean): Integer;
Parameter
Description
strFind
String to look for.
objFind
Object to look for.
rowStart
Index of the row where the search should start.
col
Column that contains the data to be searched.
caseSensitive
Whether the search should be case-sensitive.
fullMatch
Whether a full match is required. If this parameter is set to false, searching for
"John" may return a row that contains "Johnson".
wrap
Whether the search should stop at the bottom of the grid or wrap around and
restart from the first scrollable row.
Return Value
The index of the row that contains the data, or –1 if the data is not found.
Remarks
To allow users to search for data as they type, use the AutoSearch property.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
FinishEditing Method · 173
FinishEditing Method
Finishes editing the current cell and takes the grid out of edit mode.
Syntax
[VB]
Public Function FinishEditing() As Boolean
Public Function FinishEditing(cancel As Boolean) As Boolean
[C#]
public Boolean FinishEditing ( )
public Boolean FinishEditing (Boolean cancel )
[Delphi]
function FinishEditing: Boolean;
function FinishEditing(cancel: Boolean): Boolean;
Parameter
Description
cancel
Whether to cancel the current edits and revert the cell to its original value.
Return Value
True if the control is no longer in edit mode, false if validation failed and the control was put back in edit
mode.
Remarks
To determine whether the grid is in edit mode, check whether the Editor property is null.
If the cancel parameter is set to false, the grid will fire the ValidateEdit and AfterEdit events as usual.
Depending on how these events are handled, the grid may return to edit mode. If the cancel parameter is
set to true, the grid is guaranteed to get out of edit mode.
See Also
C1FlexGrid Class (page 101)
GetCellCheck Method
Returns the state of the checkbox in a grid cell.
Syntax
[VB]
Public Function GetCellCheck(row As Integer, col As Integer) As CheckEnum
[C#]
public virtual CheckEnum GetCellCheck ( int row , int col )
174 · C1FlexGrid Reference
[Delphi]
function GetCellCheck(row: Integer; col: Integer): CheckEnum;
Parameter
Description
row, col
The coordinates of the cell.
Return Value
One of the values in the CheckEnum enumeration.
Remarks
By default, the grid displays values in boolean columns as checkboxes (the type of the column is
determined by the DataType property of the Column object). If you don't want boolean values displayed
as checkboxes, set the column's Format property to a string containing the values that should be
displayed for True and False values. For example:
•
Visual Basic
fg.Cols("bools").Format = "Yes;No"
•
C#
fg.Cols("bools").Format = "Yes;No";
•
Delphi
fg.Cols['bools'].Format := 'Yes;No';
In unbound mode, you can use the GetCellCheck and SetCellCheck properties to add checkboxes to any
cells. The checkboxes will be displayed along with any text in the cell, and you can set their position
using the column's ImageAlign property.
There are two types of check boxes: boolean and tri-state. Boolean check boxes toggle between the
Checked and Unchecked states. Tri-state check boxes cycle through the settings TSChecked and
TSUnchecked and TSGrayed.
For example, the code below creates a boolean checkbox in cell (3,3) and a tri-state checkbox in cell (4,3):
•
Visual Basic
fg.SetCellCheck(3, 3, CheckEnum.Unchecked)
' boolean
fg.SetCellCheck(4, 3, CheckEnum.TSUnchecked) ' tri-state
•
C#
fg.SetCellCheck(3, 3, CheckEnum.Unchecked)
// boolean;
fg.SetCellCheck(4, 3, CheckEnum.TSUnchecked) // tri-state;
•
Delphi
fg.SetCellCheck(3, 3, CheckEnum.Unchecked);
fg.SetCellCheck(4, 3, CheckEnum.TSUnchecked);
See Also
C1FlexGrid Class (page 101)
GetCellImage Method · 175
GetCellImage Method
Gets the image assigned to a cell.
Syntax
[VB]
Public Function GetCellImage(row As Integer, col As Integer) As Image
[C#]
public Image GetCellImage ( int row , int col )
[Delphi]
function GetCellImage(row: Integer; col: Integer): Image;
Parameter
Description
row
Row that contains the image.
col
Column that contains the image.
Remarks
This method retrieves images assigned to a cell using the SetCellImage method.
See Also
C1FlexGrid Class (page 101)
GetCellRange Method
Returns a CellRange object that can be used to format and manipulate a range.
Syntax
[VB]
Public Function GetCellRange(row As Integer, col As Integer) As CellRange
Public Function GetCellRange(row1 As Integer, col1 As Integer, row2 As Integer, col2 As Integer) As
CellRange
[C#]
public CellRange GetCellRange ( int row1 , int col1 , int row2 , int col2 )
public CellRange GetCellRange ( int row , int col )
[Delphi]
function GetCellRange(row: integer; col: Integer): CellRange;
function GetCellRange(row1: Integer; col1: Integer; row2: Integer; col2: Integer): CellRange;
176 · C1FlexGrid Reference
Parameter
Description
row, col
The coordinates of a single cell that represents the range.
row1, col1, row2, col2
Four indices that specify the range.
Return Value
A CellRange object that can be used to format and manipulate the specified range.
Remarks
The CellRange object provides access to properties of the cells in the range. For example, the code below
sets the style of a range:
•
Visual Basic
Dim rg As CellRange = flex.GetCellRange(5, 5, 20, 8)
rg.Style = flex.Styles("MyStyle")
•
C#
CellRange rg = flex.GetCellRange(5, 5, 20, 8);
rg.Style = flex.Styles["MyStyle"];
•
Delphi
var
rg: CellRange;
begin
rg := flex.GetCellRange(5, 5, 20, 8);
rg.Style := flex.Styles['MyStyle'];
end;
NOTE: CellRange is a class, not a struct. Because of this, you have to assign the value to a variable and
then use the variable. For example, the following code will not compile:
•
Visual Basic
' this does not compile!!!
flex.GetCellRange(5, 5, 20, 8).Style = flex.Styles("MyStyle")
•
C#
// this does not compile!!!
flex.GetCellRange(5, 5, 20, 8).Style = flex.Styles["MyStyle"];
•
Delphi
flex.GetCellRange(5, 5, 20, 8).Style := flex.Styles['MyStyle'];
See Also
C1FlexGrid Class (page 101)
GetCellRect Method
Returns a Rectangle object with the coordinates of the cell on the screen.
Syntax
[VB]
Public Function GetCellRect(row As Integer, col As Integer) As Rectangle
GetCellStyle Method · 177
Public Function GetCellRect(row As Integer, col As Integer, show As Boolean) As Rectangle
[C#]
public Rectangle GetCellRect ( int row , int col )
public Rectangle GetCellRect ( int row , int col , Boolean show )
[Delphi]
function GetCellRect(row: Integer; col: Integer): Rectangle;
function GetCellRect(row: Integer; col: Integer; show: Boolean): Rectangle;
Parameter
Description
row, col
The coordinates of the cell.
show
Whether the cell should be scrolled into view before the rectangle is calculated.
Return Value
A Rectangle object containing the coordinates of the cells rectangle, in pixels and relative to the control's
client area.
Remarks
This property is useful if you need to implement custom editors or other elements that need to be
positioned over cells.
See Also
C1FlexGrid Class (page 101)
GetCellStyle Method
Returns a custom style associated with a cell, or null if the cell doesn't have a custom style.
Syntax
[VB]
Public Function GetCellStyle(row As Integer, col As Integer) As CellStyle
[C#]
public CellStyle GetCellStyle ( int row , int col )
[Delphi]
function GetCellStyle(row: Integer; col: Integer): CellStyle;
Parameter
Description
row, col
The coordinates of the cell that contains the custom style.
Return Value
A CellStyle object containing the custom style assigned to the cell, or null if the cell has no custom style.
178 · C1FlexGrid Reference
Remarks
If the cell doesn't have a custom style, the grid paints it using one of the built-in styles. The built-in style
is selected based on the cell position and state (fixed, scrollable, highlighted, etc). To retrieve the style that
will be used to paint the cell (custom or built-in) use the GetCellStyleDisplay method.
See Also
C1FlexGrid Class (page 101)
GetCellStyleDisplay Method
Returns the style used to render a cell.
Syntax
[VB]
Public Function GetCellStyleDisplay(row As Integer, col As Integer) As CellStyle
[C#]
public CellStyle GetCellStyleDisplay ( int row , int col )
[Delphi]
function GetcellStyleDisplay(row: Integer; col: Integer): CellStyle;
Parameter
Description
row, col
The coordinates of the cell that contains the style.
Return Value
A CellStyle object containing the style that will be used to render the cell. If the cell has a custom style
associated with it, GetCellStyleDisplay returns that style; otherwise it returns the appropriate stock style
(e.g., Normal, Fixed, etc.).
Remarks
The style returned may be a custom style assigned to the cell or a built-in style if the cell doesn't have one
(this method never returns null). Use the GetCellStyle method to determine whether a cell has a custom
style and to retrieve it.
See Also
C1FlexGrid Class (page 101)
GetData Method
Returns the data in a grid cell.
Syntax
[VB]
Public Function GetData(row As Integer, col As Integer) As Object
Public Function GetData(row As Integer, colName As String) As Object
GetDataDisplay Method · 179
[C#]
public Object GetData ( int row , int col )
public Object GetData ( int row , String colName )
[Delphi]
function GetData(row: Integer; col: Integer): Object;
function GetData(row: Integer; colName: string): Object;
Parameter
Description
row, col
The coordinates of the cell.
Return Value
The data contained in the given grid cell.
Remarks
The GetData method returns the raw data stored in a specific grid cell. It is equivalent to using the grid's
indexer. For example:
•
Visual Basic
Dim foo As Object
foo = fg.GetData(row, col) ' is equivalent to
foo = fg(row, col)
•
C#
object foo;
foo = fg.GetData(row, col); // is equivalent to
foo = fg[row, col];
•
Delphi
var
foo: System.Object;
begin
foo := fg.GetData(row, col);
foo := fg[row, col];
end;
The data displayed by the grid might be different from the raw data, depending on the setting of the
Format and DataMap properties on the Column object. To obtain the display value (which is always a
string), use the GetDataDisplay method instead.
See Also
C1FlexGrid Class (page 101)
GetDataDisplay Method
Returns the data in a grid cell, formatted as a string.
180 · C1FlexGrid Reference
Syntax
[VB]
Public Function GetDataDisplay(row As Integer, col As Integer) As String
Public Function GetDataDisplay(row As Integer, colName As String) As String
[C#]
public String GetDataDisplay ( int row , int col )
public String GetDataDisplay ( int row , String colName )
[Delphi]
function GetDataDisplay(row: Integer, col: Integer): string;
function GetDataDisplay(row: Integer, colName: string): string;
Parameter
Description
row, col
The coordinates of the cell.
extraSpace
The amount of extra space, in pixels, to add to the column width.
Return Value
A string containing the data displayed in the given grid cell.
Remarks
To retrieve the raw data (before any mapping and formatting), use the GetData method or the grid's
indexer.
See Also
C1FlexGrid Class (page 101)
GetMergedRange Method (C1FlexGrid)
Returns the merged range of cells that includes a given cell.
Syntax
[VB]
Public Function GetMergedRange(row As Integer, col As Integer) As CellRange
Public Function GetMergedRange(row As Integer, col As Integer, clip As Boolean) As CellRange
[C#]
public CellRange GetMergedRange(int row , int col)
public CellRange GetMergedRange(int row , int col , Boolean clip)
[Delphi]
function GetMergedRange(row: Integer; col: Integer): CellRange;
HitTest Method · 181
function GetMergedRange(row: Integer; col: Integer; clip: Boolean); CellRange;
Parameter
Description
row, col
The coordinates of the cell.
Clip
Whether the returned value should include all merged cells in the range (clip =
false) or only those that are visible (clip = true).
Return Value
A CellRange object containing all cells in the merged range that includes the cell at row, col.
Remarks
Cell merging is controlled by the AllowMerging property. The GetMergedRange allows you to
determine whether a cell is merged with its neighbor cells.
See Also
C1FlexGrid Class (page 101)
HitTest Method
Returns information about the control at a given point on the control surface.
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;
Parameter
Description
x, y
The coordinates of a point on the control surface, in pixels.
row1, col1, row2, col2
The coordinates of the range to invalidate.
range
CellRange object specifying the range to invalidate.
Return Value
A HitTestInfo structure containing data about the point (coordinates, row, column, etc).
Remarks
This method is especially useful when handling the BeforeMouseDown event. It allows you to determine
whether the mouse is over a specific cell, grid buttons, resizing elements, etc.
182 · C1FlexGrid Reference
For example, the code below shows hit test information whenever the user clicks the mouse:
•
Visual Basic
Private Sub _flex_BeforeMouseDown(sender As Object, e As
BeforeMouseDownEventArgs)
Dim hti As HitTestInfo = _flex.HitTest(e.X, e.Y)
Console.WriteLine("at {0},{1}: row {2} col {3} type {4}", _
hti.X, hti.Y, hti.Row, hti.Column, hti.Type)
End Sub '_flex_BeforeMouseDown
•
C#
private void _flex_BeforeMouseDown(object sender,
BeforeMouseDownEventArgs e)
{
HitTestInfo hti = _flex.HitTest(e.X, e.Y);
Console.WriteLine("at {0},{1}: row {2} col {3} type {4}",
hti.X, hti.Y, hti.Row, hti.Column, hti.Type);
}
•
Delphi
var
hti: HitTestInfo;
items: array of object;
begin
hti := _flex.HitTest(e.X, e.Y);
SetLength(items, 5);
items[0] := System.Object(hti.X);
items[1] := System.Object(hti.Y);
items[2] := System.Object(hti.Row);
items[3] := System.Object(hti.Column);
items[4] := System.Object(hti.Type);
Console.WriteLine('at {0},{1}: row {2} col {3} type {4}',
items);
end;
To use this method in an event that does not provide the mouse coordinates, use the
Control.MousePosition property and convert the point from window to control coordinates. For
example:
•
Visual Basic
Private Sub _flex_DoubleClick(sender As Object, e As System.EventArgs)
Dim pt As Point = Control.MousePosition
pt = _flex.PointToClient(pt)
Dim hti As HitTestInfo = _flex.HitTest(pt.X, pt.Y)
Console.WriteLine("at {0},{1}: row {2} col {3} type {4}", _
hti.X, hti.Y, hti.Row, hti.Column, hti.Type)
End Sub '_flex_DoubleClick
•
C#
private void _flex_DoubleClick(object sender, System.EventArgs e)
{
Point pt = Control.MousePosition;
pt = _flex.PointToClient(pt);
HitTestInfo hti = _flex.HitTest(pt.X, pt.Y);
Console.WriteLine("at {0},{1}: row {2} col {3} type {4}",
hti.X, hti.Y, hti.Row, hti.Column, hti.Type);
}
Invalidate Method · 183
•
Delphi
var
hti: HitTestInfo;
pt: Point;
items: array of object;
begin
pt := Control.MousePosition;
pt := _flex.PointToClient(pt);
hti := _flex.HitTest(pt.X, pt.Y);
SetLength(items, 5);
items[0] := System.Object(hti.X);
items[1] := System.Object(hti.Y);
items[2] := System.Object(hti.Row);
items[3] := System.Object(hti.Column);
items[4] := System.Object(hti.Type);
Console.WriteLine('at {0},{1}: row {2} col {3} type {4}',
items);
end;
See Also
C1FlexGrid Class (page 101)
Invalidate Method
Invalidates a specific region of the grid and causes a paint message to be sent to the control.
Syntax
[VB]
Public Sub Invalidate(row As Integer, col As Integer)
Public Sub Invalidate(rg As CellRange)
Public Sub Invalidate(row1 As Integer, col1 As Integer, row2 As Integer, col2 As Integer)
[C#]
public void Invalidate(int row , int col)
public void Invalidate(int row1 , int col1 , int row2 , int col2)
public virtual void Invalidate(CellRange rg)
[Delphi]
procedure Invalidate(row: integer; col: Integer);
procedure Invalidate(rg: CellRange);
procedure Invalidate(row1: Integer; col1: Integer; row2: Integer; col2: Integer);
Parameter
Description
row, col
The coordinates of the cell to invalidate.
row1, col1, row2, col2
The coordinates of the range to invalidate.
range
CellRange object specifying the range to invalidate.
184 · C1FlexGrid Reference
Remarks
This method is rarely used by the programmer, since the grid automatically performs invalidation as
needed.
See Also
C1FlexGrid Class (page 101 )
Column Class (page 320)
Row Class (page 306)
LoadExcel Method
Loads a grid from a Microsoft Excel file (xls).
Syntax
[VB]
Public Sub LoadExcel(fileName As String)
Public Sub LoadExcel(fileName As String, sheetName As String)
Public Sub LoadExcel(fileName As String, sheetName As String, flags As FileFlags)
[C#]
public void LoadExcel(string fileName)
public void LoadExcel(string fileName, string sheetName)
public void LoadExcel(string fileName, string sheetName, FileFlags flags)
[Delphi]
procedure LoadExcel(fileName: string);
procedure LoadExcel(fileName: string; sheetName: string);
procedure LoadExcel(fileName: string; sheetName: string; flags: FileFlags);
Parameter
Description
fileName
The name of the file to load, including the path.
sheetName
The name of the worksheet to load from the Excel file. If not provided, the first
sheet is loaded. To retrieve a list of the worksheets in an existing Excel file,
use the LoadExcelSheetNames method.
flags
One of the values in the FileFlags enumeration, that specifies options for
loading the file (whether to load fixed cells for example).
Remarks
The LoadGrid method can also be used to load Excel files, but it does not allow you to specify the name
of the worksheet and therefore always loads the first sheet in the file.
To retrieve a list of the worksheets in an existing Excel file, use the LoadExcelSheetNames method.
LoadExcelSheetNames Method · 185
See Also
C1FlexGrid Class (page 101)
LoadExcelSheetNames Method
Retrieves the names of all worksheets stored in a Microsoft Excel file (xls).
Syntax
[VB]
Public Function LoadExcelSheetNames(fileName As String) As String()
[C#]
public string() LoadExcelSheetNames(string fileName)
[Delphi]
function LoadExcelSheetNames(fileName: string): string[];
Parameter
Description
fileName
The name of the Excel file to load, including the path.
Remarks
This method is useful when you need to load a specific worksheet from an Excel file. To do this, use
LoadExcelSheetNames to retrieve a list of the sheets available in the file, select the one you want to load,
then use the LoadExcel method to retrieve the selected sheet.
See Also
C1FlexGrid Class (page 101)
LoadGrid Method
Loads a grid from a text file.
Syntax
[VB]
Public Sub LoadGrid(fileName As String, format As FileFormatEnum)
Public Sub LoadGrid(fileName As String, format As FileFormatEnum, flags As FileFlags)
Public Sub LoadGrid(fileName As String, format As FileFormatEnum, flags As FileFlags, encoding As
Encoding)
[C#]
public void LoadGrid(string fileName , FileFormatEnum format)
public void LoadGrid(string fileName , FileFormatEnum format , FileFlags flags)
public void LoadGrid(string fileName , FileFormatEnum format , FileFlags flags, Encoding encoding)
186 · C1FlexGrid Reference
[Delphi]
procedure LoadGrid(fileName: string; format: FileFormatEnum);
procedure LoadGrid(fileName: string; format: FileFormatEnum; flags: FileFlags);
procedure LoadGrid(fileName: string; format: FileFormatEnum; flags: FileFlags; encoding: Encoding);
Parameter
Description
fileName
The name of the file to load, including the path.
format
One of the values in the FileFormatEnum enumeration, that specifies the
format of the file (e.g., comma-delimited, tab-delimited, Excel, etc.).
flags
One of the values in the FileFlags enumeration, that specifies options for
loading the file (whether to load fixed cells for example).
encoding
A System.Text.Encoding object that determines how to decode the text in the
file (e.g. ASCII, Unicode, UTF-7, UTF-8). This parameter does not apply when
loading Excel files.
Remarks
This method loads grid from a file previously saved with the SaveGrid method, comma-delimited text
file (CSV format) such as an Excel text file, or a tab-delimited text file. It can also be used to load
Microsoft Excel files (xls).
When loading text files, rows and columns are added to the grid if needed to accommodate the file
contents.
When loading Excel files, the grid retrieves the first worksheet from the specified xls file. The LoadExcel
method allows you to specify which worksheet should be loaded. The LoadExcelSheetNames method
allows you to retrieve a list of the worksheets stored in an xls file.
See Also
C1FlexGrid Class (page 101)
PrintGrid Method
Prints the grid, optionally showing a print preview dialog.
Syntax
[VB]
Public Function PrintGrid(docName As String) As Boolean
Public Function PrintGrid(docName As String, flags As PrintGridFlags) As Boolean
Public Function PrintGrid(docName As String, flags As PrintGridFlags, header As String, footer As
String) As Boolean
[C#]
public Boolean PrintGrid(string docName)
public Boolean PrintGrid(string docName , PrintGridFlags flags)
PrintGrid Method · 187
public Boolean PrintGrid(string docName , PrintGridFlags flags , string header , string footer)
[Delphi]
function PrintGrid(docName: string): Boolean;
function PrintGrid(docName: string; flags: PrintGridFlags): Boolean;
function PrintGrid(docName: string; flags: PrintGridFlags; header: string; footer: string): Boolean;
Parameter
Description
docName
The document name, which appears on the progress dialogs and on the print job
windows.
flags
A combination of values from the PrintGridFlags enumeration, which specify what
types of print and preview dialogs to display and how to scale the grid for printing.
header, footer
Strings to be printed at the top and bottom of each page.
Return Value
A boolean value that indicates whether the grid was printed or the user canceled any of the optional
setup dialogs.
Remarks
The header and footer strings may contain up to three tab-delimited sections, to be aligned at the left,
center, and right of the page. The strings may also contain placeholders that are replaced with the current
page number and total number of pages (“{0}” and “{1}”).
You can also control other aspects of the print job (such as page orientation and margins, header and
footer fonts, etc.) using the PrintParameters property.
Example
The following call prints the grid on the default printer, scaling it to fit the page width, with a “Page n of
m” footer centered on the bottom of each page.
•
Visual Basic
flex.PrintGrid("My Grid", PrintGridFlags.FitPageWidth, _
"", vbTab + "Page {0} of {1}")
•
C#
flex.PrintGrid("My Grid", PrintGridFlags.FitPageWidth,
"", "\tPage {0} of {1}");
•
Delphi
flex.PrintGrid('My Grid', PrintGridFlags.FitPageWidth, '', #9'Page
{0} of {1}');
See Also
C1FlexGrid Class (page 101 )
C1FlexGridClassic Class (page 429)
188 · C1FlexGrid Reference
RemoveItem Method (C1FlexGrid)
Removes a row from the control.
Syntax
[VB]
Public Sub RemoveItem()
Public Sub RemoveItem(index As Integer)
[C#]
public void RemoveItem ( )
public void RemoveItem ( int index )
[Delphi]
procedure RemoveItem;
procedure RemoveItem(index: Integer);
Parameter
Description
index
The index of the row to remove. It this parameter is omitted, the last row is
removed.
Remarks
You can also add and remove rows using the Rows collection. The RemoveItem method is provided
mainly for consistency.
See Also
C1FlexGrid Class (page 101)
SaveExcel Method
Saves a grid to a specific sheet in a Microsoft Excel file (xls).
Syntax
[VB]
Public Sub SaveExcel(fileName As String)
Public Sub SaveExcel(fileName As String, sheetName As String)
Public Sub SaveExcel(fileName As String, sheetName As String, flags As FileFlags)
[C#]
public void SaveExcel(string fileName)
public void SaveExcel(string fileName, string sheetName)
public void SaveExcel(string fileName, string sheetName, FileFlags flags)
SaveExcel Method · 189
[Delphi]
procedure SaveExcel(fileName: string);
procedure SaveExcel(fileName: string; sheetName: string);
procedure SaveExcel(fileName: string; sheetName: string; flags: FileFlags);
Parameter
Description
fileName
The name of the file to load, including the path.
sheetName
The name of the worksheet to save to the Excel file. If not provided, a file with
a single sheet is created. If provided, a sheet with the specified name is
created and added to the file.
flags
One of the values in the FileFlags enumeration, that specifies options for
loading the file (whether to load fixed cells for example).
Remarks
The SaveGrid method can also be used to save Excel files, but it does not allow you to specify the name
of the worksheet and therefore always creates files with a single worksheet.
The SaveExcel method, on the other hand, allows you to save multiple grids as separate worksheets into
a single file. For example, the code below saves all tables in a data set into a single xls file:
•
Visual Basic
Dim ds As DataSet = GetDataSet()
Dim dt As DataTable
For Each dt In ds.Tables
_flex.DataSource = dt
_flex.SaveExcel(xlsFileName, dt.TableName)
Next
•
C#
DataSet ds = GetDataSet();
foreach (DataTable dt in ds.Tables)
{
_flex.DataSource = dt;
_flex.SaveExcel(xlsFileName, dt.TableName);
}
•
Delphi
var ds: DataSet;
dt: DataTable;
i: Integer;
ds := GetDataSet;
for i := 0 to ds.Tables.Count-1 do
begin
dt := ds.Tables[i];
_flex.DataSource := dt;
_flex.SaveExcel(xlsFileName, dt.TableName);
end;
See Also
C1FlexGrid Class (page 101)
190 · C1FlexGrid Reference
SaveGrid Method
Saves a grid to a text file.
Syntax
[VB]
Public Sub SaveGrid(fileName As String, format As FileFormatEnum)
Public Sub SaveGrid(fileName As String, format As FileFormatEnum, flags As FileFlags)
Public Sub SaveGrid(fileName As String, format As FileFormatEnum, flags As FileFlags, encoding As
Encoding)
[C#]
public void SaveGrid (String fileName , FileFormatEnum format )
public void SaveGrid (String fileName , FileFormatEnum format , FileFlags flags)
public void SaveGrid (String fileName , FileFormatEnum format ,FileFlags flags, Encoding encoding)
[Delphi]
procedure SaveGrid(fileName: string; format: FileFormatEnum);
procedure SaveGrid(fileName: string; format: FileFormatEnum; flags: FileFlags);
procedure SaveGrid(fileName: string; format: FileFormatEnum; flags: FileFlags; encoding: Encoding);
Parameter
Description
fileName
The name of the file to save, including the path.
format
One of the values in the FileFormatEnum enumeration, that specifies the
format of the file (e.g., comma-delimited, tab-delimited, Excel, etc.).
flags
One of the values in the FileFlags enumeration, that specifies options for
saving the file (whether to load save fixed cells for example).
encoding
A System.Text.Encoding object that determines how to encode the text in the
file (e.g. ASCII, Unicode, UTF-7, UTF-8). The default value is
Encoding.ASCII. This parameter does not apply when saving Excel files.
Remarks
When the grid saves text files, any cells that contain quotes, row delimiters, or column delimiters are
enclosed in quotes. Quotes in cell text are replaced with a pair of quotes. This is the standard encoding
used when saving and loading CSV files.
When saving Excel files, the grid creates a new xls file with a single worksheet containing the grid data.
The SaveExcel method allows you to save multiple worksheets in a single xls file.
See Also
C1FlexGrid Class (page 101)
Select Method · 191
Select Method
Selects a cell or range of cells.
Syntax
[VB]
Public Select(row As Integer, col As Integer)
Public Select(row As Integer, col As Integer, rowSel As Integer, colSel As Integer)
Public Select(rg As CellRange)
Public Select(row As Integer, col As Integer, show As Boolean)
Public Select(row As Integer, col As Integer, rowSel As Integer, colSel As Integer, show As Boolean)
Public Select(rg As CellRange, show As Boolean)
[C#]
public void Select ( int row , int col )
public void Select ( int row , int col , int rowSel , int colSel )
public void Select ( int row , int col , Boolean show )
public void Select (CellRange rg )
public void Select ( int row , int col , int rowSel , int colSel , Boolean show )
public void Select (CellRange rg , Boolean show )
[Delphi]
procedure Select(row: Integer; col: Integer);
procedure Select(row: Integer; col: Integer; rowSel: Integer; colSel: Integer);
procedure Select(row: Integer; col: Integer; show: Boolean);
procedure Select(rg: CellRange);
procedure Select(row: Integer; col: Integer; rowSel: Integer; colSel: Integer; show: Boolean);
procedure Select(rg: CellRange; show: Boolean);
Parameter
Description
row, col
The coordinates of the cell to select.
row1, col1, row2, col2
The coordinates of the range to select.
range
The range to invalidate.
show
Whether the selection should be scrolled into view. The default value for this
parameter is true.
Remarks
Using the Select method is equivalent to setting the Row, Col, RowSel, and ColSel properties.
192 · C1FlexGrid Reference
If you set the SelectionMode property to ListBox, then the grid behaves as a multi-selection listbox. In
this mode, you can use the Selected property of the Row object to get or set the selected state of a
particular row.
See Also
C1FlexGrid Class (page 101)
SetCellImage Method
Assigns an image to a cell.
Syntax
[VB]
Public Sub SetCellImage(row As Integer, col As Integer, newImage As Image)
[C#]
public void SetCellImage ( int row , int col , Image newImage )
[Delphi]
procedure SetCellImage(row: Integer; col: Integer; newImage: Image);
Remarks
Parameter
Description
row
Row that will contain the image.
col
Column that will contain the image.
newImage
The image to be added to the cell.
Remarks
In addition to the usual cell contents, you can display images in cells. There are two methods for showing
images in cells:
1.
You can use the SetCellImage and GetCellImage methods to assign images directly to the cells.
In this case, the cell contents and the image are independent. To update the image, you need to
call SetCellImage again.
2.
You can use the ImageMap property of the Column object to associate images to specific cell
values. In this case, the images are updated automatically whenever the cell contents change. The
column object also has an ImageAndText property that allows you to specify whether the control
should display the images in addition to or instead of the cell text.
See Also
C1FlexGrid Class (page 101)
SetCellStyle Method
Assigns a custom CellStyle to a cell.
SetCellCheck Method · 193
Syntax
[VB]
Public Sub SetCellStyle(row As Integer, col As Integer, newStyle As CellStyle)
[C#]
public void SetCellStyle ( int row , int col , CellStyle newStyle )
[Delphi]
procedure SetCellStyle(row: Integer; col: Integer; newStyle: CellStyle);
Parameter
Description
row, col
The coordinates of the cell that will be assigned the new style.
newStyle
The new style for the cell, or null to reset the cell style.
Remarks
The SetCellStyle method is useful is you want to assign a new style to a single cell. You can also reset the
cell style by setting it to null (Nothing, in VB).
To apply a custom cell style to an entire row or column, set the Style property of the Row or Column
objects.
To apply a custom style to a range cells, use the CellRange object. For example:
•
Visual Basic
Dim rg As CellRange = fg.GetCellRange(3, 3, 10, 10)
rg.Data = Nothing
rg.Style = fg.Styles("MyRangeStyle")
•
C#
CellRange rg = fg.GetCellRange(3, 3, 10, 10);
rg.Data = null;
rg.Style = fg.Styles["MyRangeStyle"];
•
Delphi
var
rg: CellRange;
begin
rg := fg.GetCellRange(3, 3, 10, 10);
rg.Data := nil;
rg.Style := fg.Styles['MyRangeStyle'];
end;
See Also
C1FlexGrid Class (page 101)
SetCellCheck Method
Sets the type and state of the checkbox that is displayed in a cell.
194 · C1FlexGrid Reference
Syntax
[VB]
Public Sub SetCellCheck(row As Integer, col As Integer, check As CheckEnum)
[C#]
public void SetCellCheck ( int row , int col , CheckEnum check )
[Delphi]
procedure SetCellCheck(row: Integer; col: Integer; check: CheckEnum);
Parameter
Description
row, col
The coordinates of the cell that will be assigned the new checkbox value.
checkValue
One of the values in the CheckEnum enumeration that defines whether a
checkbox should be displayed in the cell and the state of the checkbox.
Remarks
By default, the grid displays values in boolean columns as checkboxes (the type of the column is
determined by the DataType property of the Column object). If you don't want boolean values displayed
as checkboxes, set the column's Format property to a string containing the values that should be
displayed for True and False values. For example:
•
Visual Basic
fg.Cols("bools").Format = "Yes;No"
•
C#
fg.Cols["bools"].Format = "Yes;No";
•
Delphi
fg.Cols['bools'].Format := 'Yes;No';
In unbound mode, you can use the GetCellCheck and SetCellCheck properties to add checkboxes to any
cells. The checkboxes will be displayed along with any text in the cell, and you can set their position
using the column's ImageAlign property.
There are two types of check boxes: boolean and tri-state. Boolean check boxes toggle between the
Checked and Unchecked states. Tri-state check boxes cycle through the settings TSChecked and
TSUnchecked and TSGrayed.
For example, the code below creates a boolean checkbox in cell (3,3) and a tri-state checkbox in cell (4,3):
•
Visual Basic
fg.SetCellCheck(3, 3, CheckEnum.Unchecked)
' boolean
fg.SetCellCheck(4, 3, CheckEnum.TSUnchecked) ' tri-state
•
C#
fg.SetCellCheck(3, 3, CheckEnum.Unchecked);
// boolean
fg.SetCellCheck(4, 3, CheckEnum.TSUnchecked); // tri-state
SetData Method · 195
•
Delphi
fg.SetCellCheck(3, 3, CheckEnum.Unchecked);
// boolean
fg.SetCellCheck(4, 3, CheckEnum.TSUnchecked); // tri-state
See Also
C1FlexGrid Class (page 101)
SetData Method
Assigns data to a grid cell.
Syntax
[VB]
Public Function SetData(row As Integer, colName As String, data As Object) As Boolean
Public Function SetData(row As Integer, colName As String, data As Object, coerce As Boolean) As
Boolean
Public Function SetData(rg As CellRange, data As Object) As Boolean
Public Function SetData(rg As CellRange, data As Object, coerce As Boolean) As Boolean
Public Function SetData(row As Integer, col As Integer, data As Object) As Boolean
Public Function SetData(row As Integer, col As Integer, data As Object, coerce As Boolean) As Boolean
[C#]
public Boolean SetData ( int row , String colName , Object data )
public Boolean SetData ( int row , String colName , Object data , Boolean coerce )
public Boolean SetData (CellRange rg , Object data )
public Boolean SetData ( int row , int col , Object data )
public Boolean SetData (CellRange rg , Object data , Boolean coerce )
public Boolean SetData (int row , int col , Object data , Boolean coerce )
[Delphi]
function SetData(row: Integer; colName: string; data: Object): Boolean;
function SetData(row: Integer; colName: string; data: Object; coerce: Boolean): Boolean;
function SetData(rg: CellRange; data: Object): Boolean;
function SetData(row: Integer; col: Integer; data: Object): Boolean;
function SetData(rg: CellRange; data: Object; coerce, Boolean): Boolean;
function SetData(row: Integer; col: Integer; data: Object; coerce: Boolean): Boolean;
Parameter
Description
row, col
The coordinates of the cell that will be assigned the new data.
196 · C1FlexGrid Reference
Parameter
Description
data
The data to assign to the cell.
coerce
Whether the object should be converted to the column's data type. If coerce is set
to true and the value cannot be converted into the proper data type, the grid will fire
the GridError event and the cell will retain its original data. The default value for
this parameter is true.
Return Value
A boolean value that indicates whether the data was assigned to the grid (see remarks below).
Remarks
The SetData method assigns data to a grid cell, and is equivalent to using the grid's indexer. For example:
•
Visual Basic
fg.SetData(row, col, 12) ' is equivalent to
fg(row, col) = 12
•
C#
fg.SetData(row, col, 12); // is equivalent to
fg[row, col] = 12;
•
Delphi
fg.SetData(row, col, 12);
fg[row, col] := 12;
When you assign a data value to a cell, the grid checks the column data type and automatically coerces
the value into the appropriate type. For example, if a column's DataType property is set to integer and
you assign it a string or double value, the grid will try to convert the value into an integer before storing
it in the grid. If the conversion fails, SetData returns false.
If you set the optional parameter coerce to False, the grid stores the data in the grid without any
conversions. This allows you to store arbitrary values in cells, regardless of column data type.
You can also attach your own arbitrary data to grid cells using the CellRange object and its UserData
property.
See Also
C1FlexGrid Class (page 101)
SetDataBinding Method
Sets the DataSource and DataMember properties.
Syntax
[VB]
Public Sub SetDataBinding(ByVal dataSource As Object, ByVal dataMember As String)
[C#]
public void SetDataBinding (object dataSource, string dataMember)
ShowCell Method · 197
[Delphi]
procedure SetDataBinding(dataSource: Object; dataMember: String);
Parameter
Description
dataSource
The data source for the grid.
dataMember
The specific list in a DataSource object that the grid should display.
See Also
C1FlexGrid Class (page 101)
ShowCell Method
Brings a cell into view, scrolling the grid is necessary.
Syntax
[VB]
Public Sub ShowCell(row As Integer, col As Integer)
[C#]
public void ShowCell ( int row , int col )
[Delphi]
procedure ShowCell(row: integer; col: Integer);
Parameter
Description
row, col
The coordinates of the cell that will be scrolled into view.
Remarks
This method does not affect the current selection. To move the cursor to a specific cell and optionally
bring it into view, use the Select method.
See Also
C1FlexGrid Class (page 101)
ShowSortAt Method
Shows a sorting glyph at a specific column.
Syntax
[VB]
Public Sub ShowSortAt(order As SortFlags, col As Integer)
198 · C1FlexGrid Reference
[C#]
public void ShowSortAt (SortFlags order , int col )
[Delphi]
procedure ShowSortAt(order: SortFlags; col: Integer);
Parameter
Description
glyph
The type of sorting glyph to display (e.g., SortFlags.Ascending,
SortFlags.Descending).
col
The column where the glyph should be displayed.
Remarks
This method is useful if you want to perform custom sorting and need control over the appearance and
position of the sorting glyph (the little triangle that appears on the header of sorted columns).
See Also
C1FlexGrid Class (page 101)
Sort Method
Sorts the entire grid or a range of rows based on the contents of one or more columns.
Syntax
[VB]
Public Overridable Sort(order As SortFlags, col As Integer)
Public Overridable Sort(order As SortFlags, col1 As Integer, col2 As Integer)
Public Overridable Sort(order As SortFlags, rg As CellRange)
Public Overridable Sort(index As Integer, count As Integer, comparer As IComparer)
Public Overridable Sort(comparer As IComparer)
[C#]
public void Sort (SortFlags order , int col )
public void Sort (SortFlags order , int col1 , int col2 )
public void Sort (SortFlags order , CellRange rg )
public void Sort ( int index , int count , IComparer comparer )
public void Sort (IComparer comparer )
[Delphi]
procedure Sort(order: SortFlags; col: Integer);
procedure Sort(order: SortFlags; col1: Integer; col2: Integer);
procedure Sort(order: SortFlags; rg: CellRange);
Sort Method · 199
procedure Sort(index: Integer; count: Integer; comparer: Icomparer);
procedure Sort(comparer: Icomparer);
Parameter
Description
SortFlags flags
One or more values from the SortFlags enumeration that specify the type of
sorting (e.g. ascending, descending, case-sensitive, etc).
int col
The column that contains the data to be sorted.
int col1, col2
A range of columns to sort.
CellRange range
A range of cells to sort. If a range is specified, the grid will sort only rows that
are contained in the range.
IComparer compare
An object that implements the IComparer interface to compare Row objects.
This can be used to provide custom sorting.
Remarks
The Sort method allows you to sort specific columns or cell ranges in ascending or descending order. The
flags parameter specifies the sorting order and a few additional options, described below:
Flag
Effect
Ascending
Sort rows in ascending order.
Descending
Sort rows in descending order.
AsDisplayed
Sort comparing the displayed value. If this flag is set, the sorting is based on the
formatted string that is displayed to the user. If it is not set, the sorting is based on
the underlying data value.
IgnoreCase
Use case-insensitive string comparison.
UseColSort
Use the value stored in the Sort property of each column in the range. This allows
you to sort some columns in ascending order and other in descending order.
When you sort multiple columns, the same sorting options are applied to each column, starting from the
leftmost column in the range and proceeding to the right.
The grid uses a stable sorting algorithm. This means that the sorting keeps the relative order of records
when the sorting key is the same. For example, if you sort a list of files by name, then by extension, file
names will still be sorted within each extension group.
To sort multiple columns using a different sorting order for each, you can either call the Sort method
multiple times or set each column's Sort property and call the Sort method and include the UseColSort
flag in the flags parameter.
To implement custom sorts, you should provide an object that implements the IComparer interface. This
simple interface has a single method called Compare that takes two objects as arguments (in this case,
they will be Row objects) and returns -1, 0, or +1. For more details, see the documentation for the
System.Collections.IComparer interface.
200 · C1FlexGrid Reference
See Also
C1FlexGrid Class (page 101)
StartEditing Method
Puts the grid in edit mode and starts editing a cell.
Syntax
[VB]
Public Function StartEditing() As Boolean
Public Function StartEditing(row As Integer, col As Integer) As Boolean
Public Function StartEditing(row As Integer, col As Integer, key As Char) As Boolean
[C#]
public Boolean StartEditing ( )
public Boolean StartEditing ( int row , int col )
public Boolean StartEditing ( int row , int col , Char key )
[Delphi]
function StartEditing: Boolean;
function StartEditing(row: Integer; col: Integer): Boolean;
function StartEditing(row: Integer; col: Integer; key: Char): Boolean;
Parameter
Description
row, col
The cell to edit. The default value is the current selection (defined by properties
Row and Col).
charTyped
The initial character to be sent to the editor. If this parameter is omitted, the editor
starts with the current cell contents. If a value is supplied, the grid ends it to the
editor, causing it to replace the selection (in textbox editors) or to select an item
matching the character (in list editors).
Remarks
If the AllowEditing property is set to a non-zero value, the control goes into editing mode automatically
when the user presses the edit key (F2), the space bar, or any printable character. You may use the
StartEditing method to force the control into cell-editing mode.
The StartEditing method will force the control into editing mode even if the AllowEditing property is set
to False. You may also use it to allow editing of fixed cells.
Example
The code below uses the StartEditing method to keep the grid in edit mode while the user moves the
selection with the keyboard (like the .NET DataGrid control):
StartEditing Method · 201
•
Visual Basic
Private Sub _flex_KeyDown(sender As Object, e As KeyEventArgs)
If e.KeyCode = Keys.Return Then
e.Handled = True ' ignore the event, we'll handle it ourselves
_flex.StartEditing() ' put the grid in edit mode
Dim tb As TextBox = _flex.Editor '
' if we got a textbox, then
If Not (tb Is Nothing) Then
tb.Select(tb.Text.Length, 0) ' move cursor to end
End If
End If
End Sub '_flex_KeyDown
Private Sub _flex_KeyPress(sender As Object, e As KeyPressEventArgs)
If e.KeyChar = CChar(13) Then ' ignore enter key
e.Handled = True ' (don't move the cursor)
End If
End Sub '_flex_KeyPress
•
C#
private void _flex_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
e.Handled = true; // ignore the event, we'll handle it ourselves
_flex.StartEditing(); // put the grid in edit mode
TextBox tb = _flex.Editor as TextBox; // if we got a textbox, then
if (tb != null) tb.Select(tb.Text.Length, 0); // move cursor to end
}
}
private void _flex_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13) // ignore enter key
e.Handled = true; // (don't move the cursor)
}
•
Delphi
procedure Class1._flex_KeyDown(sender: System.Object; e: KeyEventArgs);
var
tb: TextBox;
begin
if (e.KeyCode = Keys.Return) then
begin
e.Handled := True;
_flex.StartEditing;
if (flex.Editor is TextBox) then
TextBox(tb).Select(tb.Text.Length, 0);
end;
end;
procedure Class1._flex_KeyPress(sender: System.Object; e:
KeyPressEventArgs);
begin
if (e.KeyChar = (WideChar(13))) then
e.Handled := True;
end;
See Also
C1FlexGrid Class (page 101)
202 · C1FlexGrid Reference
Subtotal Method
Groups and totals rows based on their contents.
Syntax
[VB]
Public Sub Subtotal(aggType As AggregateEnum)
Public Sub Subtotal(aggType As AggregateEnum, level As Integer, groupOn As Integer, totalOn As
Integer)
Public Sub Subtotal(aggType As AggregateEnum, level As Integer, groupFrom As Integer, groupTo As
Integer, totalOn As Integer, caption As String)
Public Sub Subtotal(aggType AggregateEnum, level As Integer, groupOn As Integer, totalOn As Integer,
caption As String)
[C#]
public void Subtotal (AggregateEnum aggType )
public void Subtotal (AggregateEnum aggType , int level , int groupOn , int totalOn )
public void Subtotal (AggregateEnum aggType , int level , int groupOn , int totalOn , String caption )
public void Subtotal (AggregateEnum aggType , int level , int groupFrom , int groupTo , int totalOn ,
String caption )
[Delphi]
procedure Subtotal(aggType: AggregateEnum);
procedure Subtotal(aggType: AggregateEnum; level: Integer; groupOn: Integer; totalOn: Integer);
procedure Subtotal(aggType: AggregateEnum; level: Integer; groupOn: Integer; totalOn: Integer;
caption: string);
procedure Subtotal(aggType: AggregateEnum; level: Integer; groupFrom: Integer; groupOn: Integer;
totalOn: Integer; caption: string);
Parameter
Description
function
One of the AggregateEnum values. This parameter specifies the type of
aggregate to calculate (options include sum, average, min, max, etc).
level
The outline level to assign to the new subtotal rows. This parameter allows the
creation of multi-level subtotals and affects the display of the outline tree. For
more details on outlining, see the Tree property. If this parameter is set to a
negative value, the subtotals will not be displayed as nodes in the outline tree.
groupOn
The index of the column to use when detecting group breaks. When inserting the
subtotals, the grid will scan all rows and will insert a new subtotal row whenever
the value on this column or on columns to the left changes. If this parameter is
set to a negative value, the control will calculate grand totals (aggregate over the
whole grid).
groupFrom,
groupTo
The range of columns to use when detecting group breaks. When inserting the
subtotals, the grid will scan all rows and will insert a new subtotal row whenever
any of the values in this range changes.
Subtotal Method · 203
Parameter
Description
totalOn
The column to use for calculating the aggregates. For most types of aggregate,
this column should contain numeric values. You can also obtain counts for
columns of any type and ranges for date columns.
caption
The text to insert on the subtotal rows. By default, the grid will copy the values
that are being grouped on (defined by the groupOn or groupFrom, groupTo
parameters). If you specify a caption, the caption string will be assigned to the
subtotal row at the column specified by the Tree’s Column property. The caption
string may contain a placeholder "{0}" that will be replaced with the value being
grouped on.
Remarks
The Subtotal method inserts rows containing aggregate values. These new rows are set to behave as tree
nodes so they can be collapsed and expanded to display a dynamic hierarchical outline.
You can control the appearance and behavior of the outline tree using the Tree property.
The node rows added by the Subtotal method have their Style property automatically set to one of the
Styles.Subtotal styles. You can use the Styles property to modify the appearance of all subtotal rows on
the grid.
To create an outline tree manually, set the Row’s IsNode property to true for the rows that you want to
display as outline nodes. Then use the Row.Node’s Level property to set the outline level for the new
node.
Example
The code below is a typical tree-updating routine, called in response to changes in the data or after the
user drags columns to display a different view of the data.
The routine starts by clearing the old totals, then it sorts the grid to organize the data into groups. Finally,
it creates three levels of subtotals for the "Sales" column and three levels for the "Credits" column.
•
Visual Basic
Private Sub flex_AfterDragColumn(sender As Object, e As
DragRowColEventArgs)
updateTreeReport(True)
End Sub 'flex_AfterDragColumn
Sub updateTreeReport(setCaption As Boolean)
' avoid flicker
flex.Redraw = False
' clear old totals
flex.Subtotal(AggregateEnum.Clear)
' sort grid to organize into groups
flex.Sort(SortFlags.Ascending, flex.Cols.Fixed, flex.Cols.Count - 1)
' update subtotals
flex.Tree.Column = 1
Dim caption As String
If setCaption Then caption = "Total {0}"
' total on Sales, group on first three columns
Dim totalOn As Integer = flex.Cols("Sales").SafeIndex
204 · C1FlexGrid Reference
flex.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption)
flex.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption)
flex.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption)
' total on Credits, group on first three columns
totalOn = flex.Cols("Credits").SafeIndex
flex.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption)
flex.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption)
flex.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption)
' ready to show the grid again
flex.Redraw = True
End Sub 'updateTreeReport
•
C#
private void flex_AfterDragColumn(object sender, DragRowColEventArgs e)
{
updateTreeReport(true);
}
void updateTreeReport(bool setCaption)
{
// avoid flicker
flex.Redraw = false;
// clear old totals
flex.Subtotal(AggregateEnum.Clear);
// sort grid to organize into groups
flex.Sort(SortFlags.Ascending, flex.Cols.Fixed, flex.Cols.Count-1);
// update subtotals
flex.Tree.Column = 1;
string caption = (setCaption)? "Total {0}": "";
// total on Sales, group on first three columns
int totalOn = flex.Cols["Sales"].SafeIndex;
flex.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption);
flex.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption);
flex.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption);
// total on Credits, group on first three columns
totalOn = flex.Cols["Credits"].SafeIndex;
flex.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption);
flex.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption);
flex.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption);
// ready to show the grid again
flex.Redraw = true;
}
•
Delphi
procedure flex_AfterDragColumn(sender: System.Object; e:
DragRowColEventArgs);
updateTreeReport(True);
end; // flex_AfterDragColumn
procedure updateTreeReport(setCaption: Boolean);
var
caption: string;
totalOn: Integer;
begin
// avoid flicker
flex.Redraw := False;
Subtotal Method · 205
// clear old totals
flex.Subtotal(AggregateEnum.Clear);
// sort grid to organize into groups
flex.Sort(SortFlags.Ascending, flex.Cols.Fixed, flex.Cols.Count - 1);
// update subtotals
flex.Tree.Column := 1;
If setCaption Then
caption := 'Total {0}';
// total on Sales, group on first three columns
totalOn := flex.Cols['Sales'].SafeIndex;
flex.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption);
flex.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption);
flex.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption);
// total on Credits, group on first three columns
totalOn := flex.Cols['Credits'].SafeIndex;
flex.Subtotal(AggregateEnum.Sum, 0, 1, totalOn, caption);
flex.Subtotal(AggregateEnum.Sum, 1, 2, totalOn, caption);
flex.Subtotal(AggregateEnum.Sum, 2, 3, totalOn, caption);
// ready to show the grid again
flex.Redraw := True;
end; // updateTreeReport
Note that you can display several aggregates in each subtotal row (one per column). The Subtotal
method will check for empty cells in existing subtotal rows and will use them if it can. The example
below shows totals for several columns on each subtotal row:
•
Visual Basic
flex.Subtotal(AggregateEnum.Clear)
flex.Subtotal(AggregateEnum.Count, 0, 1, 1, 1, "Count is {0}")
Dim c As Integer
For c = 2 To flex.Cols.Count - 1
flex.Subtotal(AggregateEnum.Sum, 0, 1, 1, c, "Sum is {0}")
Next c
•
C#
flex.Subtotal(AggregateEnum.Clear);
flex.Subtotal(AggregateEnum.Count, 0, 1, 1, 1, "Count is {0}");
for (int c = 2; c < flex.Cols.Count; c++)
flex.Subtotal(AggregateEnum.Sum, 0, 1, 1, c, "Sum is {0}");
•
Delphi
var
c: Integer;
begin
flex.Subtotal(AggregateEnum.Clear);
flex.Subtotal(AggregateEnum.Count, 0, 1, 1, 1, 'Count is {0}');
c := 2;
while (c < flex.Cols.Count) do
begin
flex.Subtotal(AggregateEnum.Sum, 0, 1, 1, c, 'Sum is {0}');
c := c + 1;
end;
end;
206 · C1FlexGrid Reference
See Also
C1FlexGrid Class (page 101)
C1FlexGrid Events
AfterAddRow Event
Fires when the AllowAddNew property is set to True, after the user adds a new row to the grid.
Syntax
[VB]
Public Event AfterAddRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler AfterAddRow
[Delphi]
property AfterAddRow: RowColEventHandler;
Remarks
This event does not fire when a new row is added to the grid programmatically or through the grid's data
source. It only fires when AllowAddNew is set to True and the user creates a new empty row by moving
the cursor into the last row on the grid.
You can use this event to initialize the new rows.
When a new row is created this way, it is initially empty, and the user may cancel the row by moving the
cursor out of the new row before making any edits. In this case, the grid fires the CancelAddRow event
and the new (empty) row is removed.
See Also
C1FlexGrid Class (page 101)
AfterCollapse Event
Fires after a node row is collapsed or expanded.
Syntax
[VB]
Public Event AfterCollapse(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler AfterCollapse
[Delphi]
property AfterCollapse: RowColEventHandler;
Remarks
See the BeforeCollapse event for details and an example.
AfterDataRefresh Event · 207
See Also
C1FlexGrid Class (page 101)
AfterDataRefresh Event
Fires in bound mode, after the grid changes as a result of changes in the data source.
Syntax
[VB]
Public Event AfterDataRefresh(sender As Object, e As ListChangedEventArgs) As
ListChangedEventHandler
[C#]
public ListChangedEventHandler AfterDataRefresh
[Delphi]
property AfterDataRefresh: ListChangedEventHandler;
Event Data
The event handler receives an argument of type ListChangedEventArgs containing data related to this
event.
Remarks
When the grid is used in bound mode, any changes to the data source cause the grid to fire the
AfterDataRefresh event. This event is the ideal place to put code that updates the grid with datadependent elements such as subtotals and outline trees.
For an example, see the Data Analysis Tutorial.
NOTE: The ListChangedEventHandler delegate is defined in System.ComponentModel.
See Also
C1FlexGrid Class (page 101)
AfterDeleteRow Event
Fires when the AllowDelete property is set to True, after the user deletes one or more rows from the grid
by pressing the Delete key.
Syntax
[VB]
Public Event AfterDeleteRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler AfterDeleteRow
[Delphi]
property AfterDeleteRow: RowColEventHandler;
208 · C1FlexGrid Reference
Remarks
This event does not fire when rows are removed from the grid programmatically or through the grid's
data source. It only fires when AllowDelete is set to True and the user deletes one or more rows by
pressing the Delete key.
When this event fires, the rows have already been removed from the grid, so the Row parameter is
always set to –1.
See Also
C1FlexGrid Class (page 101)
AfterDragColumn Event
Fires after the user drags a column using the mouse.
Syntax
[VB]
Public Event AfterDragColumn(sender As Object, e As DragRowColEventArgs) As
DragRowColEventHandler
[C#]
public event DragRowColEventHandler AfterDragColumn
[Delphi]
property AfterDragColumn: DragRowColEventHandler;
Event Data
The event handler receives an argument of type DragRowColEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int Col
The original index of the column that was dragged by the user.
int Position
The current index of the column that was dragged by the user.
Remarks
This event is only fired when a column is moved by the user, by dragging it with the mouse (see the
AllowDragging property). It is not fired when a column is moved using the Cols.Move method.
See Also
C1FlexGrid Class (page 101)
AfterDragRow Event
Fires after the user drags a row using the mouse.
AfterEdit Event · 209
Syntax
[VB]
Public Event AfterDragRow(sender As Object, e As DragRowColEventArgs) As
DragRowColEventHandler
[C#]
public event DragRowColEventHandler AfterDragRow
[Delphi]
property AfterDragRow: DragRowColEventHandler;
Event Data
The event handler receives an argument of type DragRowColEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int Row
The original index of the row that was dragged by the user.
int Position
The current index of the row that was dragged by the user.
Remarks
This event is only fired when a row is moved by the user, by dragging it with the mouse (see the
AllowDragging property). It is not fired when a row is moved using the Rows.Move method.
See Also
C1FlexGrid Class (page 101)
AfterEdit Event
Fires after the user finishes editing a cell.
Syntax
[VB]
Public Event AfterEdit(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler AfterEdit
[Delphi]
property AfterEdit: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
210 · C1FlexGrid Reference
Property
Description
int Row, Col
The coordinates of the cell that was edited.
Remarks
This event is fired after the contents of a cell have been changed by the user. It is useful for performing
actions such as re-sorting the data or calculating subtotals.
The AfterEdit event is not adequate for performing data validation, because it is fired after the changes
have been applied to the control. To validate user-entered data, use the ValidateEdit event instead.
See Also
C1FlexGrid Class (page 101)
AfterFreezeColumn Event
Fired after the user freezes columns with the mouse.
Syntax
[VB]
Public Event AfterFreezeColumn(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler AfterFreezeColumn
[Delphi]
property AfterFreezeColumn: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row, Col
The coordinates of the cell that was edited.
Remarks
See the AllowFreezing property.
See Also
C1FlexGrid Class (page 101)
AfterFreezeRow Event
Fired after the user freezes rows with the mouse.
AfterResizeColumn Event · 211
Syntax
[VB]
Public Event AfterFreezeRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler AfterFreezeRow
[Delphi]
property AfterFreezeRow: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row, Col
The coordinates of the cell that was edited.
Remarks
See the AllowFreezing property.
See Also
C1FlexGrid Class (page 101)
AfterResizeColumn Event
Fired after a column is resized by the user.
Syntax
[VB]
Public Event AfterResizeColumn(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler AfterResizeColumn
[Delphi]
property AfterResizeColumn: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Col
The index of the column that was resized by the user.
212 · C1FlexGrid Reference
Remarks
This event is only fired when a column is resized by the user, by dragging the edge of the header cell with
the mouse (see the AllowResizing property). It is not fired when a column is resized by assigning a new
value to the Col.Width property.
See Also
C1FlexGrid Class (page 101)
AfterResizeRow Event
Fired after a row is resized by the user.
Syntax
[VB]
Public Event AfterResizeRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler AfterResizeRow
[Delphi]
property AfterResizeRow: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The index of the row that was resized by the user.
Remarks
This event is only fired when a row is resized by the user, by dragging the edge of the header cell with
the mouse (see the AllowResizing property). It is not fired when a row is resized by assigning a new
value to the Row.Height property.
See Also
C1FlexGrid Class (page 101)
AfterRowColChange Event
Fired after the selection anchor moves to a new cell.
Syntax
[VB]
Public Event AfterRowColChange(sender As Object, e As RangeEventArgs) As RangeEventHandler
AfterScroll Event · 213
[C#]
public event RangeEventHandler AfterRowColChange
[Delphi]
property AfterRowColChange: RangeEventHandler;
Event Data
The event handler receives an argument of type RangeEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
CellRange OldRange
The selection before the event.
CellRange NewRange
The current selection.
Remarks
This event is fired after the Row or Col properties change, either as a result of user actions (mouse or
keyboard) or through code.
This event is useful if you want to display additional information about the currently selected row,
column, or cell. To perform validation or prevent certain cells from being selected, use the
BeforeRowColChange and BeforeSelChange events instead.
See Also
C1FlexGrid Class (page 101)
AfterScroll Event
Fired after the grid scrolls.
Syntax
[VB]
Public Event AfterScroll(sender As Object, e As RangeEventArgs) As RangeEventHandler
[C#]
public event RangeEventHandler AfterScroll
[Delphi]
property AfterScroll: RangeEventHandler;
Event Data
The event handler receives an argument of type RangeEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
CellRange OldRange
The visible range (TopRow, LeftCol, BottomRow, RightCol) before the
event.
214 · C1FlexGrid Reference
Property
Description
CellRange NewRange
The current visible range.
Remarks
This event is useful if you want to keep synchronized views of two or more grids.
Example
This code binds two grids (fgLeft and fgRight) together and synchronizes their scrolling in the vertical
direction (the user can scroll the independently in the horizontal direction).
•
Visual Basic
' bind grids together
fgRight.DataSource = fgLeft
fgLeft.ScrollBars = ScrollBars.Horizontal
' synchronize vertical scrolling
Private Sub flex_AfterScroll(sender As Object, _
e As C1.Win.C1FlexGrid.RangeEventArgs)
Dim fg As C1FlexGrid.C1FlexGrid = CType(sender, C1FlexGrid)
fg.Update()
Dim y As Integer = fg.ScrollPosition.Y
If fg = fgLeft Then
fgRight.ScrollPosition = New Point(fgRight.ScrollPosition.X, y)
Else
fgLeft.ScrollPosition = New Point(fgLeft.ScrollPosition.X, y)
End If
End Sub 'flex_AfterScroll
•
C#
// bind grids together
fgRight.DataSource = fgLeft;
fgLeft.ScrollBars = ScrollBars.Horizontal;
// synchronize vertical scrolling
private void flex_AfterScroll(object sender,
C1.Win.C1FlexGrid.RangeEventArgs e)
{
C1FlexGrid.C1FlexGrid fg = ((C1FlexGrid)sender);
fg.Update();
int y = fg.ScrollPosition.Y;
if (fg == fgLeft)
fgRight.ScrollPosition = new Point(fgRight.ScrollPosition.X, y);
else
fgLeft.ScrollPosition = new Point(fgLeft.ScrollPosition.X, y);
}
}
•
Delphi
fgRight.DataSource := fgLeft;
fgLeft.ScrollBars := ScrollBars.Horizontal;
procedure Class1.flex_AfterScroll(sender: System.Object; e:
C1.Win.C1FlexGrid.RangeEventArgs);
var
y: Integer;
fg: C1FlexGrid.C1FlexGrid;
AfterSelChange Event · 215
begin
fg := C1FlexGrid(sender);
fg.Update;
y := fg.ScrollPosition.Y;
if fg = fgLeft then
fgRight.ScrollPosition := Point.Create(fgRight.ScrollPosition.X, y)
else
fgLeft.ScrollPosition := Point.Create(fgLeft.ScrollPosition.X, y);
end;
See Also
C1FlexGrid Class (page 101)
AfterSelChange Event
Fires after the selection changes.
Syntax
[VB]
Public Event AfterSelChange(sender As Object, e As RangeEventArgs) As RangeEventHandler
[C#]
public event RangeEventHandler AfterSelChange
[Delphi]
property AfterSelChange: RangeEventHandler;
Event Data
The event handler receives an argument of type RangeEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
CellRange OldRange
The selection before the event.
CellRange NewRange
The current selection.
Remarks
This event is fired after the RowSel or ColSel properties change, either as a result of user actions (mouse
or keyboard) or through code.
This event is useful if you want to display additional information about the current selection. To perform
validation or prevent certain cells from being selected, use the BeforeRowColChange and
BeforeSelChange events instead.
See Also
C1FlexGrid Class (page 101)
AfterSort Event
Fired after a column is sorted when the user clicks on a column header.
216 · C1FlexGrid Reference
Syntax
[VB]
Public Event AfterSort(sender As Object, e As SortColEventArgs) As SortColEventHandler
[C#]
public event SortColEventHandler AfterSort
[Delphi]
property AfterSort: SortColEventHandler;
Event Data
The event handler receives an argument of type SortColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Col
The column that was sorted.
SortFlags Order
The new sorting order for the column.
Remarks
This event is only fired if the sorting was caused by a click on a column header cell (see the AllowSorting
property). It is not fired after sorting with the Sort method.
This event is useful if you want to update user interface elements to reflect the new sorting.
To prevent certain columns from being sorted, or to alter their default sorting order, use the
Col.AllowSorting or handle the BeforeSort event.
See Also
C1FlexGrid Class (page 101)
BeforeAddRow Event
Fires when the AllowAddNew property is set to True, before the user adds a new row to the grid.
Syntax
[VB]
Public Event BeforeAddRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeAddRow
[Delphi]
property BeforeAddRow: RowColEventHandler;
BeforeAutoSizeColumn Event · 217
Remarks
This event does not fire when a new row is added to the grid programmatically or through the grid's data
source. It only fires when AllowAddNew is set to True and the user creates a new empty row by moving
the cursor into the last row on the grid.
You can use this event to cancel the creation of new rows by setting the Cancel parameter to True. In this
case, the cursor does not move into the new row.
See Also
C1FlexGrid Class (page 101)
BeforeAutoSizeColumn Event
Fired before a column is automatically resized in response to a double click.
Syntax
[VB]
Public Event BeforeAutosizeColumn(sender As Object, e As RowColEventArgs) As
RowColEventHandler
[C#]
public event RowColEventHandler BeforeAutosizeColumn
[Delphi]
property BeforeAutosizeColumn: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row, Col
The cell that is about to be edited or painted.
bool Cancel
Set this parameter to true to prevent the cell from being edited.
Remarks
By default, the grid automatically resizes rows and columns based on the entries for the entire grid. If a
grid contains several thousand rows, you may want to save some time by trapping this event, resizing the
column using the AutoSizeCols method and setting the Cancel parameter to true.
See Also
C1FlexGrid Class (page 101)
BeforeAutoSizeRow Event
Fired before a row is resized in response to a double click.
218 · C1FlexGrid Reference
Syntax
[VB]
Public Event BeforeAutosizeRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeAutosizeRow
[Delphi]
property BeforeAutosizeRow: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row, Col
The cell that is about to be edited or painted.
bool Cancel
Set this parameter to true to prevent the cell from being edited.
Remarks
By default, the grid automatically resizes rows and columns based on the entries for the entire grid. If a
grid contains several thousand rows, you may want to save some time by trapping this event, resizing the
column using the AutoSizeCols method and setting the Cancel parameter to true.
See Also
C1FlexGrid Class (page 101)
BeforeCollapse Event
Fires before a node row is collapsed or expanded.
Syntax
[VB]
Public Event BeforeCollapse(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeCollapse
[Delphi]
property BeforeCollapse: RowColEventHandler;
Remarks
The BeforeCollapse and AfterCollapse events fire before and after node rows are expanded or collapsed.
You can determine whether the node is being collapsed or expanded by checking its Expanded property.
These events allow you to populate outlines on demand, so you only need to create the rows that will
actually be shown to the user. For example, if you are using the grid to display a directory tree, it would
BeforeCollapse Event · 219
take a long time to read each directory on the disk in order to populate the tree, and the user would
probably only look at a few nodes anyway.
The code below shows how you can handle the BeforeCollapse event to populate a tree on demand. The
code assumes that the grid contains a root node that is collapsed and has a dummy child. The dummy
child node will be replaced with the actual data when the user expands it.
•
Visual Basic
Private m_ExpandingNode As Boolean = False
Private Sub flex_BeforeCollapse(sender As Object, e As RowColEventArgs)
' if we're working, ignore this
If m_ExpandingNode Then
Return
End If
' don't allow collapsing/expanding groups of rows (with shift-click)
If e.Row < 0 Then
e.Cancel = True
Return
End If
' if we're already collapsed, populate node
' before expanding
If flex.Rows(e.Row).Node.Collapsed Then
m_ExpandingNode = True
ExpandRow(e.Row)
m_ExpandingNode = False
End If
End Sub 'flex_BeforeCollapse
•
C#
private bool m_ExpandingNode = false;
private void flex_BeforeCollapse(object sender, RowColEventArgs e)
{
// if we're working, ignore this
if (m_ExpandingNode)
return;
// don't allow collapsing/expanding groups of rows (with shift-click)
if (e.Row < 0)
{
e.Cancel = true;
return;
}
}
•
// if we're already collapsed, populate node
// before expanding
if (flex.Rows[e.Row].Node.Collapsed)
{
m_ExpandingNode = true;
ExpandRow(e.Row);
m_ExpandingNode = false;
}
Delphi
procedure Class1.flex_BeforeCollapse(sender: System.Object; e:
RowColEventArgs);
begin
// if we're working, ignore this
if Self.m_ExpandingNode then
Exit;
220 · C1FlexGrid Reference
// don't allow collapsing/expanding groups of rows (with shift-click)
if (e.Row < 0) then
begin
e.Cancel := True;
Exit;
end;
// if we're already collapsed, populate node
// before expanding
if flex.Rows[e.Row].Node.Collapsed then
begin
Self.m_ExpandingNode := True;
ExpandRow(e.Row);
Self.m_ExpandingNode := False;
end;
end;
The code starts by declaring an m_ExpandingNode flag used to prevent recursive calls. This is needed
because the ExpandRow routine called later in the code also expands some nodes, which fires the event
again.
Then it checks the value of the e.Row parameter. This parameter can be negative if many rows are being
expanded or collapsed at once (this happens when you call the Tree.Show method).
Finally, the code checks whether the current row is collapsed. If it is, a helper routine ExpandRow is
called to populate the node before it is expanded.
BeforeCollapse and AfterCollapse now fire with Row = -1 to indicate many rows are being expanded or
collapsed.
When the user clicks an outline button, several nodes may be expanded or collapsed to show the target
outline level. In these cases, the grid will fire the BeforeCollapse event with the Row parameter set to -1 to
indicate it is starting a collapse/expand batch of operations, and it will fire the AfterCollapse event with
the Row parameter set to -1 to indicate it is done with the batch. For example, when the user expands the
outline tree to a given level, the control will fire the following event sequence:
•
Visual Basic
BeforeCollapse(e.Row = - 1) ' ** batch started
BeforeCollapse(e.Row = 1) ' individual rows being collapsed/expanded
AfterCollapse(e.Row = 1)
BeforeCollapse(e.Row = 5)
AfterCollapse(e.Row = 5)
BeforeCollapse(e.Row = 15)
AfterCollapse(e.Row = 15)
AfterCollapse(e.Row = - 1) ' ** batch ended
•
C#
BeforeCollapse
BeforeCollapse
AfterCollapse
BeforeCollapse
AfterCollapse
BeforeCollapse
AfterCollapse
AfterCollapse
•
(e.Row
(e.Row
(e.Row
(e.Row
(e.Row
(e.Row
(e.Row
(e.Row
=
=
=
=
=
=
=
=
-1) // ** batch started
1) // individual rows being collapsed/expanded
1)
5)
5)
15)
15)
-1) // ** batch ended
Delphi
BeforeCollapse(e.Row = -1); // ** batch started
BeforeCollapse(e.Row = 1); // individual rows being
collapsed/expanded
AfterCollapse(e.Row = 1);
BeforeDeleteRow Event · 221
BeforeCollapse(e.Row = 5);
AfterCollapse(e.Row = 5);
BeforeCollapse(e.Row = 15);
AfterCollapse(e.Row = 15);
AfterCollapse(e.Row = -1); // ** batch ended
See Also
C1FlexGrid Class (page 101)
BeforeDeleteRow Event
Fires when the AllowDelete property is set to True, before the user deletes a row from the grid by
pressing the Delete key.
Syntax
[VB]
Public Event BeforeDeleteRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C# ]
public event RowColEventHandler BeforeDeleteRow
[Delphi]
property BeforeDeleteRow: RowColEventHandler;
Remarks
This event does not fire when rows are removed from the grid programmatically or through the grid's
data source. It only fires when AllowDelete is set to True and the user deletes one or more rows by
pressing the Delete key.
You can use this event to cancel the deletion of the rows by setting the Cancel parameter to True.
See Also
C1FlexGrid Class (page 101)
BeforeDragColumn Event
Fires when the user drags a column using the mouse, before the column is moved to the new position.
Syntax
[VB]
Public Event BeforeDragColumn(sender As Object, e As DragRowColEventArgs) As
DragRowColEventHandler
[C# ]
public event DragRowColEventHandler BeforeDragColumn
[Delphi]
property BeforeDragColumn: DragRowColEventHandler;
222 · C1FlexGrid Reference
Event Data
The event handler receives an argument of type DragRowColEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int Col
The current index of the column that was dragged by the user.
int Position
The new index of the column that was dragged by the user. You may modify this
value to move the column to any position.
Remarks
This event is only fired when a column is moved by the user, by dragging it with the mouse (see the
AllowDragging property). It is not fired when a column is moved using the Cols.Move method.
You can prevent specific columns from being dragged by the user by setting their AllowDragging
property to false.
See Also
C1FlexGrid Class (page 101)
BeforeDragRow Event
Fires when the user drags a column using the mouse, before the column is moved to the new position.
Syntax
[VB]
Public Event BeforeDragRow(sender As Object, e As DragRowColEventArgs) As
DragRowColEventHandlers
[C#]
public event DragRowColEventHandler BeforeDragRow
[Delphi]
property BeforeDragRow: DragRowColEventHandler;
Event Data
The event handler receives an argument of type DragRowColEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int Row
The current index of the row that was dragged by the user.
int Position
The new index of the row that was dragged by the user. You may modify this value
to move the column to any position.
BeforeEdit Event · 223
Remarks
This event is only fired when a row is moved by the user, by dragging it with the mouse (see the
AllowDragging property). It is not fired when a row is moved using the Rows.Move method.
You can prevent specific rows from being dragged by the user by setting their AllowDragging property
to false.
See Also
C1FlexGrid Class (page 101)
BeforeEdit Event
Fires before the control enters edit mode.
Syntax
[VB]
Public Event BeforeEdit(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeEdit
[Delphi]
property BeforeEdit: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row, Col
The cell that is about to be edited or painted.
bool Cancel
Set this parameter to true to prevent the cell from being edited.
Remarks
This event is fired before the control enters edit mode and before an editable cell is repainted when it has
the focus (to determine whether the cell should be painted with a drop-down arrow). It allows you to
prevent editing by setting the Cancel parameter to true, to supply a list of choices for a combo list with the
ComboList property, or to specify an edit mask with the EditMask property.
If the choices or the mask are the same for a whole column, you may set the relevant properties
(AllowEdit, ComboList, and EditMask) on the Column object instead.
Because BeforeEdit is fired before each repaint, it does not guarantee that the control is really about to
enter edit mode. For that, use the StartEdit event instead.
Example
The code below shows how you can prevent editing of certain cells based on their content. (Note that you
can prevent editing on an entire column by setting the column's AllowEditing property to false).
224 · C1FlexGrid Reference
•
Visual Basic
Private Sub c1FlexGrid1_BeforeEdit(sender As Object, e As
RowColEventArgs)
Dim value As Object = _flex(e.Row, e.Col)
If TypeOf value Is Integer And CInt(value) < 0 Then
e.Cancel = True
End If
End Sub 'c1FlexGrid1_BeforeEdit
•
C#
private void c1FlexGrid1_BeforeEdit(object sender, RowColEventArgs e)
{
object value = _flex[e.Row, e.Col];
if (value is int && (int)value < 0)
e.Cancel = true;
}
•
Delphi
var
value: System.Object;
begin
value := _flex[e.Row];
if ((value is System.Int32) and (Integer(value) < 0)) then
e.Cancel := True;
end;
See Also
C1FlexGrid Class (page 101)
BeforeFreezeColumn Event
Fired before the user freezes columns with the mouse.
Syntax
[VB]
Public Event BeforeFreezeColumn(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeFreezeColumn
[Delphi]
property BeforeFreezeColumn: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row, Col
The cell that is about to be edited or painted.
bool Cancel
Set this parameter to true to prevent the cell from being edited.
BeforeFreezeRow Event · 225
Remarks
See the AllowFreezing Property (page 111.)
See Also
C1FlexGrid Class (page 101)
BeforeFreezeRow Event
Fired before the user freezes rows with the mouse.
Syntax
[VB]
Public Event BeforeFreezeRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeFreezeRow
[Delphi]
property BeforeFreezeRow: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row, Col
The cell that is about to be edited or painted.
bool Cancel
Set this parameter to true to prevent the cell from being edited.
Remarks
See the AllowFreezing Property (page 111.)
See Also
C1FlexGrid Class (page 101)
BeforeMouseDown Event
Fired before the control processes the MouseDown event.
Syntax
[VB]
Public Event BeforeMouseDown(sender As Object, e As BeforeMouseDownEventArgs) As
BeforeMouseDownEventHandler
[C#]
public BeforeMouseDownEventHandler BeforeMouseDown
226 · C1FlexGrid Reference
[Delphi]
property BeforeMouseDown: BeforeMouseDownEventHandler;
Event Data
The event handler receives an argument of type BeforeMouseDownEventArgs containing data related to
this event. The following properties provide information specific to this event.
Property
Description
MouseButtons Button
Gets which mouse button was pressed.
int Clicks, X, Y, Delta
Other information about the mouse action (same as the parameters in the
MouseDown event).
bool Cancel
Set this parameter to true to prevent the control from processing the mouse
message.
Remarks
The parameters for this event are identical to the ones in the MouseDown event, plus an additional
Cancel parameter that allows you to tell the control to ignore the event so you can handle it yourself.
Example
The following routine disables mouse selection while the grid is in edit mode:
•
Visual Basic
Private Sub flex_BeforeMouseDown(sender As Object, e As
BeforeMouseDownEventArgs)
If Not (flex.Editor Is Nothing) Then
e.Cancel = True
End If
End Sub 'flex_BeforeMouseDown
•
C#
private void flex_BeforeMouseDown(object sender,
BeforeMouseDownEventArgs e)
{
if (flex.Editor != null)
e.Cancel = true;
}
•
Delphi
procedure Class1.flex_BeforeMouseDown(sender: System.Object; e:
BeforeMouseDownEventArgs);
begin
if (flex.Editor <> nil) then
e.Cancel := True;
end;
See Also
C1FlexGrid Class (page 101)
BeforePageBreak Event · 227
BeforePageBreak Event
Fires while the control is being printed, to allow control over page breaks.
Syntax
[VB]
Public Event BeforePageBreak(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforePageBreak
[Delphi]
property BeforePageBreak: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The row that will cause the page break and will be printed first on a new page.
bool Cancel
Set this parameter to true to prevent Row from being the first row on the page.
Remarks
This event is fired while the control is being printed with the PrintGrid method, and provides control
over page breaks.
Set the Cancel parameter to true to indicate that Row should not be printed at the top of a page. In this
case, the control will move the break point up and fire the event again until it finds a valid break point.
Example
The following code shows how to use the BeforePageBreak event to keep groups of rows together on a
page.
•
Visual Basic
Private Sub flex_BeforePageBreak(sender As Object, e As
RowColEventArgs)
' get content before and after the proposed page break
Dim s1 As String = CStr(flex(e.Row, 1))
Dim s2 As String = CStr(flex(e.Row - 1, 1))
' if contents are the same, set Cancel to true to
' keep rows together on a page
If s1 = s2 Then
e.Cancel = True
End If
End Sub 'flex_BeforePageBreak
•
C#
private void flex_BeforePageBreak(object sender, RowColEventArgs e)
{
228 · C1FlexGrid Reference
// get content before and after the proposed page break
string s1 = (string) flex[e.Row,1];
string s2 = (string) flex[e.Row-1,1];
}
•
// if contents are the same, set Cancel to true to
// keep rows together on a page
if (s1 == s2)
e.Cancel = true;
Delphi
procedure Class1.flex_BeforePageBreak(sender: System.Object; e:
RowColEventArgs);
var
s2: string;
s1: string;
begin
s1 := string(flex[e.Row]);
s2 := string(flex[(e.Row - 1)]);
if (s1 = s2) then
e.Cancel := True;
end;
See Also
C1FlexGrid Class (page 101)
BeforeResizeColumn Event
Fires before a column is resized.
Syntax
[VB]
Public Event BeforeResizeColumn(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeResizeColumn
[Delphi]
property BeforeResizeColumn: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Col
The column that is about to be resized.
bool Cancel
Set this parameter to true to prevent Col from being resized.
BeforeResizeRow Event · 229
Remarks
Use the grid's AllowResizing property to determine whether users are allowed to resize rows, columns,
or both. Row and Column objects also have an AllowResizing property that allows you to prevent
specific columns from being resized.
See Also
C1FlexGrid Class (page 101)
BeforeResizeRow Event
Fires before a row is resized.
Syntax
[VB]
Public Event BeforeResizeRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeResizeRow
[Delphi]
property BeforeResizeRow: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The row that is being resized.
bool Cancel
Set this parameter to true to prevent Row from being resized.
Remarks
Use the grid's AllowResizing property to determine whether users are allowed to resize rows, columns,
or both. Row and Column objects also have an AllowResizing property that allows you to prevent
specific columns from being resized.
See Also
C1FlexGrid Class (page 101)
BeforeRowColChange Event
Fires before the current cell (Row, Col) changes to a different cell.
Syntax
[VB]
Public Event BeforeRowColChange(sender As Object, e As RangeEventArgs) As RangeEventHandler
230 · C1FlexGrid Reference
[C#]
public event RangeEventHandler BeforeRowColChange
[Delphi]
property BeforeRowColChange: RangeEventHandler;
Event Data
The event handler receives an argument of type RangeEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
CellRange OldRange
The selection before the event.
CellRange NewRange
The current selection.
Remarks
This event gets fired before the Row and Col properties change, either as a result of user actions or
through code. It allows you to prevent the selection of certain cells, thus creating "protected" ranges on a
grid.
BeforeRowColChange is fired only when the Row and Col property are about to change. To prevent the
extended selection of a range, you also need to handle the BeforeSelChange event.
See Also
C1FlexGrid Class (page 101)
BeforeScroll Event
Fires before the control scrolls.
Syntax
[VB]
Public Event BeforeScroll(sender As Object, e As RangeEventArgs) As RangeEventHandler
[C#]
public event RangeEventHandler BeforeScroll
[Delphi]
property BeforeScroll: RangeEventHandler;
Event Data
The event handler receives an argument of type RangeEventHandler containing data related to this
event. The following properties provide information specific to this event.
Remarks
This event allows you to prevent the user from scrolling the grid while an operation is being performed
on the current selection.
BeforeScrollTip Event · 231
See Also
C1FlexGrid Class (page 101)
BeforeScrollTip Event
Fires before a scroll tip is shown so you can set the ScrollTipText property.
Syntax
[VB]
Public Event BeforeScrollTip(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler BeforeScrollTip
[Delphi]
property BeforeScrollTip: RangeEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The row in which the current cell is located.
Remarks
This event is fired only if the ScrollTips property is set to True. It allows you to set the ScrollTipText
property to a descriptive string for the given row. For example:
•
Visual Basic
flex.ScrollTips = True
flex.ScrollTrack = False
Private Sub flex_BeforeScrollTip(sender As Object, e As
RowColEventArgs)
Dim tip As String
tip = String.Format("Row {0}" + ControlChars.Lf + "{1}", _
e.Row, flex(e.Row, 1))
flex.ScrollTipText = tip
End Sub 'flex_BeforeScrollTip
•
C#
flex.ScrollTips = true;
flex.ScrollTrack = false;
private void flex_BeforeScrollTip(object sender, RowColEventArgs e)
{
string tip = string.Format("Row {0}\n{1}", e.Row, flex[e.Row,1]);
flex.ScrollTipText = tip;
}
232 · C1FlexGrid Reference
•
Delphi
flex.ScrollTips := True;
flex.ScrollTrack := False;
procedure Class1.flex_BeforeScrollTip(sender: System.Object; e:
RowColEventArgs);
var
tip: string;
begin
tip := System.String.Format('Row {0}'#10'{1}', e.Row, flex[e.Row]);
flex.ScrollTipText := tip;
end;
See Also
C1FlexGrid Class (page 101)
BeforeSelChange Event
Fires before the selected range (RowSel, ColSel) changes.
Syntax
[VB]
Public Event BeforeSelChange(sender As Object, e As RangeEventArgs) As RangeEventHandler
[C#]
public event RangeEventHandler BeforeSelChange
[Delphi]
property BeforeSelChange: RangeEventHandler;
Event Data
The event handler receives an argument of type RangeEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
CellRange OldRange
The selection before the event.
CellRange NewRange
The current selection.
Remarks
This event is fired before the RowSel and ColSel properties change, either as a result of user actions or
through code. It allows you to prevent the selection of certain cells, thus creating "protected" ranges on a
grid.
To prevent the selection of a range, you also need to handle the BeforeRowColChange event, which is
fired before the Row and Col properties change.
See Also
C1FlexGrid Class (page 101)
BeforeSort Event · 233
BeforeSort Event
Fires before a column is sorted by a click on a column header.
Syntax
[VB]
Public Event BeforeSort(sender As Object, e As SortColEventArgs) As SortColEventHandler
[C#]
public event SortColEventHandler BeforeSort
[Delphi]
property BeforeSort: SortColEventHandler;
Event Data
The event handler receives an argument of type SortColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Col
The column that is being sorted.
SortFlags Order
The sorting order.
bool Cancel
Cancel the sorting operation. Setting this parameter to true cancels the built-in
sort operation and leaves the sorting glyph unchanged.
bool Handled
Sort was handled by the event handler. Setting this parameter to true cancels
the built-in sort but updates the sorting glyph as if the sort had been performed.
This is useful in case you want to provide custom sorting.
Remarks
This event is only fired if the sorting was caused by a click on a column header. It is not fired before
sorting with the Sort property.
This event is useful when you want to prevent the user from sorting certain columns or to specify custom
sorting orders for specific columns. You may do so by modifying the value of the Order parameter.
See Also
C1FlexGrid Class (page 101)
BeginPrint Event
Fires when the grid starts printing.
Syntax
[VB]
Public Event BeginPrint(sender As Object, e As PrintEventArgs) As PrintEventHandler
234 · C1FlexGrid Reference
[C#]
public event PrintEventHandler BeginPrint
[Delphi]
property BeginPrint: PrintEventHandler;
Event Data
The event handler receives an argument of type PrintEventHandler, defined in the
System.Drawing.Printing namespace.
Remarks
Use the PrintGrid method to print the grid and specify the document name, common printing options,
headers and footers. Use the PrintParameters property to specify less common printing options such as
header and footer fonts, page margins, orientation, etc.
See Also
C1FlexGrid Class (page 101)
CancelAddRow Event
Fires when the AllowAddNew property is set to True, after the user adds a row and then removes it by
exiting the new row without making any changes
Syntax
[VB]
Public Event CancelAddRow(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler CancelAddRow
[Delphi]
property CancelAddRow: RowColEventHandler;
Remarks
For details, see the AfterAddRow event.
See Also
C1FlexGrid Class (page 101)
CellButtonClick Event
Fires after the user clicks a cell button.
Syntax
[VB]
Public Event CellButtonClick(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler CellButtonClick
CellChanged Event · 235
[Delphi]
property CellButtonClick: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The row in which the current cell is located.
int Col
The column in which the current cell is located.
Remarks
This event is fired when the user clicks an edit button on a cell. Typically, this event is used to pop up a
custom editor for the cell (e.g. dialogs for selecting colors, dates, files, pictures, and so on).
By default, cell edit buttons are displayed on the right side of a cell, with an ellipsis caption ("..."). They
are similar to the buttons displayed in the Visual Basic property window next to picture properties. You
may customize their appearance by assigning a picture to the CellButtonImage property.
To create an edit button on a cell, you must set the AllowEditing property to True and set the ComboList
property (on the grid or specific columns) to an ellipsis ("…").
See Also
C1FlexGrid Class (page 101)
CellChanged Event
Fires after the contents of a cell change.
Syntax
[VB]
Public Event CellChanged(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler CellChanged
[Delphi]
property CellChanged: RowColEventHandler;
Remarks
This event allows you to perform processing whenever the contents of a cell change, regardless of how
they were changed (e.g. a user typed data into the cell, data got loaded from a database, or data was
assigned to the grid through code).
This event can be used to provide conditional formatting and dynamic data summaries, which get
updated automatically whenever the data changes. For an example, see the Formatting Cells (page 26)
topic.
236 · C1FlexGrid Reference
Important Note: In some cases, CellChanged will fire with e.Col = -1
When you edit a cell in the grid, it fires the CellChanged event and tells you which row and column
changed. This works in bound and unbound mode.
However, when the grid is bound to a data source and some value in the data source changes, the data
source informs the grid that something in that row has changed. It does not inform the grid which
column changed (it could even be several columns). This is due to the way the IBindingList interface is
defined in .NET. Change notifications go down to the row (record) level, not to the column (field).
If the grid is bound and the user types something into a cell, you will actually get two notifications. One
from the grid itself, with the row and column, and one from the data source, with the row and -1 for the
column. If the only UI element that can change the data in your app is the grid, you can ignore the second
notification.
See Also
C1FlexGrid Class (page 101)
ChangeEdit Event
Fires after the text in the editor has changed.
Syntax
[VB]
Public Event ChangeEdit(sender As Object, e As EventArgs) As EventHandler
[C#]
public EventHandler ChangeEdit
[Delphi]
property ChangeEdit: EventHandler;
Event Data
No Parameters.
Remarks
This event is fired while in edit mode, whenever the contents of the editor change or a new selection is
made from a drop-down list.
Example
The code below shows how you can use the ChangeEdit event to resize a row so it fits the contents of all
cells, adjusting the row height automatically as the user types:
•
Visual Basic
' set up grid styles to allow wordwrapping:
Private Sub Form1_Load(sender As Object, e As System.EventArgs)
flex.Styles.Normal.WordWrap = True
End Sub 'Form1_Load
' after editing a row, do an AutoSizeRow
Private Sub flex_AfterEdit(sender As Object, e As RowColEventArgs)
flex.AutoSizeRow(e.Row)
End Sub 'flex_AfterEdit
ChangeEdit Event · 237
' while editing, adjust the row height to fit the contents of the
editor
Private Sub flex_ChangeEdit(sender As Object, e As System.EventArgs)
Dim g As Graphics = flex.CreateGraphics()
Try
' measure text height
Dim sf As New StringFormat()
Dim wid As Integer = flex.Cols(flex.Col).WidthDisplay - 2
Dim [text] As String = flex.Editor.Text
Dim sz As SizeF = g.MeasureString([text], flex.Font, wid, sf)
' adjust row height if necessary
Dim row As Row = flex.Rows(flex.Row)
If sz.Height + 4 > row.HeightDisplay Then
row.HeightDisplay = CInt(sz.Height) + 4
End If
Finally
g.Dispose()
End Try
End Sub 'flex_ChangeEdit
•
C#
// set up grid styles to allow wordwrapping:
private void Form1_Load(object sender, System.EventArgs e)
{
flex.Styles.Normal.WordWrap = true;
}
// after editing a row, do an AutoSizeRow
private void flex_AfterEdit(object sender, RowColEventArgs e)
{
flex.AutoSizeRow(e.Row);
}
// while editing, adjust the row height to fit the contents of the
editor
private void flex_ChangeEdit(object sender, System.EventArgs e)
{
using (Graphics g = flex.CreateGraphics())
{
// measure text height
StringFormat sf = new StringFormat();
int wid = flex.Cols[flex.Col].WidthDisplay - 2;
string text = flex.Editor.Text;
SizeF sz = g.MeasureString(text, flex.Font, wid, sf);
// adjust row height if necessary
Row row = flex.Rows[flex.Row];
if (sz.Height + 4 > row.HeightDisplay)
row.HeightDisplay = (int)sz.Height + 4;
}
}
•
Delphi
// set up grid styles to allow wordwrapping:
procedure Form1_Load(sender: System.Object; e: System.EventArgs);
begin
flex.Styles.Normal.WordWrap := True;
end; // Form1_Load
// after editing a row, do an AutoSizeRow
procedure flex_AfterEdit(sender: System.Object; e: RowColEventArgs);
begin
flex.AutoSizeRow(e.Row);
end; // flex_AfterEdit
238 · C1FlexGrid Reference
// while editing, adjust the row height to fit the contents of the
editor
procedure flex_ChangeEdit(sender: System.Object; e: System.EventArgs);
var
g: Graphics;
sf: StringFormat;
wid: Integer;
txt: string;
sz: SizeF;
r: Row;
begin
g := flex.CreateGraphics;
Try
// measure text height
sf := StringFormat.Create;
wid := flex.Cols[flex.Col].WidthDisplay – 2;
txt := flex.Editor.Text;
sz := g.MeasureString(txt, flex.Font, wid, sf);
// adjust row height if necessary
r := flex.Rows[flex.Row];
if sz.Height + 4 > row.HeightDisplay then
row.HeightDisplay := Integer(sz.Height) + 4;
Finally
g.Dispose;
end;
end; // flex_ChangeEdit
See Also
C1FlexGrid Class (page 101)
ComboCloseUp Event
Fires while the grid is in edit mode, after the user closes the drop-down list.
Syntax
[VB]
Public Event ComboCloseUp(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler ComboCloseUp
[Delphi]
property ComboCloseUp: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The row in which the current cell is located.
int Col
The column in which the current cell is located.
ComboDropDown Event · 239
Remarks
This event is fired while in edit mode, when a cell is being edited using the built-in drop-down editor.
See Also
C1FlexGrid Class (page 101)
ComboDropDown Event
Fires while the grid is in edit mode, before the user drops down the combo list.
Syntax
[VB]
Public Event ComboDropDown(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler ComboDropDown
[Delphi]
property ComboDropDown: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The row in which the current cell is located.
int Col
The column in which the current cell is located.
Remarks
This event is fired while in edit mode, when a cell is being edited using the built-in drop-down editor.
See Also
C1FlexGrid Class (page 101)
EndPrint Event
Fires when the grid finishes printing.
Syntax
[VB]
Public Event EndPrint(sender As Object, e As PrintEventArgs) As PrintEventHandler
[C#]
public event PrintEventHandler EndPrint
240 · C1FlexGrid Reference
[Delphi]
property EndPrint: PrintEventHandler;
Event Data
The event handler receives an argument of type PrintEventHandler, defined in the
System.Drawing.Printing namespace.
Remarks
Use the PrintGrid method to print the grid and specify the document name, common printing options,
headers and footers. Use the PrintParameters property to specify less common printing options such as
header and footer fonts, page margins, orientation, etc.
See Also
C1FlexGrid Class (page 101)
EnterCell Event
Fires when a cell becomes active.
Syntax
[VB]
Public Event EnterCell(sender As Object, e As EventArgs) As EventHandler
[C#]
public event EventHandler EnterCell
[Delphi]
property EnterCell: EventHandler;
Event Data
No Parameters.
Remarks
This event is fired after a cell becomes current, either as a result of mouse/keyboard action, or when the
current selection is modified programmatically.
See Also
C1FlexGrid Class (page 101)
GetUnboundValue Event
Fires when the grid is bound and needs to retrieve a value from an unbound column.
Syntax
[VB]
Public Event GetUnboundValue(sender As Object, e As EventArgs) As UnboundValueEventHandler
[C#]
public event UnboundValueEventHandler GetUnboundValue
GetUnboundValue Event · 241
[Delphi]
property GetUnboundValue: UnboundValueEventHandler;
Event Data
The event handler receives an argument of type UnboundValueEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int Row, Col
The unbound cell that contains the value.
object Value
The value of the unbound cell. The event handler should retrieve or
calculate the unbound value and assign it to this parameter.
Remarks
This event only fires in bound mode, when the grid contains unbound columns. Unbound columns do
not map to values in the data source, they may contain information that is calculated based on the bound
columns or any information provided by the application.
The ADO.NET DataTable class supports calculated columns than in many situations can be used instead
of unbound columns. However, calculated columns are somewhat limited (the values must be simple
functions of other values in the same row). In these cases, you may want to use an unbound column and
provide the value using this event.
For example, the code below binds the grid to a data source, than adds an unbound column that contains
additional information not stored in the database:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
' load table from db
Dim dt As DataTable = GetProductDataTable()
' bind to grid
_flex.Cols(0).Width = 20
_flex.ShowCursor = True
_flex.DataSource = dt
' add unbound column
Dim col As Column = _flex.Cols.Add()
col.Name = col.Caption = "Unbound"
End Sub
' keep unbound values in a hashtable
Dim _hash As New Hashtable()
Private Sub
ByVal e
Handles
Dim drv
e.Value
End Sub
_flex_GetUnboundValue(ByVal sender As Object, _
As C1.Win.C1FlexGrid.UnboundValueEventArgs) _
_flex.GetUnboundValue
As DataRowView = _flex.Rows(e.Row).DataSource
= _hash(drv("ProductID"))
Private Sub _flex_SetUnboundValue(ByVal sender As Object, _
242 · C1FlexGrid Reference
ByVal e As C1.Win.C1FlexGrid.UnboundValueEventArgs) _
Handles _flex.SetUnboundValue
Dim drv As DataRowView = _flex.Rows(e.Row).DataSource
_hash(drv("ProductID")) = e.Value
End Sub
End Sub
•
C#
private void Form1_Load(object sender, System.EventArgs e)
{
// load table from db
DataTable dt = GetProductDataTable();
// bind to grid
_flex.Cols[0].Width = 20;
_flex.ShowCursor = true;
_flex.DataSource = dt;
// add unbound column
Column col = _flex.Cols.Add();
col.Name = col.Caption = "Unbound";
}
// keep unbound values in a hashtable
Hashtable _hash = new Hashtable();
// get value from hashtable using ProductID as key
private void _flex_GetUnboundValue(object sender,
C1.Win.C1FlexGrid.UnboundValueEventArgs e)
{
DataRowView drv = (DataRowView)_flex.Rows[e.Row].DataSource;
e.Value = _hash[drv["ProductID"]];
}
// store value in hashtable using ProductID as key
private void _flex_SetUnboundValue(object sender,
C1.Win.C1FlexGrid.UnboundValueEventArgs e)
{
DataRowView drv = (DataRowView)_flex.Rows[e.Row].DataSource;
_hash[drv["ProductID"]] = e.Value;
}
•
Delphi
TWinForm1 = class(TWinForm)
private
// keep unbound values in a hashtable
Fhash: Hashtable;
end;
constructor TWinForm.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
Fhash := Hashtable.Create;
end;
procedure TWinForm1.TWinForm_Load(sender: System.Object; e:
System.EventArgs);
GridChanged Event · 243
var dt: DataTable;
col: Column;
begin
// load table from db
dt := GetProductDataTable;
// bind to grid
_flex.Cols[0].Width := 20;
_flex.ShowCursor := true;
_flex.DataSource := dt;
// add unbound column
col := _flex.Cols.Add;
col.Name := ‘Unbound’;
col.Caption := col.Name;
end;
// get value from hashtable using ProductID as key
procedure TWinForm1._flex_GetUnboundValue(sender: System.Object; e:
C1.Win.C1FlexGrid.UnboundValueEventArgs);
var drv: DataRowView;
begin
drv := DataRowView(_flex.Rows[e.Row].DataSource);
e.Value := Fhash[drv[‘ProductID’]];
end;
// store value in hashtable using ProductID as key
procedure TWinForm1._flex_SetUnboundValue(sender: System.Object; e:
C1.Win.C1FlexGrid.UnboundValueEventArgs);
var drv: DataRowView;
begin
drv := DataRowView(_flex.Rows[e.Row].DataSource);
Fhash[drv[‘ProductID’]] := e.Value;
end;
See Also
C1FlexGrid Class (page 101)
GridChanged Event
Fires when the grid changes in any way.
Syntax
[VB]
Public Event GridChanged(sender As Object, e As GridChangedEventArgs) As
GridChangedEventHandler
[C#]
public event GridChangedEventHandler GridChanged
[Delphi]
property GridChanged: GridChangedEventHandler;
Event Data
The event handler receives an argument of type GridChangedEventArgs containing data related to this
event. The following properties provide information specific to this event.
244 · C1FlexGrid Reference
Property
Description
int r1, c1, r2, c2
The range of cells that was affected by the event (values may be -1 for events
that affect the entire grid).
GridChangedTypeEnum
GridChangedType
The type of change that caused the event to fire.
Remarks
This event fires in addition to more specific events. For example, if the user moves a column with the
mouse, the control will fire the BeforeDragColumn, GridChanged, and AfterDragColumn events.
The GridChanged event provides a generic, centralized handler for all types of grid events. It does not
provide detailed arguments for each event, or the option of canceling any actions.
See Also
C1FlexGrid Class (page 101)
GridError Event
Fires when the grid detects an error condition.
Syntax
[VB]
Public Event GridError(sender As Object, e As GridErrorEventArgs) As GridErrorEventHandler
[C#]
public event GridErrorEventHandler GridError
[Delphi]
property GridError: GridErrorEventHandler;
Event Data
The event handler receives an argument of type GridErrorEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int row, col
The cell where the error condition was detected.
Exception exception
A description of the error that was detected.
bool handled
Whether the error was handled and the grid should ignore it. If this parameter
is set to False, the grid throws the exception in the exception parameter.
See Also
C1FlexGrid Class (page 101)
KeyDownEdit Event · 245
KeyDownEdit Event
Fires when the user presses a key in cell-editing mode.
Syntax
[VB]
Public Event KeyDownEdit(sender As Object, e As KeyEditEventArgs) As KeyEditEventHandler
[C#]
public event KeyEditEventHandler KeyDownEdit
[Delphi]
property KeyDownEdit: KeyEditEventHandler;
Event Data
The event handler receives an argument of type KeyEditEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The row in which the current cell is located.
int Col
The column in which the current cell is located.
Keys KeyCode
ASCII code for key pressed.
bool Shift
Specifies whether the shift key was pressed.
Remarks
This event is similar to the standard KeyDown event, except it is fired while the grid is in edit mode.
The editor has three modes: text, drop-down combo, or drop-down list. The mode used is determined by
the ComboList properties in the grid and column objects.
While editing with the text editor or with a drop-down combo, you may set or retrieve the contents of the
editor by retrieving the editor control with the Editor property and casting it to the proper type. For
example, the code below retrieves the contents of the selection in the editor control:
•
Visual Basic
Dim selText As String = ""
Dim ctl As Control = flex.Editor
If TypeOf ctl Is TextBox Then
selText = CType(ctl, TextBox).SelectedText
End If
If TypeOf ctl Is ComboBox Then
selText = CType(ctl, ComboBox).SelectedText
End If
•
C#
string selText = "";
Control ctl = flex.Editor
if (ctl is TextBox) selText = ((TextBox)ctl).SelectedText;
if (ctl is ComboBox) selText = ((ComboBox)ctl).SelectedText;
246 · C1FlexGrid Reference
•
Delphi
var
ctl: Control;
selText: string;
begin
selText := '';
ctl := flex.Editor;
if (ctl is TextBox) then selText := TextBox(ctl).SelectedText;
if (ctl is ComboBox) then selText := ComboBox(ctl).SelectedText;
end;
See Also
C1FlexGrid Class (page 101)
KeyPressEdit Event
Fires when the user presses a key in cell-editing mode.
Syntax
[VB]
Public Event KeyPressEdit(sender As Object, e As KeyPressEditEventArgs) As
KeyPressEditEventHandler
[C#]
public event KeyPressEditEventHandler KeyPressEdit
[Delphi]
property KeyPressEdit: KeyPressEditEventHandler;
Event Data
The event handler receives an argument of type KeyPressEditEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int Row
The row in which the current cell is located.
int Col
The column in which the current cell is located.
char KeyChar
The key that the user entered.
bool Handled
Specifies whether the key press was handled.
Remarks
This event is similar to the standard KeyPress event, except it is fired while the grid is in edit mode.
The editor has three modes: text, drop-down combo, or drop-down list. The mode used is determined by
the ComboList properties in the grid and column objects.
While editing with the text editor or with a drop-down combo, you may set or retrieve the contents of the
editor by retrieving the editor control with the Editor property and casting it to the proper type. For
example, the code below retrieves the contents of the selection in the editor control:
KeyUpEdit Event · 247
•
Visual Basic
Dim selText As String = ""
Dim ctl As Control = flex.Editor
If TypeOf ctl Is TextBox Then
selText = CType(ctl, TextBox).SelectedText
End If
If TypeOf ctl Is ComboBox Then
selText = CType(ctl, ComboBox).SelectedText
End If
•
C#
string selText = "";
Control ctl = flex.Editor
if (ctl is TextBox) selText = ((TextBox)ctl).SelectedText;
if (ctl is ComboBox) selText = ((ComboBox)ctl).SelectedText;
•
Delphi
var
ctl: Control;
selText: string;
begin
selText := '';
ctl := flex.Editor;
if (ctl is TextBox) then selText := TextBox(ctl).SelectedText;
if (ctl is ComboBox) then selText := ComboBox(ctl).SelectedText;
end;
See Also
C1FlexGrid Class (page 101)
KeyUpEdit Event
Fires when the user presses a key in cell-editing mode.
Syntax
[VB]
Public Event KeyUpEdit(sender As Object, e As KeyEditEventArgs) As KeyEditEventHandler
[C#]
public event KeyEditEventHandler KeyUpEdit
[Delphi]
property KeyUpEdit: KeyEditEventHandler;
Event Data
The event handler receives an argument of type KeyEditEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int Row
The row in which the current cell is located.
int Col
The column in which the current cell is located.
Keys KeyCode
ASCII code for key pressed.
248 · C1FlexGrid Reference
Property
Description
bool Shift
Specifies whether the shift key was pressed.
Remarks
This event is similar to the standard KeyUp event, except it is fired while the grid is in edit mode.
The editor has three modes: text, drop-down combo, or drop-down list. The mode used is determined by
the ComboList properties in the grid and column objects.
While editing with the text editor or with a drop-down combo, you may set or retrieve the contents of the
editor by retrieving the editor control with the Editor property and casting it to the proper type. For
example, the code below retrieves the contents of the selection in the editor control:
•
Visual Basic
Dim selText As String = ""
Dim ctl As Control = flex.Editor
If TypeOf ctl Is TextBox Then
selText = CType(ctl, TextBox).SelectedText
End If
If TypeOf ctl Is ComboBox Then
selText = CType(ctl, ComboBox).SelectedText
End If
•
C#
string selText = "";
Control ctl = flex.Editor
if (ctl is TextBox) selText = ((TextBox)ctl).SelectedText;
if (ctl is ComboBox) selText = ((ComboBox)ctl).SelectedText;
•
Delphi
var
ctl: Control;
selText: string;
begin
selText := '';
ctl := flex.Editor;
if ctl is TextBox then
selText := TextBox(ctl).SelectedText;
if ctl is ComboBox then
selText := ComboBox(ctl).SelectedText;
end;
See Also
C1FlexGrid Class (page 101)
LeaveCell Event
Fires before the current cell changes to a different cell.
Syntax
[VB]
Public Event LeaveCell(sender As Object, e As EventArgs) As EventHandler
OwnerDrawCell Event · 249
[C#]
public event EventHandler LeaveCell
[Delphi]
property LeaveCell: EventHandler;
Event Data
No Parameters.
Remarks
This event is fired before the cursor leaves the current cell, either as a result of mouse/keyboard action, or
when the current selection is modified programmatically.
See Also
C1FlexGrid Class (page 101)
OwnerDrawCell Event
Fires before the grid draws a cell, when the DrawMode property is set to OwnerDraw.
Syntax
[VB]
Public Event OwnerDrawCell(sender As Object, e As OwnerDrawCellEventArgs) As
OwnerDrawCellEventHandler
[C#]
public event OwnerDrawCellEventHandler OwnerDrawCell
[Delphi]
property OwnerDrawCell: OwnerDrawCellEventHandler;
Event Data
The event handler receives an argument of type OwnerDrawCellEventArgs containing data related to
this event. The following properties provide information specific to this event.
Property
Description
int Row, Col
Get the coordinates of the cell being painted.
Graphics Graphics
Gets the Graphics surface used to draw the cell.
Rectangle Bounds
Get the rectangle where the cell should be drawn.
string Text
Gets or sets the text that will be displayed in the cell.
Image Image
Gets or sets the image that will be displayed in the cell.
CellStyle Style
Sets or sets the CellStyle object used to paint the cell.
void DrawCell(DrawCellFlags
flags)
Causes the grid to paint parts of the cell (background, foreground,
border, etc.)
void DrawCell()
Causes the grid to paint the whole cell.
250 · C1FlexGrid Reference
Property
Description
bool Handled
Gets or sets whether the event has finished drawing the cell.
bool Measuring
Gets a value that determines if the event was fired only to measure
the cell. This occurs while autosizing rows or columns.
Remarks
The OwnerDrawCell event only fires if the DrawMode property is set to OwnerDraw.
You can use this event to customize the appearance of any cell in the grid. The event allows three main
types of customization:
1.
Change the Text and Image parameters to modify the values displayed by the grid. You can use
this type of customization to replace password strings with asterisks, for example.
2.
Change the Style property to display the cell using a different format than the default one
selected by the grid. You can use this type of customization to provide conditional formatting, for
example.
3.
Use the Graphics and Bounds parameters and draw the cell yourself. When drawing cells this way,
you may call the DrawCell member to force the grid to draw specific parts of the cell, while your
code draws other parts. For example, the code below draws cells with a gradient background:
•
Visual Basic
' use owner-draw to add gradients
fg.DrawMode = DrawModeEnum.OwnerDraw
Private Sub fg_OwnerDrawCell(ByVal sender As Object, _
ByVal e As OwnerDrawCellEventArgs) Handles fg.OwnerDrawCell
' draw selected cell background using gradient brush
If fg.Selection.Contains(e.Row, e.Col) Then
e.Graphics.FillRectangle(m_GradientBrush, e.Bounds) ' draw
background
e.DrawCell(DrawCellFlags.Content) ' let the grid draw the
content
e.Handled = True ' we're done drawing this cell
End If
End Sub
•
C#
// use owner-draw to add gradients
fg.DrawMode = DrawModeEnum.OwnerDraw;
private void fg_OwnerDrawCell( object sender,
OwnerDrawCellEventArgs e) fg.OwnerDrawCell {
// draw selected cell background using gradient brush
if ( fg.Selection.Contains(e.Row, e.Col) ) {
e.Graphics.FillRectangle(m_GradientBrush, e.Bounds); // draw
background
e.DrawCell(DrawCellFlags.Content); // let the grid draw the
content
e.Handled = true; // we're done drawing this cell
}
}
OwnerDrawCell Event · 251
•
Delphi
' use owner-draw to add gradients
fg.DrawMode := DrawModeEnum.OwnerDraw;
procedure fg_OwnerDrawCell(sender: System.Object;
e: OwnerDrawCellEventArgs);
begin
// draw selected cell background using gradient brush
If fg.Selection.Contains(e.Row, e.Col) Then
begin
e.Graphics.FillRectangle(m_GradientBrush, e.Bounds); // draw
background
e.DrawCell(DrawCellFlags.Content); // let the grid draw the
content
e.Handled := True; // we're done drawing this cell
end;
end;
The OwnerDrawCell event also fires when the grid autosizes rows or columns (see the AutoSizeRows
and AutoSizeCols methods). This is done because the grid needs to measure the cell using the same text,
image, and style parameters that are used to render it. In these cases, the Measuring parameter is set to
true and the Bounds rectangle is empty.
Example
This example draws cells as usual and highlights the first two characters in the cell. The code starts by
measuring the string and taking into account the cell borders. Then it uses the DrawCell method to draw
the cell background, draws a highlighted rectangle, and ends with the cell contents and borders:
•
Visual Basic
Private Sub _flex_OwnerDrawCell(sender As Object, e As
OwnerDrawCellEventArgs)
' highlight all but the first two characters
Dim txt As String = _flex.GetDataDisplay(e.Row, e.Col)
If txt.Length < 2 Then
Return
End If
txt = txt.Substring(2)
' measure the width of the highlight
Dim g As Graphics = e.Graphics
Dim wid As Integer = CInt(g.MeasureString(txt, e.Style.Font).Width)
wid += e.Style.Margins.Right
wid += e.Style.Border.Width - 1
' build the highlight rect
Dim rc As Rectangle = e.Bounds
rc.X = rc.Right - wid
rc.Width = wid
' draw background, highlight, draw content
e.DrawCell(DrawCellFlags.Background)
g.FillRectangle(Brushes.LightYellow, rc)
e.DrawCell((DrawCellFlags.Border Or DrawCellFlags.Content))
End Sub '_flex_OwnerDrawCell
•
C#
private void _flex_OwnerDrawCell(object sender, OwnerDrawCellEventArgs
e)
{
252 · C1FlexGrid Reference
// highlight all but the first two characters
string txt = _flex.GetDataDisplay(e.Row, e.Col);
if (txt.Length < 2) return;
txt = txt.Substring(2);
// measure the width of the highlight
Graphics g = e.Graphics;
int wid = (int)g.MeasureString(txt, e.Style.Font).Width;
wid += e.Style.Margins.Right;
wid += e.Style.Border.Width - 1;
// build the highlight rect
Rectangle rc = e.Bounds;
rc.X = rc.Right - wid;
rc.Width = wid;
}
•
// draw background, highlight, draw content
e.DrawCell(DrawCellFlags.Background);
g.FillRectangle(Brushes.LightYellow, rc);
e.DrawCell(DrawCellFlags.Border | DrawCellFlags.Content);
Delphi
procedure_flex_OwnerDrawCell(sender: System.Object; e:
OwnerDrawCellEventArgs)
var
txt: string;
g: Graphics;
wid: Integer;
rc: Rectangle;
begin
// highlight all but the first two characters
txt := _flex.GetDataDisplay(e.Row, e.Col);
If txt.Length < 2 Then
exit;
txt := txt.Substring(2);
// measure the width of the highlight
g := e.Graphics;
wid := Round(g.MeasureString(txt, e.Style.Font).Width);
wid := wid + e.Style.Margins.Right;
wid := wid + e.Style.Border.Width – 1;
// build the highlight rect
rc := e.Bounds;
rc.X := rc.Right – wid;
rc.Width := wid;
// draw background, highlight, draw content
e.DrawCell(DrawCellFlags.Background);
g.FillRectangle(Brushes.LightYellow, rc);
e.DrawCell(DrawCellFlags.Border Or DrawCellFlags.Content);
end; //_flex_OwnerDrawCell
See Also
C1FlexGrid Class (page 101)
PrintPage Event
Fires when the grid finishes printing a page.
RowColChange Event · 253
Syntax
[VB]
Public Event PrintPage(sender As Object, e As PrintPageEventArgs) As PrintPageEventHandler
[C#]
public event PrintPageEventHandler PrintPage
[Delphi]
property PrintPage: PrintPageEventHandler;
Event Data
The event handler receives an argument of type PrintEventHandler, defined in the
System.Drawing.Printing namespace.
Remarks
Use the PrintGrid method to print the grid and specify the document name, common printing options,
headers and footers. Use the PrintParameters property to specify less common printing options such as
header and footer fonts, page margins, orientation, etc.
This event allows you to add custom graphics to a printed page or to cancel the printing process.
See Also
C1FlexGrid Class (page 101)
RowColChange Event
Fires when the current cell (Row, Col) changes to a different cell.
Syntax
[VB]
Public Event RowColChange(sender As Object, e As EventArgs) As EventHandler
[C#]
public event EventHandler RowColChange
[Delphi]
property RowColChange: EventHandler;
Event Data
No Parameters
Remarks
RowColChange is fired when the Row or Col properties change, either as a result of user actions (mouse
or keyboard) or through code. It is not fired when the selection changes (RowSel or ColSel properties)
but the active cell (Row, Col) remains the same. In this case, the SelChange event is fired instead.
See Also
C1FlexGrid Class (page 101)
254 · C1FlexGrid Reference
SelChange Event
Fires after the selected range (RowSel, ColSel) changes.
Syntax
[VB]
Public Event SelChange(sender As Object, e As EventArgs) As EventHandler
[C#]
public event EventHandler SelChange
[Delphi]
property SelChange: EventHandler;
Event Data
No Parameters
Remarks
SelChange is fired after the Row, Col, RowSel or ColSel properties change, either as a result of user
actions (mouse or keyboard) or through code. This event is also fired while the user extends the selection
with the mouse.
See Also
C1FlexGrid Class (page 101)
SetUnboundValue Event
Fires when the grid is bound and needs to set a value in an unbound column.
Syntax
[VB]
Public Event SetUnboundValue(sender As Object, e As EventArgs) As UnboundValueEventHandler
[C#]
public event UnboundValueEventHandler SetUnboundValue
[Delphi]
property SetUnboundValue: UnboundValueEventHandler;
Event Data
The event handler receives an argument of type UnboundValueEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int Row, Col
The unbound cell that contains the value.
object Value
The value of the unbound cell. The event handler should assign this value
to the cell.
SetupEditor Event · 255
Remarks
This event only fires in bound mode, when the grid contains unbound columns. Unbound columns do
not map to values in the data source; they may contain information that is calculated based on the bound
columns or any information provided by the application.
In most cases, unbound columns are read-only, and you don't need to handle this event. However, if a
value is assigned to an unbound cell, either through editing or programmatically, the grid fires this event
to allow the application to store the value using whatever mechanism is appropriate.
For an example, see the GetUnboundValue event.
See Also
C1FlexGrid Class (page 101)
SetupEditor Event
Fires after the built-in editor is initialized but before it is displayed.
Syntax
[VB]
Public Event SetupEditor(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler SetupEditor
[Delphi]
property SetupEditor: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int row, col
The coordinates of the cell about to be edited.
Remarks
The grid initializes the editor based on the style of the cell about to be edited. By default, the editor has
the same font, background color, alignment, etc as the cell. You can use the SetupEditor event to override
that behavior and customize the appearance of the editor.
Example
The code below makes the editor use a bold font with yellow background, and sets the maximum length
to 4:
•
Visual Basic
Private Sub flex_SetupEditor(sender As Object, e As RowColEventArgs)
Dim ctl As Control = flex.Editor
ctl.Font = New Font(ctl.Font, FontStyle.Bold)
256 · C1FlexGrid Reference
ctl.BackColor = Color.Yellow
If TypeOf ctl Is TextBox Then
CType(ctl, TextBox).MaxLength = 4
End If
End Sub 'flex_SetupEditor
•
C#
private void flex_SetupEditor(object sender, RowColEventArgs e)
{
Control ctl = flex.Editor;
ctl.Font = new Font(ctl.Font, FontStyle.Bold);
ctl.BackColor = Color.Yellow;
if (ctl is TextBox) ((TextBox)ctl).MaxLength = 4;
}
•
Delphi
procedure Class1.flex_SetupEditor(sender: System.Object; e:
RowColEventArgs);
var
ctl: Control;
begin
ctl := flex.Editor;
ctl.Font := Font.Create(ctl.Font, FontStyle.Bold);
ctl.BackColor := Color.Yellow;
if (ctl is TextBox) then TextBox(tl).MaxLength := 4;
end;
And here's a more sophisticated example that uses the SetupEditor event to install event handlers for the
editor:
•
Visual Basic
' ** initialize and hook up event handlers for the grid editors
Private Sub flex_SetupEditor(sender As Object, e As RowColEventArgs)
' set up the grid's combo box
Dim cb As ComboBox = flex.Editor '
If Not (cb Is Nothing) Then
' make this a real combo, even if we're using a DataMap
cb.DropDownStyle = ComboBoxStyle.DropDown
' hook up combo event
cb.SelectedIndexChanged -= New
System.EventHandler(fe_SelectedValueChanged)
AddHandler cb.SelectedIndexChanged, AddressOf
fe_SelectedValueChanged
' hook up textbox event
cb.TextChanged -= New
System.EventHandler(fe_SelectedValueChanged)
AddHandler cb.TextChanged, AddressOf fe_SelectedValueChanged
End If
' set up the grid's text box
Dim tb As TextBox = flex.Editor '
If Not (tb Is Nothing) Then
tb.TextChanged -= New
System.EventHandler(fe_SelectedValueChanged)
AddHandler tb.TextChanged, AddressOf fe_SelectedValueChanged
End If
End Sub 'flex_SetupEditor
' ** event handlers for the grid editors
SetupEditor Event · 257
Private Sub fe_SelectedValueChanged(sender As Object, e As
System.EventArgs)
Console.WriteLine(("editor value changed to " + _flex.Editor.Text))
End Sub 'fe_SelectedValueChanged
•
C#
// ** initialize and hook up event handlers for the grid editors
private void flex_SetupEditor(object sender, RowColEventArgs e)
{
// set up the grid's combo box
ComboBox cb = flex.Editor as ComboBox;
if (cb != null)
{
// make this a real combo, even if we're using a DataMap
cb.DropDownStyle = ComboBoxStyle.DropDown;
// hook up combo event
cb.SelectedIndexChanged -= new
System.EventHandler(fe_SelectedValueChanged);
cb.SelectedIndexChanged += new
System.EventHandler(fe_SelectedValueChanged);
// hook up textbox event
cb.TextChanged -= new System.EventHandler(fe_SelectedValueChanged);
cb.TextChanged += new System.EventHandler(fe_SelectedValueChanged);
}
// set up the grid's text box
TextBox tb = flex.Editor as TextBox;
if (tb != null)
{
tb.TextChanged -= new System.EventHandler(fe_SelectedValueChanged);
tb.TextChanged += new System.EventHandler(fe_SelectedValueChanged);
}
}
// ** event handlers for the grid editors
private void fe_SelectedValueChanged(object sender, System.EventArgs e)
{
Console.WriteLine("editor value changed to " + _flex.Editor.Text);
}
•
Delphi
// ** initialize and hook up event handlers for the grid editors
procedure flex_SetupEditor(sender: System.Object; e: RowColEventArgs);
var
cb: ComboBox;
tb: TextBox;
begin
// set up the grid's combo box
if cb Is ComboBox then
begin
cb := ComboBox(flex.Editor);
// make this a real combo, even if we're using a DataMap
cb.DropDownStyle := ComboBoxStyle.DropDown;
// hook up combo event
Exclude(cb.SelectedIndexChanged, fe_SelectedValueChanged);
Include(cb.SelectedIndexChanged, fe_SelectedValueChanged);
// hook up textbox event
Exclude(cb.TextChanged, fe_SelectedValueChanged);
Include(cb.TextChanged, fe_SelectedValueChanged);
End;
258 · C1FlexGrid Reference
// set up the grid's text box
if tb Is TextBox then
begin
tb := TextBox(flex.Editor);
Exclude(tb.TextChanged, fe_SelectedValueChanged);
Include(tb.TextChanged, fe_SelectedValueChanged);
end;
end; // flex_SetupEditor
// ** event handlers for the grid editors
procedure fe_SelectedValueChanged(sender: System.Object; e:
System.EventArgs);
Console.WriteLine('editor value changed to ' + _flex.Editor.Text);
end; // fe_SelectedValueChanged
See Also
C1FlexGrid Class (page 101)
StartEdit Event
Fires when the control enters cell edit mode (after BeforeEdit).
Syntax
[VB]
Public Event StartEdit(sender As Object, e As RowColEventArgs) As RowColEventHandler
[C#]
public event RowColEventHandler StartEdit
[Delphi]
property StartEdit: RowColEventHandler;
Event Data
The event handler receives an argument of type RowColEventArgs containing data related to this event.
The following properties provide information specific to this event.
Property
Description
int row, col
The coordinates of the cell about to be edited.
bool Cancel
Specifies whether editing is to be cancelled.
Remarks
This event is fired before the control enters edit mode. It allows you to prevent editing by setting the
Cancel parameter to True, to supply a list of choices for a combo list with the ComboList property, or to
specify an edit mask with the EditMask property.
If the choices or the mask are the same for a whole column, you may set them with the ComboList and
EditMask properties for the Column object, and you don't need to handle the StartEdit event.
ValidateEdit Event · 259
See Also
C1FlexGrid Class (page 101)
ValidateEdit Event
Fires before the control exits cell edit mode.
Syntax
[VB]
Public Event ValidateEdit(sender As Object, e As ValidateEditEventArgs) As ValidateEditEventHandler
[C#]
public event ValidateEditEventHandler ValidateEdit
[Delphi]
property ValidateEdit: ValidateEditEventHandler;
Event Data
The event handler receives an argument of type ValidateEditEventArgs containing data related to this
event. The following properties provide information specific to this event.
Property
Description
int row, col
The coordinates of the cell being edited.
CheckEnum
Checkbox
If the cell contains a checkbox, this parameter contains the setting that is about
to be assigned to the cell. If the cell does not contain a checkbox, this
parameter is set to CheckEnum.None.
bool Cancel
Set this parameter to true to cancel the edits when the value in the editor is
invalid for the cell.
Remarks
The ValidateEdit event fires before changes are committed to the cell. The event code should check the
value contained in the Editor.Text property. If the value is invalid for the cell, set the Cancel parameter to
True and the grid will remain in edit mode until the user types a valid entry.
For example, the code below validates input into a currency column to ensure that values entered are
between 1,000 and 10,000:
•
Visual Basic
Private Sub fg_ValidateEdit(ByVal sender As Object, _
ByVal e As ValidateEditEventArgs) Handles fg.ValidateEdit
' validate amounts
If fg.Cols(e.Col).DataType Is GetType(Decimal) Then
Try
10,000")
Dim dec As Decimal = Decimal.Parse(fg.Editor.Text())
If dec < 1000 Or dec > 10000 Then
MessageBox.Show("Value must be between 1,000 and
260 · C1FlexGrid Reference
e.Cancel = True
End If
Catch
MessageBox.Show("Value not recognized as a Currency")
e.Cancel = True
End Try
End If
End Sub
•
C#
private void fg_ValidateEdit( object sender, ValidateEditEventArgs e)
{
// validate amounts
if ( fg.Cols[e.Col].DataType == typeof(Decimal) ) {
try {
10,000");
Decimal dec = Decimal.Parse(fg.Editor.Text());
if ( dec < 1000 || dec > 10000 ) {
MessageBox.Show("value must be between 1,000 and
e.Cancel = true;
}
} catch {
MessageBox.Show("value not recognized as a Currency");
e.Cancel = true;
}
}
•
}
Delphi
procedure fg_ValidateEdit(sender: System.Object;
e: ValidateEditEventArgs);
var
dec: Decimal;
begin
// validate amounts
if fg.Cols(e.Col).DataType Is Decimal then
Try
dec := System.Decimal.Parse(fg.Editor.Text());
If (dec < 1000) Or (dec > 10000) Then
begin
MessageBox.Show('Value must be between 1,000 and 10,000');
e.Cancel := True;
end;
except
MessageBox.Show('Value not recognized as a Currency');
e.Cancel = True;
end;
end;
If you want to validate keys as they are typed into the editor, use the KeyPressEdit or the ChangeEdit
events. For more details on in-cell editing, see the Editing Cells (page 34 ) topic.
BeforeMouseDownEventHandler Delegate · 261
C1FlexGrid Event Handlers
BeforeMouseDownEventHandler Delegate
Syntax
[VB]
Public Delegate Sub BeforeMouseDownEventHandler (object sender, BeforeMouseDownEventArgs e)
[C#]
public delegate BeforeMouseDownEventHandler : MulticastDelegate
[Delphi]
type BeforeMouseDownEventHandler = procedure(sender: System.Object, e:
BeforeMouseDownEventArgs) of object;
Arguments
Argument
Description
sender
The source of the event.
e
A BeforeMouseDownEventArgs object that contains the event data.
See Also
BeforeMouseDown Event (page 225)
DragRowColEventHandler Delegate
Syntax
[VB]
Public Delegate Sub DragRowColEventHandler (object sender, DragRowColEventArgs e)
[C#]
public sealed delegate DragRowColEventHandler : System.MulticastDelegate
[Delphi]
type DragRowColEventHandler = procedure(sender: System.Object, e: DragRowColEventArgs) of
object;
Arguments
Argument
Description
sender
The source of the event.
e
A DragRowColEventArgs object that contains the event data.
262 · C1FlexGrid Reference
See Also
AfterDragColumn Event (page 208)
AfterDragRow Event (page 208)
BeforeDragColumn Event (page 221)
BeforeDragRow Event (page 222)
GridChangedEventHandler Delegate
Syntax
[VB]
Public Delegate Sub GridChangedEventHander (object sender, GridChangedEventArgs e)
[C#]
public sealed delegate GridChangedEventHandler : System.MulticastDelegate
[Delphi]
type GridChangedEventHander = procedure(sender: System.Object, e: GridChangedEventArgs) of
object;
Arguments
Argument
Description
sender
The source of the event.
e
A GridChangedEventArgs object that contains the event data.
See Also
GridChanged Event (page 243)
GridErrorEventHandler Delegate
Syntax
[VB]
Public Delegate Sub GridErrorEventHander (object sender, GridErrorEventArgs e)
[C#]
public sealed delegate GridErrorEventHandler : System.MulticastDelegate
[Delphi]
type GridErrorEventHandler = procedure(sender: System.Object, e: GridErrorEventArgs) of object;
KeyEditEventHandler Delegate · 263
Arguments
Argument
Description
sender
The source of the event.
e
A GridErrorEventArgs object that contains the event data.
See Also
GridError Event (page 244)
KeyEditEventHandler Delegate
Syntax
[VB]
Public Delegate Sub KeyEditEventHandler (object sender, KeyEditEventHandler e)
[C#]
public sealed delegate KeyEditEventHandler : System.MulticastDelegate
[Delphi]
type KeyEditEventHandler = procedure(sender: System.Object, e: KeyEditEventHandler) of object;
Arguments
Argument
Description
sender
The source of the event.
e
A KeyEditEventArgs object that contains the event data.
See Also
KeyDownEdit Event (page 245)
KeyUpEdit Event (page 247)
KeyPressEditEventHandler Delegate
Syntax
[VB]
Public Delegate Sub KeyPressEditEventHandler (object sender, KeyPressEditEventArgs e)
[C#]
public sealed delegate KeyPressEditEventHandler : System.MulticastDelegate
264 · C1FlexGrid Reference
[Delphi]
type KeyPressEditEventHandler = procedure(sender: System.Object, e: KeyPressEditEventArgs) of
object;
Arguments
Argument
Description
sender
The source of the event.
e
A KeyPressEditEventArgs object that contains the event data.
See Also
KeyPressEdit Event (page 246)
OwnerDrawCellEventHandler Delegate
Syntax
[VB]
Public Delegate Sub OwnerDrawCellEventHandler (object sender, OwnerDrawCellEventArgs e)
[C#]
public sealed delegate OwnerDrawCellEventHandler : System.MulticastDelegate
[Delphi]
type OwnerDrawCellEventHandler = procedure(sender: System.Object, e: OwnerDrawCellEventArgs)
of object;
Arguments
Argument
Description
sender
The source of the event.
e
A OwnerDrawCellEventArgs object that contains the event data.
See Also
OwnerDrawCell Event (page 249)
PrintEventHandler Delegate
Syntax
[VB]
Public Delegate Sub PrintEventHandler (object sender, PrintEventArgs e)
PrintPageEventHandler Delegate · 265
[C#]
public sealed delegate PrintEventHandler : System.MulticastDelegate
[Delphi]
type PrintEventHandler = procedure(sender: System.Object, e: PrintEventArgs) of object;
Arguments
Argument
Description
sender
The source of the event.
e
A PrintEventArgs object that contains the event data.
See Also
BeginPrint Event (page 233)
EndPrint Event (page 239)
PrintPageEventHandler Delegate
Syntax
[VB]
Public Delegate Sub PrintPageEventHandler (object sender, PrintPageEventArgs e)
[C#]
public sealed delegate PrintPageEventHandler : System.MulticastDelegate
[Delphi]
type PrintPageEventHandler = procedure(sender: System.Object, e: PrintPageEventArgs) of object;
Arguments
Argument
Description
sender
The source of the event.
e
A PrintPageEventArgs object that contains the event data.
See Also
PrintPage Event (page 252)
RangeEventHandler Delegate
Syntax
[VB]
Public Delegate Sub RangeEventHandler (object sender, RangeEventArgs e)
266 · C1FlexGrid Reference
[C#]
public sealed delegate RangeEventHandler : System.MulticastDelegate
[Delphi]
type RangeEventHandler = procedure(sender: System.Object, e: RangeEventArgs) of object;
Arguments
Argument
Description
sender
The source of the event.
e
A RangeEventArgs object that contains the event data.
See Also
AfterRowColChange Event (page 212)
AfterScroll Event (page 213)
AfterSelChange Event (page 215)
BeforeRowColChange Event (page 229)
BeforeScroll Event (page 230)
BeforeSelChange Event (page 232)
RowColEventHandler Delegate
Syntax
[VB]
Public Delegate Sub RowColEventHandler (object sender, RowColEventArgs e)
[C#]
public sealed delegate RowColEventHandler : System.MulticastDelegate
[Delphi]
type RowColEventHandler = procedure(sender: System.Object, e: RowColEventArgs) of object;
Arguments
Argument
Description
sender
The source of the event.
e
A RowColEventArgs object that contains the event data.
See Also
AfterEdit Event (page 209)
SortColEventHandler Delegate · 267
AfterResizeColumn Event (page 211)
AfterResizeRow Event (page 212)
BeforeEdit Event (page 223)
BeforePageBreak Event (page 227)
BeforeResizeColumn Event (page 228)
BeforeResizeRow Event (page 229)
BeforeScrollTip Event (page 231)
CellButtonClick Event (page 234)
ComboCloseUp Event (page 238)
ComboDropDown Event (page 239)
SetupEditor Event (page 255)
StartEdit Event (page 258)
SortColEventHandler Delegate
Syntax
[VB]
Public Delegate Sub SortColEventHandler (object sender, SortColEventArgs e)
[C#]
public sealed delegate SortColEventHandler : System.MulticastDelegate
[Delphi]
type SortColEventHandler = procedure(sender: System.Object, e: SortColEventArgs) of object;
Arguments
Argument
Description
sender
The source of the event.
e
A SortColEventArgs object that contains the event data.
See Also
AfterSort Event (page 215)
BeforeSort Event (page 233)
ValidateEditEventHandler Delegate
Syntax
[VB]
Public Delegate Sub ValidateEditEventHandler (object sender, ValidateEditEventArgs e)
268 · C1FlexGrid Reference
[C#]
public sealed delegate ValidateEditEventHandler : System.MulticastDelegate
[Delphi]
type ValidateEditEventHandler = procedure(sender: System.Object, e: ValidateEditEventArgs) of object;
Arguments
Argument
Description
sender
The source of the event.
e
A ValidateEditEventArgs object that contains the event data.
See Also
ValidateEdit Event (page 259)
C1FlexGrid Event Arguments
BeforeMouseDownEventArgs Class
Syntax
[VB]
Public Class BeforeMouseDownEventArgs
[C#]
public class BeforeMouseDownEventArgs : EventArgs
[Delphi]
type BeforeMouseDownEventArgs: class(EventArgs);
Members
Member
Description
MouseButtons Button
Gets which mouse button was pressed.
int Clicks, X, Y, Delta
Other information about the mouse action (same as the parameters in the
MouseDown event).
bool Cancel
Set this parameter to true to prevent the control from processing the mouse
message.
See Also
BeforeMouseDownEventHandler Delegate (page 261)
DragRowColEventArgs Class · 269
DragRowColEventArgs Class
Syntax
[VB]
Public Class DragRowColEventArgs
[C#]
public class DragRowColEventArgs : EventArgs
[Delphi]
type DragRowColEventArgs: class(EventArgs);
Members
Member
Description
int Col
The original index of the column that was dragged by the user.
int Row
The original index of the row that was dragged by the user.
int Position
The current index of the column that was dragged by the user.
bool Cancel
Cancels the current operation.
See Also
DragRowColEventHandler Delegate (page 261)
GridChangedEventArgs Class
Syntax
[VB]
Public Class GridChangedEventArgs
[C#]
public class GridChangedEventArgs : EventArgs
[Delphi]
type GridChangedEventArgs: class(EventArgs);
Members
Member
Description
int r1, c1, r2, c2
The range that was affected by the change.
GridChangedTypeEnum
GridChangedType
The type of change that caused the event to fire.
270 · C1FlexGrid Reference
See Also
GridChangedEventHandler Delegate (page 262)
GridErrorEventArgs Class
Syntax
[VB]
Public Class GridErrorEventArgs
[C#]
public class GridErrorEventArgs : EventArgs
[Delphi]
type GridErrorEventArgs: class(EventArgs);
Members
Member
Description
int Row, Col
The coordinates of the cell where the error was detected.
Exception Exception
A description of the error.
bool Handled
Whether the error was handled by the code or an exception should be thrown.
See Also
GridErrorEventHandler Delegate (page 262)
KeyEditEventArgs Class
Syntax
[VB]
Public Class KeyEditEventArgs
[C#]
public class KeyEditEventArgs : EventArgs
[Delphi]
type KeyEditEventArgs: class(EventArgs);
Members
Member
Description
int Row, Col
The coordinates of the cell being edited when the key was pressed.
int Col
The column in which the current cell is located.
int KeyValue
The integer representation of the KeyData property.
KeyPressEditEventArgs Class · 271
Member
Description
Keys KeyCode
The key code for the event, which will be one of the Keys values.
Keys KeyData
The key code for the key that was pressed, combined with modifier flags that
indicate which combination of CTRL, SHIFT, and ALT keys were pressed at the
same time.
Keys Modifiers
One or more modifier flags, as defined in Keys.
bool Shift
Specifies whether the shift key was pressed.
bool Alt
Specifies whether the alt key was pressed.
bool Control
Specifies whether the control key was pressed.
Handled
Specifies whether the key press was handled.
See Also
KeyEditEventHandler Delegate (page 263)
KeyPressEditEventArgs Class
Syntax
[VB]
Public Class KeyPressEditEventArgs
[C#]
public class KeyPressEditEventArgs : EventArgs
[Delphi]
type KeyPressEditEventArgs: class(EventArgs);
Members
Member
Description
int Row, Col
The coordinates of the cell being edited.
char KeyChar
The character that corresponds to the key that was pressed.
bool Handled
Specifies whether the key press was handled.
See Also
KeyPressEditEventHandler Delegate (page 263)
OwnerDrawCellEventArgs Class
Syntax
[VB]
Public Class OwnerDrawCellEventArgs
272 · C1FlexGrid Reference
[C#]
public class OwnerDrawCellEventArgs : EventArgs
[Delphi]
type OwnerDrawCellEventArgs: class(EventArgs);
Members
Member
Description
int Row, Col
Get the coordinates of the cell being painted.
Graphics Graphics
Gets the Graphics surface used to draw the cell.
Rectangle Bounds
Get the rectangle where the cell should be drawn.
string Text
Gets or sets the text that will be displayed in the cell.
Image Image
Gets or sets the image that will be displayed in the cell.
CellStyle Style
Sets or sets the CellStyle object used to paint the cell.
void DrawCell(DrawCellFlags
flags)
Causes the grid to paint parts of the cell (background, foreground,
border, etc.)
void DrawCell()
Causes the grid to paint the whole cell.
bool Handled
Gets or sets whether the event has finished drawing the cell.
bool Measuring
Gets a value that determines if the event was fired only to measure
the cell. This occurs while autosizing rows or columns.
Remarks
The user can modify the contents that will be displayed, the style to use, or use the provided Graphics
object to draw custom content into the cell.
See Also
OwnerDrawCellEventHandler Delegate (page 264)
RangeEventArgs Class
Syntax
[VB]
Public Class RangeEventArgs
[C#]
public class RangeEventArgs : EventArgs
[Delphi]
type RangeEventArgs: class(EventArgs);
RowColEventArgs Class · 273
Members
Member
Description
CellRange OldRange
The selection before the event.
CellRange NewRange
The current selection.
bool Cancel
A boolean that when set to true cancels the pending operation.
See Also
RangeEventHandler Delegate (page 265)
RowColEventArgs Class
Syntax
[VB]
Public Class RowColEventArgs
[C#]
public class RowColEventArgs : EventArgs
[Delphi]
type RowColEventArgs: class(EventArgs);
Members
Member
Description
int Row, Col
The coordinates of the cell that an action was performed upon.
bool Cancel
A boolean that when set to true cancels the pending operation.
See Also
RowColEventHandler Delegate (page 266)
SortColEventArgs Class
Syntax
[VB]
Public Class SortColEventArgs
[C#]
public class SortColEventArgs : EventArgs
[Delphi]
type SortColEventArgs: class(EventArgs);
274 · C1FlexGrid Reference
Members
Member
Description
int Col
The column that is being sorted.
SortFlags Order
The sorting order.
bool Cancel
Cancel the sorting operation.
Setting this parameter to true in the BeforeSort event cancels the built-in
sort operation and leaves the sorting glyph unchanged.
bool Handled
Sort was handled by the event handler.
Setting this parameter to true in the BeforeSort event cancels the built-in
sort but updates the sorting glyph as if the sort had been performed. This
is useful in case you want to provide custom sorting.
See Also
SortColEventHandler Delegate (page 267)
ValidateEditEventArgs Class
Syntax
[VB]
Public Class ValidateEditEventArgs
[C#]
public class ValidateEditEventArgs : EventArgs
[Delphi]
type ValidateEditEventArgs: class(EventArgs);
Members
Public Readonly Integer Row, Col
Public Readonly CheckEnum Checkbox
Public Boolean Cancel
Property
Description
int Row
The row in which the current cell is located.
int Col
The column in which the current cell is located.
CheckEnum Checkbox
If the cell contains a checkbox, the new checkbox state about to be applied to
the cell.
bool Cancel
Specifies whether the start of the editing is to be cancelled.
See Also
ValidateEditEventHandler Delegate (page 267)
CellRange Struct · 275
CellRange Struct
The CellRange object provides access to properties of cell ranges. To obtain a CellRange object, use the
C1FlexGrid's GetCellRange method.
For example, the code below sets the style of a group of cells.
•
Visual Basic
' create new custom cell style
Dim st As CellStyle = flex.Styles.Add("MyStyle")
st.Font = New Font("Tahoma", 14)
' assign new style to a group of cells
Dim rg As CellRange = flex.GetCellRange(1, 1, 10, 10)
rg.Style = st
•
C#
// create new custom cell style
CellStyle st = flex.Styles.Add("MyStyle");
st.Font = new Font("Tahoma", 14);
// assign new style to a group of cells
CellRange rg = flex.GetCellRange(1,1,10,10);
rg.Style = st;
•
Delphi
var
rg: CellRange;
st: CellStyle;
begin
st := flex.Styles.Add('MyStyle');
st.Font := Font.Create('Tahoma', 14);
// assign new style to a group of cells
rg := flex.GetCellRange(1, 1, 10, 10);
rg.Style := st;
end;
Note that the CellRange object is a struct, not a class. This means the object is used as a value, not as a
reference. If you pass a CellRange to a method and change the object within that method, the original
value is not modified.
All CellRange Members
CellRange Struct Public Properties
BottomRow
Supported by the .NET Compact Framework.
Returns the index of the bottom row in this range
(greater of r1 and r2).
CheckBox
Supported by the .NET Compact Framework.
Gets or sets the state of the checkbox in this range.
Clip
Supported by the .NET Compact Framework.
Gets or sets the contents of this range, represented
as a string.
Data
Supported by the .NET Compact Framework.
Gets or sets the raw contents of this range.
276 · C1FlexGrid Reference
DataDisplay
Supported by the .NET Compact Framework.
Gets the content of the cell in (r1,c1).
Image
Supported by the .NET Compact Framework.
Gets or sets the image displayed in this range.
IsSingleCell
Determines whether this range contains a single cell
(r1 == r2 and c1 == c2).
IsValid
Determines whether this CellRange object describes
a valid range.
LeftCol
Supported by the .NET Compact Framework.
Returns the index of the left column in the range
(smaller of c1 and c2).
r1c1r2c2
Supported by the .NET Compact Framework.
Index of the cells that define the range (not
necessarily in order, see Normalize method).
RightCol
Supported by the .NET Compact Framework.
Returns the index of the right column in the range
(greater of c1 and c2).
Style
Supported by the .NET Compact Framework.
Gets or sets a custom cell style for the range.
StyleDisplay
Supported by the .NET Compact Framework.
Gets the cell style used to display the range.
StyleNew
Supported by the .NET Compact Framework.
Gets the custom cell style used to display the range,
creates a new style if necessary.
TopRow
Supported by the .NET Compact Framework.
Returns the index of the top row in the range (smaller
of r1 and r2).
UserData
Supported by the .NET Compact Framework.
Gets or sets arbitrary data associated with cells in the
range.
CellRange Struct Public Methods
Contains
Supported by the .NET Compact Framework.
Determines if the specified cell is contained in this
CellRange.
ContainsCol
Supported by the .NET Compact Framework.
Determines if the specified column is contained in this
CellRange.
ContainsRow
Supported by the .NET Compact Framework.
Determines if the specified row is contained in this
CellRange.
Normalize
Supported by the .NET Compact Framework.
Ensures that r1 = TopRow, r2 = BottomRow, c1 =
LeftCol, c2 = RightCol.
CellRange Properties
BottomRow Property (CellRange)
Returns the index of the bottom row in this range (greater of r1 and r2).
CheckBox Property · 277
Syntax
[VB]
Public BottomRow As Integer
[C#]
public int BottomRow {get;}
[Delphi]
property BottomRow: Integer;
See Also
CellRange Struct (page 275)
CheckBox Property
Gets or sets the state of the checkbox in this range.
Syntax
[VB]
Public Checkbox As CheckEnum
[C#]
public CheckEnum Checkbox {get; set;}
[Delphi]
property CheckBox: CheckEnum;
Remarks
This property returns the checkbox state for the first cell of the range (r1, c1), and sets the checkbox state
for the entire range.
See Also
CellRange Struct (page 275)
Clip Property (CellRange)
Gets or sets the data in this range, represented as a string.
Syntax
[VB]
Public Clip As String
[C#]
public string Clip {get; set;}
[Delphi]
property Clip: string;
278 · C1FlexGrid Reference
Remarks
The string assigned to (or returned by) the Clip property may contain multiple cells. By default, tab
characters (\t) indicate column breaks, and carriage return characters (\n) indicate row breaks.
The default row and column delimiters may be changed using the ClipSeparators property.
See Also
CellRange Struct (page 275)
Data Property (CellRange)
Gets or sets the data in this range.
Syntax
[VB]
Public Data As Object
[C#]
public object Data {get; set;}
[Delphi]
property Data: Object;
Remarks
This property returns the data in the first cell of the range (r1, c1), and sets the data for the entire range.
See Also
CellRange Struct (page 275)
DataDisplay Property
Gets the data in the first cell of the range, formatted as a string.
Syntax
[VB]
Public DataDisplay As String
[C#]
public string DataDisplay {get;}
[Delphi]
property DataDisplay: string;
Remarks
This property is similar to the Clip property, except Clip returns a delimited string containing data for
the entire range, and DataDisplay returns the contents of the first cell only (r1, c1).
See Also
CellRange Struct (page 275)
Image Property · 279
Image Property
Gets or sets the image displayed in this range.
Syntax
[VB]
Public Image As Image
[C#]
public Image Image {get; set;}
[Delphi]
property Image: Image;
Remarks
This property returns the image assigned to the first cell of the range (r1, c1), and sets the image for all
cells in the range.
See Also
CellRange Struct (page 275)
IsSingleCell Property
Determines whether this range contains a single cell (r1 == r2 and c1 == c2).
Syntax
[VB]
Public IsSingleCell As Boolean
[C#]
public bool IsSingleCell {get; }
[Delphi]
property IsSingleCell: Boolean;
See Also
CellRange Struct (page 275)
IsValid Property
Determines whether this CellRange object describes a valid range.
Syntax
[VB]
Public IsValid As Boolean
[C#]
public bool IsValid {get; }
280 · C1FlexGrid Reference
[Delphi]
property IsValid: Boolean;
Remarks
This property returns true if the range coordinates are valid (r1 and r2 between 0 and Count -1; c1 and c2
between 0 and Count – 1).
See Also
CellRange Struct (page 275)
LeftCol Property (CellRange)
Returns the index of the left column in the range (smaller of c1 and c2).
Syntax
[VB]
Public LeftCol As Integer
[C#]
public int LeftCol {get;}
[Delphi]
property LeftCol: Integer;
See Also
CellRange Struct (page 275)
r1,c1,r2,c2 Property
Index of the cells that define the range (not necessarily in order, see Normalize method).
Syntax
[VB]
Public r1, c1, r2, c2 As Integer
[C#]
Public int r1, c1, r2, c2; { get; set; }
[Delphi]
property r1, c1, r2, c2: Integer;
See Also
CellRange Struct (page 275)
RightCol Property (CellRange)
Returns the index of the right column in the range (greater of c1 and c2).
Style Property (CellRange) · 281
Syntax
[VB]
Public RightCol As Integer
[C#]
public int RightCol {get;}
[Delphi]
property RightCol: Integer;
See Also
CellRange Struct (page 275)
Style Property (CellRange)
Gets or sets a custom cell style for the range.
Syntax
[VB]
Public Style As CellStyle
[C#]
public CellStyle Style {get; set;}
[Delphi]
property Style: CellStyle;
Remarks
When getting, returns the custom style for cell (r1, c1). If the cell has no custom style, returns null. When
setting, assigns the new value to all cells in the range.
See Also
CellRange Struct (page 275)
StyleDisplay Property (CellRange)
Gets the cell style used to display the range.
Syntax
[VB]
Public StyleDisplay As CellStyle
[C#]
public CellStyle StyleDisplay {get;}
[Delphi]
property StyleDisplay: CellStyle;
282 · C1FlexGrid Reference
Remarks
When getting, returns a CellStyle object containing the style that will be used to render the cell. If the cell
has a custom style associated with it, StyleDisplay will return that style; otherwise it will return the
appropriate stock style (e.g., Normal style, Fixed style, etc.).
See Also
CellRange Struct (page 275)
StyleNew Property (CellRange)
Gets the custom cell style used to display the range, creates a new style if necessary.
Syntax
[VB]
Public StyleNew As CellStyle
[C#]
public CellStyle StyleNew {get;}
[Delphi]
property StyleNew: CellStyle;
Remarks
If cell (r1,c1) has a custom style, this property will return that style. If the cell does not have a custom
style, StyleNew will create one and assign it to the whole range.
See Also
CellRange Struct (page 275)
TopRow Property (CellRange)
Returns the index of the top row in the range (smaller of r1 and r2).
Syntax
[VB]
Public TopRow As Integer
[C#]
public int TopRow {get;}
[Delphi]
property TopRow: Integer;
See Also
CellRange Struct (page 275)
UserData Property (CellRange)
Gets or sets user data associated with cells in the range.
Contains Method (CellRange) · 283
Syntax
[VB]
Public UserData As Object
[C#]
public object UserData {get; set;}
[Delphi]
property UserData: Object;
Remarks
When getting, returns the data value associated with the first cell in the range (r1,c1). When setting,
assigns the new value to all cells in the range.
See Also
CellRange Struct (page 275)
CellRange Methods
Contains Method (CellRange)
Determines if the specified cell is contained in this CellRange.
Syntax
[VB]
Public Function Contains(row As Integer, col As Integer) As Boolean
[C#]
public Boolean Contains ( int row , int col )
[Delphi]
function Contains(row: Integer; col: Integer): Boolean;
Parameter
Description
row, col
The coordinates of the cell to test.
Return Value
Boolean. Returns true if the cell at (row, col) is contained in the CellRange, false otherwise.
See Also
CellRange Struct (page 275)
ContainsCol Method
Determines if the specified column is contained in this CellRange.
284 · C1FlexGrid Reference
Syntax
[VB]
Public Function ContainsCol(col As Integer) As Boolean
[C#]
public Boolean ContainsCol ( int col )
[Delphi]
function ContainsCol(col: Integer): Boolean;
Parameter
Description
col
The index of the column to test.
Return Value
Boolean. Returns true if the column is contained in the CellRange, false otherwise.
See Also
CellRange Struct (page 275)
ContainsRow Method
Determines if the specified row is contained in this CellRange.
Syntax
[VB]
Public Function ContainsRow(row As Integer) As Boolean
[C#]
public Boolean ContainsRow ( int row )
[Delphi]
function ContainsRow(row: Integer): Boolean;
Parameter
Description
row
The index of the row to test.
Return Value
Boolean. Returns true if the row is contained in the CellRange, false otherwise.
See Also
CellRange Struct (page 275)
Normalize Method · 285
Normalize Method
Normalizes the range to ensure that r1 <= r2 and c1 <= c2.
Syntax
[VB]
Public Sub Normalize()
[C#]
public void Normalize ( )
[Delphi]
procedure Normalize;
See Also
CellRange Struct (page 275)
HitTestInfo class
All HitTestInfo Members
HitTestInfo Struct Public Properties
X, Y
Get the coordinates of the point being tested.
Row, Column
Get the index of the row and column at the point being tested (if
the point does not correspond to a cell, these properties return -1).
Type
Gets the type of element at the point being tested (e.g., cell,
resizing area, empty area).
HitTestInfo Properties
Column Property (HitTestInfo)
Gets the column at the point being tested (or -1 if the point is in the control's empty area).
Syntax
[VB]
Public Column As Integer
[C#]
public int Column {get;}
[Delphi]
property Column: Integer;
See Also
HitTestInfo class (page 285)
286 · C1FlexGrid Reference
Row Property (HitTestInfo)
Gets the row at the point being tested (or -1 if the point is in the control's empty area).
Syntax
[VB]
Public Row As Integer
[C#]
public int Row {get;}
[Delphi]
property Row: Integer;
See Also
HitTestInfo class (page 285)
Type Property (HitTestInfo)
Gets the type of grid element at the point being tested.
Syntax
[VB]
Public Type As HitTestTypeEnum
[C#]
public HitTestTypeEnum Type {get;}
[Delphi]
property Type: HitTestTypeEnum;
Remarks
This property allows you to determine whether the point corresponds to a grid cell or to a special element
such as the row and column resizing zones,
See Also
HitTestInfo class (page 285)
X Property (HitTestInfo)
Gets the x coordinate of the point being tested.
Syntax
[VB]
Public X As Integer
[C#]
public int X {get;}
Y Property (HitTestInfo) · 287
[Delphi]
property X: Integer;
See Also
HitTestInfo class (page 285)
Y Property (HitTestInfo)
Gets the y coordinate of the point being tested.
Syntax
[VB]
Public Y As Integer
[C#]
public int Y {get;}
[Delphi]
property Y: Integer;
See Also
HitTestInfo class (page 285)
RowCollection class
All RowCollection Members
RowCollection Class Public Properties
Count
Gets or sets the number of rows in the collection.
DefaultSize
Gets or sets the default height for the rows in the
collection.
Fixed
Gets or sets the number of fixed rows in the
collection.
Frozen
Gets or sets the number of frozen rows in the
collection.
Item
Gets the Row at the specified index.
MaxSize
Gets or sets the maximum display height for a row.
MinSize
Gets or sets the minimum display height for a row.
Selected
Supported by the .NET Compact Framework.
Gets a collection of rows that are currently selected.
288 · C1FlexGrid Reference
RowCollection Class Public Methods
Add
Supported by the .NET Compact Framework.
Adds a row to the collection.
Contains
Determines whether the collection contains a given
row.
Insert
Supported by the .NET Compact Framework.
Adds a row to the collection at a specified position.
InsertNode
Inserts a new node row in the row collection.
InsertRange
Supported by the .NET Compact Framework.
Adds a range of rows to the collection at a specified
position.
Move
Moves a row to a new position in the collection.
MoveRange
Moves a range of rows to a new position in the
collection.
Remove
Supported by the .NET Compact Framework.
Removes a row from the collection.
RemoveRange
Supported by the .NET Compact Framework.
Removes a range of rows from the collection.
RowCollection Properties
Count Property (RowCollection)
Gets or sets the number of rows in the collection.
Syntax
[VB]
Public Count As Integer
[C#]
public int Count {get; set;}
[Delphi]
property Count: Integer;
Remarks
You can add or remove rows by assigning a new value to this property, or you can use the Add, Insert,
InsertRange, and Remove methods.
See Also
RowCollection class (page 287)
DefaultSize Property (RowCollection)
Gets or sets the default height for the rows in the collection.
Fixed Property (RowCollection) · 289
Syntax
[VB]
Public DefaultSize As Integer
[C#]
public int DefaultSize {get; set;}
[Delphi]
property DefaultSize: Integer;
Remarks
The default height is used when the Row.Height property has the value -1.
When you assign a new value to the grid's Font property, the DefaultSize property is automatically
adjusted to fit the new font.
See Also
RowCollection class (page 287)
Fixed Property (RowCollection)
Gets or sets the number of fixed rows in the collection.
Syntax
[VB]
Public Fixed As Integer
[C#]
public int Fixed {get; set;}
[Delphi]
property Fixed: Integer;
See Also
RowCollection class (page 287)
Frozen Property (RowCollection)
Gets or sets the number of frozen rows in the collection.
Syntax
[VB]
Public Frozen As Integer
[C#]
public int Frozen {get; set;}
[Delphi]
property Frozen: Integer;
290 · C1FlexGrid Reference
Remarks
Use the AllowFreezing property to determine whether the user can freeze rows with the mouse.
See Also
RowCollection class (page 287)
Item Property (RowCollection)
Gets the Row at the specified index.
Syntax
[VB]
Public Item As Row
[C#]
public Row this[int index] {get;}
[Delphi]
property Item: Row;
Remarks
You can use the Row object returned by this method to set attributes such as row height, visibility, style,
selected state, etc.
See Also
RowCollection class (page 287)
MaxSize Property (RowCollection)
Gets or sets the maximum display height for a row.
Syntax
[VB]
Public MaxSize As Integer
[C#]
public int MaxSize {get; set;}
[Delphi]
property MaxSize: Integer;
Remarks
The MaxSize property limits the size of rows when they are resized by the user or adjusted to fit the
contents with the AutoSizeRows method.
Setting this property to zero disables it.
See Also
RowCollection class (page 287)
MinSize Property (RowCollection) · 291
MinSize Property (RowCollection)
Gets or sets the minimum display height for a row.
Syntax
[VB]
Public MinSize As Integer
[C#]
public int MinSize {get; set;}
[Delphi]
property MinSize: Integer;
Remarks
The MinSize property limits the minimum size of rows when they are resized by the user or adjusted to
fit the contents with the AutoSizeRows method.
See Also
RowCollection class (page 287)
Selected Property (RowCollection)
Gets a collection of rows that are currently selected.
Syntax
[VB]
Public Selected As RowCollection
[C#]
public RowCollection Selected
[Delphi]
property Selected: RowCollection;
Remarks
This property is useful when the grid is used in listbox mode. For example, the code below returns
information about the currently selected rows:
•
Visual Basic
fg.SelectionMode = SelectionModeEnum.ListBox
Dim r As Row
For Each r In fg.Rows.Selected
Console.WriteLine(r.Index)
Next
•
C#
fg.SelectionMode = SelectionModeEnum.ListBox;
foreach (Row row in fg.Rows.Selection)
Console.WriteLine(row.Index);
292 · C1FlexGrid Reference
•
Delphi
var
r: Row;
i: Integer;
begin
fg.SelectionMode := SelectionModeEnum.ListBox;
for I := 0 to fg.Rows.Count do
begin
r := fg.Rows[i];
Console.WriteLine(r.Index);
end;
end;
See Also
RowCollection class (page 287)
RowCollection Methods
Add Method (RowCollection)
Adds a row to the collection.
Syntax
[VB]
Public Function Add() As Row
[C#]
public Row Add ( )
[Delphi]
property Add: Row;
Return Value
A reference to the Row that was added to the collection.
Remarks
The Add method appends a new row to the collection. To insert a row at a specific position, use the Insert
method.
See Also
RowCollection class (page 287)
Contains Method (RowCollection)
Determines whether the collection contains a given row.
Syntax
[VB]
Public Function Contains(item As RowCol) As Boolean
Insert Method (RowCollection) · 293
[C#]
public Boolean Contains (RowCol item )
[Delphi]
function Contains(item: RowCol): Boolean;
Parameter
Description
row
The Row object to test.
Return Value
Boolean. Returns true if the row is a member of the collection. Returns false otherwise.
See Also
RowCollection class (page 287)
Insert Method (RowCollection)
Adds a row to the collection at a specified position.
Syntax
[VB]
Public Function Insert(index As Integer) As Row
[C#]
public Row Insert ( int index )
[Delphi]
function Insert (index: Integer): Row;
Parameter
Description
index
The position where the new row will be inserted.
Return Value
A reference to the Row that was added to the collection.
See Also
RowCollection class (page 287)
InsertNode Method
Inserts a new node row in the row collection.
294 · C1FlexGrid Reference
Syntax
[VB]
Public Function InsertNode(index As Integer, level As Integer) As Node
[C#]
public Node InsertNode ( int index , int level )
[Delphi]
function InsertNode (index: Integer; level: Integer): Node;
Return Value
A reference to the Node that was added to the collection.
Remarks
This method is especially useful when the grid is bound to a data source, because in this case you cannot
change the value of the Row.IsNode property. When the grid is unbound, you can add rows and turn
them into nodes later using the Row.IsNode property.
See Also
RowCollection class (page 287)
InsertRange Method (RowCollection)
Adds a range of rows to the collection at a specified position.
Syntax
[VB]
Public Sub InsertRange(index As Integer, count As Integer)
[C#]
public void InsertRange ( int index , int count )
[Delphi]
procedure InsertRange (index: Integer; count: Integer);
Parameter
Description
index
The position where the new range will be inserted.
count
The number of rows to add.
See Also
RowCollection class (page 287)
Move Method (RowCollection)
Moves a row to a new position in the collection.
MoveRange Method (RowCollection) · 295
Syntax
[VB]
Public Sub Move(indexOld As Integer, indexNew As Integer)
[C#]
public void Move ( int indexOld , int indexNew )
[Delphi]
procedure Move (indexOld: Integer; indexNew: Integer);
Parameter
Description
oldindex
The current index of the row that will be moved.
newindex
The new index for the row.
See Also
RowCollection class (page 287)
MoveRange Method (RowCollection)
Moves a range of rows to a new position in the collection.
Syntax
[VB]
Public Sub MoveRange(index As Integer, count As Integer, indexNew As Integer)
[C#]
public void MoveRange ( int index , int count , int indexNew )
[Delphi]
procedure MoveRange (index: Integer, count: Integer, indexNew: Integer);
Parameter
Description
oldindex
The index of the first row in the range that will be moved.
count
The number of rows that will be moved.
newindex
The new index for the first row in the range.
See Also
RowCollection class (page 287)
296 · C1FlexGrid Reference
Remove Method (RowCollection)
Removes a row from the collection.
Syntax
[VB]
Public Function Remove(index As Integer) As Row
[C#]
public Row Remove ( int index )
[Delphi]
function Remove(index: Integer): Row;
Parameter
Description
index
The index of the row to remove from the collection.
Return Value
A reference to the Row that was removed from the collection.
See Also
RowCollection class (page 287)
RemoveRange Method (RowCollection)
Removes a range of rows from the collection.
Syntax
[VB]
Public Sub RemoveRange(index As Integer, count As Integer)
[C#]
public void RemoveRange ( int index , int count )
[Delphi]
procedure RemoveRange(index: Integer; count: Integer);
Parameter
Description
index
The index of the first row to remove from the collection.
count
The number of rows to remove from the collection.
See Also
RowCollection class (page 287)
ColumnCollection class · 297
ColumnCollection class
All ColumnCollection Members
ColumnCollection Class Public Properties
Count
Gets or sets the number of columns in the collection.
DefaultSize
Gets or sets the default width for the columns in the
collection.
Fixed
Gets or sets the number of fixed columns in the
collection.
Frozen
Gets or sets the number of frozen columns in the
collection.
Item
Gets the Column at the specified index.
MaxSize
Gets or sets the maximum display width for a column.
MinSize
Gets or sets the minimum display width for a column.
Selected
Supported by the .NET Compact Framework.
Gets the collection of columns that are currently
selected.
ColumnCollection Class Public Methods
Add
Supported by the .NET Compact Framework.
Adds a column to the collection.
ContainsCol
Determines whether the collection contains a given
column.
Insert
Supported by the .NET Compact Framework.
Adds a column to the collection at a specified position.
InsertRange
Supported by the .NET Compact Framework.
Adds a range of columns to the collection at a specified
position.
Move
Moves a column to a new position in the collection.
MoveRange
Moves a range of columns to a new position in the
collection.
Remove
Supported by the .NET Compact Framework.
Removes a column from the collection.
RemoveRange
Supported by the .NET Compact Framework.
Removes a range of columns from the collection.
298 · C1FlexGrid Reference
ColumnCollection Properties
Count Property (ColumnCollection)
Gets or sets the number of columns in the collection.
Syntax
[VB]
Public Count As Integer
[C#]
public int Count {get; set;}
[Delphi]
property Count: Integer;
Remarks
You can add or remove columns by assigning a new value to this property, or you can use the Add,
Insert, InsertRange, and Remove methods.
See Also
ColumnCollection class (page 297)
DefaultSize Property (ColumnCollection)
Gets or sets the default width for the columns in the collection.
Syntax
[VB]
Public DefaultSize As Integer
[C#]
public int DefaultSize {get; set;}
[Delphi]
property DefaultSize: Integer;
Remarks
The default height is used when the Column.Width property has the value -1.
When you assign a new value to the grid's Font property, the DefaultSize property is automatically
adjusted to fit the new font.
See Also
ColumnCollection class (page 297)
Fixed Property (ColumnCollection)
Gets or sets the number of fixed columns in the collection.
Frozen Property (ColumnCollection) · 299
Syntax
[VB]
Public Fixed As Integer
[C#]
public int Fixed {get; set;}
[Delphi]
property Fixed: Integer;
See Also
ColumnCollection class (page 297)
Frozen Property (ColumnCollection)
Gets or sets the number of frozen columns in the collection.
Syntax
[VB]
Public Frozen As Integer
[C#]
public int Frozen {get; set;}
[Delphi]
property Frozen: Integer;
Remarks
Use the AllowFreezing property to determine whether the user can freeze columns with the mouse.
See Also
ColumnCollection class (page 297)
Item Property (ColumnCollection)
Gets the Column at the specified index.
Syntax
[VB]
Public Item[int index] As Column
[C#]
public Column this[int index] {get; }
public Column this[string name] {get; }
[Delphi]
property Item: Column;
300 · C1FlexGrid Reference
Remarks
You can use the Column object returned by this method to set attributes such as row height, visibility,
style, selected state, etc.
The string indexer looks for a column with the specified Name. The column name is set automatically for
you when the grid is bound to a database, or it may be set using code. For example:
•
Visual Basic
' set the column name
flex.Cols(2).Name = "bools" '
flex.Cols(2).DataType = GetType(Boolean) '
' show boolean column as text
flex.Cols("bools").Format = "Yes;No" '
•
C#
// set the column name
flex.Cols[2].Name = "bools";
flex.Cols[2].DataType = typeof(bool);
// show boolean column as text
flex.Cols["bools"].Format = "Yes;No";
•
Delphi
// set the column name
flex.Cols[2].Name := 'bools';
flex.Cols[2].DataType := TypeOf(Boolean);
// show boolean column as text
flex.Cols['bools'].Format := 'Yes;No';
See Also
ColumnCollection class (page 297)
MaxSize Property (ColumnCollection)
Gets or sets the maximum display width for a column.
Syntax
[VB]
Public MaxSize As Integer
[C#]
public int MaxSize {get; set;}
[Delphi]
property MaxSize: Integer;
Remarks
The MaxSize property limits the size of columns when they are resized by the user or adjusted to fit the
contents with the AutoSizeCols method.
Setting this property to zero disables it.
MinSize Property (ColumnCollection) · 301
See Also
ColumnCollection class (page 297)
MinSize Property (ColumnCollection)
Gets or sets the minimum display width for a column.
Syntax
[VB]
Public MinSize As Integer
[C#]
public int MinSize {get; set;}
[Delphi]
property MinSize: Integer;
Remarks
The MinSize property limits the minimum size of columns when they are resized by the user or adjusted
to fit the contents with the AutoSizeCols method.
See Also
ColumnCollection class (page 297)
Selected Property
Gets the collection of columns that are currently selected.
Syntax
[VB]
Public Selected As ColumnCollection
[C#]
public ColumnCollection Selected {get;}
[Delphi]
property Selected: ColumnCollection;
See Also
ColumnCollection class (page 297)
ColumnCollection Methods
Add Method (ColumnCollection)
Adds a column to the collection.
302 · C1FlexGrid Reference
Syntax
[VB]
Public Function Add() As Column
[C#]
public Column Add ( )
[Delphi]
function Add: Column;
Return Value
A reference to the Column that was added to the collection.
Remarks
The Add method appends a new column to the collection. To insert a column at a specific position, use
the Insert method.
See Also
ColumnCollection class (page 297)
Contains Method (ColumnCollection)
Determines whether the collection contains a given column.
Syntax
[VB]
Public Function Contains(columnName As String) As Boolean
[C#]
public Boolean Contains (String columnName )
[Delphi]
function Contains(columnName: string): Boolean;
Parameter
Description
col
The Column object to test.
Return Value
Returns true if the row is a member of the collection. Returns false otherwise.
See Also
ColumnCollection class (page 297)
Insert Method (ColumnCollection) · 303
Insert Method (ColumnCollection)
Adds a column to the collection at a specified position.
Syntax
[VB]
Public Function Insert(index As Integer) As Column
[C#]
public Column Insert ( int index )
[Delphi]
function Insert(index: Integer): Column;
Parameter
Description
index
The Position where the column will be inserted.
Return Value
A reference to the Column that was added to the collection.
See Also
ColumnCollection class (page 297)
InsertRange Method (ColumnCollection)
Adds a range of columns to the collection at a specified position.
Syntax
[VB]
Public Sub InsertRange(index As Integer, count As Integer)
[C#]
public void InsertRange ( int index , int count )
[Delphi]
procedure InsertRange (index: Integer; count: Integer);
Parameter
Description
index
The Position where the new range will be inserted.
count
The number of columns to add.
See Also
ColumnCollection class (page 297)
304 · C1FlexGrid Reference
Move Method (ColumnCollection)
Moves a column to a new position in the collection.
Syntax
[VB]
Public Sub Move(indexOld As Integer, indexNew As Integer)
[C#]
public void Move ( int indexOld , int indexNew )
[Delphi]
procedure Move (indexOld: Integer; IndexNew: Integer);
Parameter
Description
oldindex
The current index of the column that will be moved.
newIndex
The new index for the column.
See Also
ColumnCollection class (page 297)
MoveRange Method (ColumnCollection)
Moves a range of columns to a new position in the collection.
Syntax
[VB]
Public Sub MoveRange(index As Integer, count As Integer, indexNew As Integer)
[C#]
public void MoveRange ( int index , int count , int indexNew )
[Delphi]
procedure MoveRange(index: Integer; count: Integer, indexNew: Integer);
Parameter
Description
oldindex
The index of the first column in the range that will be moved.
count
The number of columns that will be moved.
newIndex
The new index for the first column in the range.
See Also
ColumnCollection class (page 297)
Remove Method (ColumnCollection) · 305
Remove Method (ColumnCollection)
Removes a column from the collection.
Syntax
[VB]
Public Function Remove(index As Integer) As Column
[C#]
public Column Remove ( int index )
[Delphi]
function Remove(index: Integer): Column;
Parameter
Description
index
The index of the column to remove from the collection.
Return Value
A reference to the Column that was removed from the collection.
See Also
ColumnCollection class (page 297)
RemoveRange Method (ColumnCollection)
Removes a range of columns from the collection.
Syntax
[VB]
Public Sub RemoveRange(index As Integer, count As Integer)
[C#]
public void RemoveRange ( int index , int count )
[Delphi]
procedure RemoveRange(index: Integer; count: Integer);
Parameter
Description
index
The index of the first column to remove from the collection.
count
The number of columns to remove from the collection.
See Also
ColumnCollection class (page 297)
306 · C1FlexGrid Reference
Row Class
All Row Members
Row Class Public Properties
AllowDragging
Gets or sets whether this row can be dragged with
the mouse.
AllowEditing
Gets or sets whether cells on this row can be edited
by the user.
AllowMerging
Gets or sets whether cells on this row can be merged
with neighboring cells.
AllowResizing
Gets or sets whether this row can be resized with the
mouse.
Bottom
Supported by the .NET Compact Framework.
Gets the position of the bottom of this row, in pixels,
relative to the grid (does not take scrolling into
account).
Caption
Gets or sets the text of the first fixed cell in the row.
DataIndex
Gets the position of the row in the data source
object.
DataSource
Gets the object that provides data for this row.
Editor
Gets or sets the custom editor used to edit cells in
this row.
Height
Supported by the .NET Compact Framework.
Gets or sets the height of this row, in pixels (returns
–1 is the row has the default height).
HeightDisplay
Supported by the .NET Compact Framework.
Gets or sets the display height for this row, in pixels.
ImageAlign
Gets or sets how images are aligned within scrollable
cells in this row.
ImageAlignFixed
Gets or sets how images are aligned within fixed
cells in this row.
Index
Gets the index of this row in the Rows collection.
IsNew
Indicates the row is a placeholder for adding new
rows to the grid.
IsNode
Supported by the .NET Compact Framework.
Gets or sets whether this row is a node row in an
outline.
Node
Supported by the .NET Compact Framework.
Returns a Node object.
SafeIndex
Gets the index of this row in the Rows collection.
Selected
Gets or sets whether this row is selected.
Style
Gets or sets the style used to display this row.
StyleDisplay
Gets the style used to display this row.
AllowDragging Property (Row) · 307
StyleNew
Gets the custom style associated with this row.
Top
Supported by the .NET Compact Framework.
Gets the position of the top of this row, in pixels,
relative to the grid (does not take scrolling into
account).
UserData
Gets or sets user data associated with this row.
Visible
Gets or sets the visibility of this row.
Row Class Public Methods
Clear
Supported by the .NET Compact Framework.
Clears this row.
Move
Moves a row to a new position in the collection.
Row Properties
AllowDragging Property (Row)
Gets or sets whether this row can be dragged with the mouse.
Syntax
[VB]
Public AllowDragging As Boolean
[C#]
public bool AllowDragging {get; set;}
[Delphi]
property AllowDragging: Boolean;
Remarks
The grid has an AllowDragging property that determines whether rows and columns can be dragged.
The AllowDragging property of the Row and Column objects is used to prevent the user from dragging
specific rows or columns.
See Also
Row Class (page 306)
AllowEditing Property (Row)
Gets or sets whether cells on this row can be edited by the user.
Syntax
[VB]
Public AllowEditing As Boolean
308 · C1FlexGrid Reference
[C#]
public bool AllowEditing {get; set;}
[Delphi]
property AllowEditing: Boolean;
Remarks
The grid has an AllowEditing property that determines whether cells can be edited. The AllowEditing
property of the Row and Column objects is used to prevent the user from editing cells in specific rows or
columns.
See Also
Row Class (page 306)
AllowMerging Property (Row)
Gets or sets whether cells on this row can be merged with neighboring cells.
Syntax
[VB]
Public AllowMerging As Boolean
[C#]
public bool AllowMerging {get; set;}
[Delphi]
property AllowMerging: Boolean;
Remarks
The grid has an AllowMerging property that determines whether cells can be merged. The
AllowMerging property of the Row and Column objects is used to allow cells in specific rows or
columns to be merged with adjacent cells.
See Also
Row Class (page 306)
AllowResizing Property (Row)
Gets or sets whether this row can be resized with the mouse.
Syntax
[VB]
Public AllowResizing As Boolean
[C#]
public bool AllowResizing {get; set;}
[Delphi]
property AllowResizing: Boolean;
Bottom Property · 309
Remarks
The grid has an AllowResizing property that determines whether rows and columns can be resized by
dragging the edges of header cells. The AllowResizing property of the Row and Column objects is used
to prevent the user from resizing specific rows or columns.
See Also
Row Class (page 306)
Bottom Property
Gets the position of the bottom of this row, in pixels, relative to the grid (does not take scrolling into
account).
Syntax
[VB]
Public Bottom As Integer
[C#]
public int Bottom {get;}
[Delphi]
property Bottom: Integer;
Remarks
The value returned is the sum of row heights from the top of the grid. To account for vertical scrolling,
you need to adjust the value using the grid's ScrollPosition property.
To retrieve the size and position of a cell, use the GetCellRect method.
See Also
Row Class (page 306)
Caption Property (Row)
Gets or sets the text of the first fixed cell in the row.
Syntax
[VB]
Public Caption As String
[C#]
public string Caption {get; set;}
[Delphi]
property Caption: string;
See Also
Row Class (page 306)
310 · C1FlexGrid Reference
DataIndex Property (Row)
Gets the index of this row in the Rows collection, excluding fixed and node rows.
Syntax
[VB]
Public DataIndex As Integer
[C#]
public int DataIndex {get;}
[Delphi]
property DataIndex: Integer;
Remarks
This property returns –1 if the row is a fixed or node row.
If the grid is bound to a data source, the return value can be used as an indexer into the grid's data source
to obtain a reference to the item bound to the row.
You can also obtain the underlying data object directly using the row's DataSource property.
See Also
Row Class (page 306)
Index Property (Row) (page 313)
DataSource Property (Row) (page 310)
SafeIndex Property (Row) (page 315)
DataSource Property (Row)
Gets the object that provides data for this row.
Syntax
[VB]
Public DataSource As Object
[C#]
public object DataSource {get;}
[Delphi]
property DataSource: Object;
Remarks
The type of object returned depends on the type of DataSource assigned to the grid. For example, if the
grid is bound to a DataView object, then this property will return the specific DataRowView object that
is bound to this row.
This property returns null (Nothing in VB) if the grid is unbound, or if the row is a fixed or node row that
doesn't correspond to any objects in the grid's data source.
Editor Property (Row) · 311
For an example, see the GetUnboundValue event.
See Also
Row Class (page 306)
Index Property (Row) (page 313)
DataIndex Property (Row) (page 310)
SafeIndex Property (Row) (page 315)
Editor Property (Row)
Gets or sets the custom editor used to edit cells in this row.
Syntax
[VB]
Public Editor As Control
[C#]
public Control Editor {get;set;}
[Delphi]
property Editor: Control;
Remarks
The grid provides several built-in editors that are automatically selected based on the properties of the
cell being edited.
This property allows you to use external editors when editing values in a given row. Any control can be
used as an external editor, but to achieve complete integration with the grid, the external editor should
implement the IC1EmbeddedEditor interface.
For details, see the Editor property.
See Also
Editor Property (Column) (page 330)
IC1EmbeddedEditor Interface (page 423)
Height Property
Gets or sets the height of this row, in pixels (returns –1 is the row has the default height).
Syntax
[VB]
Public Height As Integer
[C#]
public int Height {get; set;}
312 · C1FlexGrid Reference
[Delphi]
property Height: Integer;
Remarks
Setting Height to -1 causes the grid to use the default row height (Rows.DefaultSize).
Height returns the height assigned to the row even if the row is invisible, and returns -1 if the row has the
default height. To obtain the actual display height of a row, use the HeightDisplay property.
See Also
Row Class (page 306)
HeightDisplay Property
Gets or sets the display height for this row, in pixels.
Syntax
[VB]
Public HeightDisplay As Integer
[C#]
public int HeightDisplay {get; set;}
[Delphi]
property HeightDisplay: Integer;
Remarks
HeightDisplay returns the row height that is displayed to the user, taking into account the default row
height and row visibility. See also the Height property.
See Also
Row Class (page 306)
ImageAlign Property (Row)
Gets or sets how images are aligned within scrollable cells in this row.
Syntax
[VB]
Public Property ImageAlign As C1.Win.C1FlexGrid.ImageAlignEnum
[C#]
public ImageAlignEnum ImageAlign {get; set;}
[Delphi]
property ImageAlign: ImageAlignEnum;
ImageAlignFixed Property (Row) · 313
See Also
Row Class (page 306)
ImageAlign Property (Column) (page 332)
ImageAlignFixed Property (Row)
Gets or sets how images are aligned within fixed cells in this row.
Syntax
[VB]
Public Property ImageAlignFixed As C1.Win.C1FlexGrid.ImageAlignEnum
[C#]
public ImageAlignEnum ImageAlignFixed {get; set;}
[Delphi]
property ImageAlignFixed: ImageAlignEnum;
See Also
Row Class (page 306)
ImageAlignFixed Property (Column) (page 333)
Index Property (Row)
Gets the index of this row in the Rows collection.
Syntax
[VB]
Public Index As Integer
[C#]
public int Index {get;}
[Delphi]
property Index: Integer;
Remarks
Returns –1 if the row is not a member of the collection.
See also the SafeIndex and DataIndex properties.
•
Visual Basic
Dim row As Row = _flex.Rows(12)
Console.WriteLine("*** Row index is {0}", row.Index)
•
C#
Row row = _flex.Rows[12];
Console.WriteLine("*** Row index is {0}", row.Index);
*** Row index is 12
314 · C1FlexGrid Reference
•
Delphi
var
r: Row;
begin
r := _flex.Rows[12];
Console.WriteLine('*** Row index is {0}', r.Index);
end;
See Also
Row Class (page 306)
IsNew Property
Indicates the row is a placeholder for adding new rows to the grid.
Syntax
[VB]
Public IsNew As Boolean
[C#]
public Bool IsNew {get; set;}
[Delphi]
property IsNew: Boolean;
Remarks
It is true only for the last row on the grid when the AllowAddNew property is set to true. (This is the row
that has an asterisk glyph on the first fixed column.)
See Also
Row Class (page 306)
IsNode Property
Gets or sets whether this row is a node row in an outline.
Syntax
[VB]
Public IsNode As Boolean
[C#]
public bool IsNode {get; set;}
[Delphi]
property IsNode: Boolean;
Remarks
The IsNode property determines whether the row behaves as a node in an outline tree. You can set this
property to create custom trees, or use the grid's Subtotal method to create trees automatically.
Node Property · 315
See Also
Row Class (page 306)
Node Property
Syntax
[VB]
Public Node As Node
[C#]
public Node Node {get;}
[Delphi]
property Node: Node;
Remarks
If the row is a node (IsNode = true), this property returns a Node object that can be used to collapse or
expand the node, set its level within the outline tree, etc. If the row is not a node (IsNode = false), returns
the row's parent node.
See Also
Row Class (page 306)
SafeIndex Property (Row)
Gets the index of this row in the Rows collection.
Syntax
[VB]
Public SafeIndex As Integer
[C#]
public int SafeIndex {get;}
[Delphi]
property SafeIndex: Integer;
Remarks
This property is similar to the Index property, except it throws an exception when the row is not a
member of the collection.
See Also
Row Class (page 306)
Selected Property (Row)
Gets or sets whether this row is selected.
316 · C1FlexGrid Reference
Syntax
[VB]
Public Selected As Boolean
[C#]
public bool Selected {get; set;}
[Delphi]
property Selected: Boolean;
Remarks
Use this property to get or set the selection status for individual rows when the grid's SelectionMode
property is set to SelectionModeEnum.ListBox.
See Also
Row Class (page 306)
Style Property (Row)
Gets or sets the custom style associated with this row.
Syntax
[VB]
Public Style As CellStyle
[C#]
public CellStyle Style {get; set;}
[Delphi]
property Style: CellStyle;
Remarks
If the row has a custom style, this property returns that style. Otherwise, it returns null.
See also the StyleDisplay and StyleNew properties.
See Also
Row Class (page 306)
StyleDisplay Property (Row)
Gets the style used to display this row.
Syntax
[VB]
Public StyleDisplay As CellStyle
[C#]
public CellStyle StyleDisplay {get;}
StyleNew Property (Row) · 317
[Delphi]
property StyleDisplay: CellStyle;
Remarks
If the row has a custom style, this property returns that style. Otherwise, it returns the stock style used to
display the row (e.g., Normal, Alternate, Fixed).
See Also
Row Class (page 306)
StyleNew Property (Row)
Gets the custom style associated with this row, creates a new one is necessary.
Syntax
[VB]
Public StyleNew As CellStyle
[C#]
public CellStyle StyleNew {get;}
[Delphi]
property StyleNew: CellStyle;
Remarks
If the row has a custom style, this property returns that style. Otherwise, it creates a new custom style
and returns a reference to it.
See Also
Row Class (page 306)
Top Property
Gets the position of the top of this row, in pixels, relative to the grid (does not take scrolling into account).
Syntax
[VB]
Public Top As Integer
[C#]
public int Top {get;}
[Delphi]
property Top: Integer;
Remarks
The value returned is the sum of row heights from the top of the grid. To account for vertical scrolling,
you need to adjust the value using the grid's ScrollPosition property.
318 · C1FlexGrid Reference
To retrieve the size and position of a cell, use the GetCellRect method.
See Also
Row Class (page 306)
UserData Property (Row)
Gets or sets user data associated with this row.
Syntax
[VB]
Public UserData As Object
[C#]
public object UserData {get; set;}
[Delphi]
property UserData: Object;
Example
The code below looks for the UserData assigned to a row and returns the row's index:
•
Visual Basic
Private Function FindRow(fg As C1FlexGrid, data As Object) As Integer
' look for data in Row.UserData
Dim row As Row
For Each row In fg.Rows
If data.Equals(row.UserData) Then
Return row.Index
End If
Next row ' not found
Return - 1
End Function 'FindRow
•
C#
private int FindRow(C1FlexGrid fg, object data)
{
// look for data in Row.UserData
foreach (Row row in fg.Rows)
if (data.Equals(row.UserData))
return row.Index;
// not found
return -1;
}
•
Delphi
function Class1.FindRow(fg: C1FlexGrid; data: System.Object): Integer;
var
I: Integer;
r: Row;
begin
// look for data in Row.UserData
for I := 0 to fg.Rows.Count – 1 do
if (data.Equals(fg.Rows[I].UserData))
begin
Visible Property (Row) · 319
Result := fg.Rows[I].Index;
exit;
end;
// not found
Result := -1;
end;
Remarks
The UserData value is not used internally by the grid. It is reserved for additional data that you may
want to associate with a row.
See Also
Row Class (page 306)
Visible Property (Row)
Gets or sets the visibility of this row.
Syntax
[VB]
Public Visible As Boolean
[C#]
public bool Visible {get; set;}
[Delphi]
property Visible: Boolean;
Remarks
This property returns true if the row has non-zero height, even if it has been scrolled out of view. To
determine whether a row is currently within view, check the TopRow and BottomRow properties.
See Also
Row Class (page 306)
Row Methods
Clear Method (Row)
Clears this row.
Syntax
[VB]
Public Sub Clear(clearFlags As ClearFlags)
[C#]
public void Clear (ClearFlags clearFlags )
[Delphi]
procedure Clear(clearFlags: ClearFlags);
320 · C1FlexGrid Reference
Parameter
Description
flags
One or more values from the ClearFlags enumeration, specifying what to clear.
Remarks
Use this method to reset row properties to their default values (height, visibility, style, user data, etc.).
This method does not affect the contents of cells in the row.
See Also
Row Class (page 306)
Move Method (Row)
Moves a row to a new position in the collection.
Syntax
[VB]
Public Sub Move(indexNew As Integer)
[C#]
public void Move ( int indexNew )
[Delphi]
procedure Move(indexNew: Integer);
Parameter
Description
indexNew
An integer specifying the row's new position.
See Also
Row Class (page 306)
Column Class
All Column Members
Column Class Public Properties
AllowDragging
Gets or sets whether this column can be dragged with
the mouse.
AllowEditing
Gets or sets whether cells in this column can be edited
by the user.
AllowMerging
Gets or sets whether cells in this column can be merged
with neighboring cells.
Column Class · 321
AllowResizing
Gets or sets whether this column can be resized with
the mouse.
AllowSorting
Supported by the .NET Compact Framework.
Gets or sets whether this column can be sorted with the
mouse.
Caption
Gets or sets the text of the first fixed cell in the column.
ComboList
Supported by the .NET Compact Framework.
Gets or sets the list of items to be used by the dropdown editor for this column.
DataIndex
Gets the position of the column in the data source
object.
DataMap
Supported by the .NET Compact Framework.
Gets or sets the data map used to translate data values
into display values for this column.
DataType
Supported by the .NET Compact Framework.
Gets or sets the data type for this column.
EditMask
Supported by the .NET Compact Framework.
Gets or sets the input mask to use when editing cells on
this column.
Editor
Gets or sets the custom editor used to edit cells in this
column.
Format
Supported by the .NET Compact Framework.
Gets or sets a string that specifies how to format the
data on this column.
ImageAlign
Supported by the .NET Compact Framework.
Gets or sets how images are aligned within scrollable
cells in this column.
ImageAlignFixed
Gets or sets how images are aligned within fixed cells in
this column.
ImageAndText
Supported by the .NET Compact Framework.
Determines whether images found in this column's
ImageMap should be displayed instead of or in addition
to the cell text.
ImageMap
Supported by the .NET Compact Framework.
Gets or sets the data map used to translate data values
into images for this column.
Index
Gets the index of this column in the Cols collection.
Left
Supported by the .NET Compact Framework.
Gets the position of the left of this column, in pixels,
relative to the grid.
Name
Supported by the .NET Compact Framework.
Gets or sets the name of this column. The name can be
used as an index in the Cols property indexer.
Right
Supported by the .NET Compact Framework.
Gets the position of the right of this column, in pixels,
relative to the grid.
SafeIndex
Gets the index of this column in the Column collection.
Selected
Gets or sets whether this column is selected.
Sort
Supported by the .NET Compact Framework.
Specifies how this column should be sorted.
Style
Gets or sets the style used to display this column.
StyleFixed
Supported by the .NET Compact Framework.
Gets the stock CellStyle used to paint fixed cells.
322 · C1FlexGrid Reference
StyleFixedDisplay
Supported by the .NET Compact Framework.
Gets the style used to display fixed cells on this column.
StyleFixedNew
Supported by the .NET Compact Framework.
Gets the custom style associated with fixed cells on this
column.
StyleNew
Gets the custom style associated with this column.
TextAlign
Supported by the .NET Compact Framework.
Gets or sets how text is aligned within cells on this
column.
TextAlignFixed
Supported by the .NET Compact Framework.
Gets or sets how text is aligned within fixed cells on this
column.
UserData
Gets or sets user data associated with this column.
Visible
Gets or sets the visibility of this column.
Width
Supported by the .NET Compact Framework.
Gets or sets the width of this column, in pixels.
WidthDisplay
Supported by the .NET Compact Framework.
Gets or sets the display width for this column, in pixels.
Column Class Public Methods
Clear
Supported by the .NET Compact Framework.
Clears the column.
Move
Moves a column to a new position in the collection.
Column Properties
AllowDragging Property (Column)
Gets or sets whether this column can be dragged with the mouse.
Syntax
[VB]
Public AllowDragging As Boolean
[C#]
public bool AllowDragging {get; set;}
[Delphi]
property AllowDragging: Boolean;
Remarks
The grid has an AllowDragging property that determines whether rows and columns can be dragged.
The AllowDragging property of the Row and Column objects is used to prevent the user from dragging
specific rows or columns.
AllowEditing Property (Column) · 323
See Also
Column Class (page 320)
AllowEditing Property (Column)
Gets or sets whether cells in this column can be edited by the user.
Syntax
[VB]
Public AllowEditing As Boolean
[C#]
public bool AllowEditing {get; set;}
[Delphi]
property AllowEditing: Boolean;
Remarks
The grid has an AllowEditing property that determines whether cells can be edited. The AllowEditing
property of the Row and Column objects is used to prevent the user from editing cells in specific rows or
columns.
See Also
Column Class (page 320)
AllowMerging Property (Column)
Gets or sets whether cells in this column can be merged with neighboring cells.
Syntax
[VB]
Public AllowMerging As Boolean
[C#]
public bool AllowMerging {get; set;}
[Delphi]
property AllowMerging: Boolean;
Remarks
The grid has an AllowMerging property that determines whether cells can be merged. The
AllowMerging property of the Row and Column objects is used to allow cells in specific rows or
columns to be merged with adjacent cells.
See Also
Column Class (page 320)
324 · C1FlexGrid Reference
AllowResizing Property (Column)
Gets or sets whether this column can be resized with the mouse.
Syntax
[VB]
Public AllowResizing As Boolean
[C#]
public bool AllowResizing {get; set;}
[Delphi]
property AllowResizing: Boolean;
Remarks
The grid has an AllowResizing property that determines whether rows and columns can be resized by
dragging the edges of header cells. The AllowResizing property of the Row and Column objects is used
to prevent the user from resizing specific rows or columns.
See Also
Column Class (page 320)
AllowSorting Property (Column)
Gets or sets whether this column can be sorted with the mouse.
Syntax
[VB]
Public AllowSorting As Boolean
[C#]
public bool AllowSorting {get; set;}
[Delphi]
property AllowSorting: Boolean;
Remarks
The grid has an AllowSorting property that determines whether columns can be sorted by clicking their
header cells. The AllowSorting property of the Column objects is used to prevent the user from sorting
specific columns.
See Also
Column Class (page 320)
Caption Property
Gets or sets the text of the first fixed cell in the column.
ComboList Property (Column) · 325
Syntax
[VB]
Public Caption As String
[C#]
public string Caption {get; set;}
[Delphi]
property Caption: string;
See Also
Column Class (page 320)
ComboList Property (Column)
Gets or sets the list of items to be used by the drop-down editor for this column.
Syntax
[VB]
Public ComboList As String
[C#]
public string ComboList {get; set;}
[Delphi]
property ComboList: string;
Remarks
For details and examples, see the Editing Cells (page 34 )topic.
See Also
Column Class (page 320)
DataIndex Property (Column)
Gets the position of the column in the data source object.
Syntax
[VB]
Public DataIndex As Integer
[C#]
public int DataIndex {get;}
[Delphi]
property DataIndex: Integer;
326 · C1FlexGrid Reference
Remarks
In data bound grids, each column has an index in the grid's column collection (Cols) and an index in the
underlying data source column collection. For example, if a data source contains three columns [First,
Last, Middle] and you bind it to a grid with one fixed column, the DataIndex property for each column
would be:
Grid Index
Data Field
DataIndex
0
(fixed)
-1
1
First
0
2
Last
1
3
Middle
2
If the user then dragged the last column into the first position, the DataIndex property for each column
would be:
Grid Index
Data Field
DataIndex
0
(fixed)
-1
1
Middle
2
2
First
0
3
Last
1
NOTE:
This property returns –1 for fixed columns.
See Also
Column Class (page 320)
DataMap Property (Column)
Gets or sets the DataMap used to associate values stored in cells with display values.
Syntax
[VB]
Public DataMap As IDictionary
[C#]
public IDictionary DataMap {get; set;}
[Delphi]
property DataMap: IDictionary;
DataType Property · 327
Remarks
The DataMap property allows you to implement "translated" columns. In translated columns, the grid
does not display the values stored in the cells. Instead, it looks up those values in the column's DataMap
and displays the mapped value.
For example, you may use the DataMap property to store product IDs and display product names
instead:
•
Visual Basic
Dim employeeMap As New Hashtable()
Dim e As Employee
For Each e In EmployeeCollection
employeeMap.Add(e.ID, e.LastName)
Next e
flex.Cols(1).DataType = GetType(Employee)
flex.Cols(1).DataMap = employeeMap '
•
C#
Hashtable employeeMap = new Hashtable();
foreach (Employee e in EmployeeCollection)
employeeMap.Add(e.ID, e.LastName);
flex.Cols[1].DataType = typeof(Employee);
flex.Cols[1].DataMap = employeeMap;
•
Delphi
var
employeeMap: Hashtable;
I: Integer;
e: Employee;
begin
employeeMap := Hashtable.Create;
for I := 0 to EmployeeCollection.Count – 1 do
begin
e := Employee(EmployeeCollection[I]);
employeeMap.Add(System.Object(e.ID), System.Object(e.LastName));
end;
flex.Cols[1].DataType := TypeOf(Employee);
flex.Cols[1].DataMap := employeeMap;
end;
The grid also uses the DataMap property to populate drop-down lists when the column is editable.
NOTE: The IDictionary interface is defined in the System.Collections namespace and is implemented by
the Hashtable class among others.
See Also
Column Class (page 320)
DataType Property
Gets or sets the data type for this column.
Syntax
[VB]
Public DataType As Type
328 · C1FlexGrid Reference
[C#]
public Type DataType {get; set;}
[Delphi]
property DataType: Type;
Remarks
By default, the column's DataType property is set to object, which allows you to store any data values in
the column.
If you set a column's DataType to a specific type, the grid will try to convert any values assigned to cells
in that column to the specified data type. If the conversion fails, the grid fires the GridError event and the
cell value is not changed.
The DataType property affects how values are stored internally in the grid, how they are sorted, and the
type of control that is used to edit the values in the column. For example, a DateTimePicker control is
used to edit values in DateTime columns, and check boxes are used to display and edit values in boolean
columns.
If you want to store times (not dates) in a column, you can still use the DateTime type, but you should
use a Format that displays only the times, not the dates. Also, if the column is editable, you should
prevent the control from using the DateTimePicker editor, either by using an EditMask or by
customizing the editor in the SetupEditor event. For example:
•
Visual Basic
' store times in column 1, use masked editor
fg.Cols(1).DataType = GetType(DateTime) '
fg.Cols(1).Format = "hh:mm tt"
fg.Cols(1).EditMask = "99:99 LL"
' store times in column 2, use DateTimePicker but prevent drop-down
fg.Cols(2).DataType = GetType(DateTime) '
fg.Cols(2).Format = "hh:mm tt"
Private Sub fg_SetupEditor(sender As Object, e As RowColEventArgs)
If e.Col = 2 Then
Dim ctl As DateTimePicker = flex.Editor '
If Not (ctl Is Nothing) Then
ctl.ShowUpDown = True
End If
End If
End Sub 'fg_SetupEditor
•
C#
' store times in column 1, use masked editor
fg.Cols[1].DataType=typeof(DateTime);
fg.Cols[1].Format="hh:mm tt";
fg.Cols[1].EditMask="99:99 LL";
' store times in column 2, use DateTimePicker but prevent drop-down
fg.Cols[2].DataType=typeof(DateTime);
fg.Cols[2].Format="hh:mm tt";
private void fg_SetupEditor(object sender, RowColEventArgs e)
{
if (e.Col == 2)
{
DateTimePicker ctl = flex.Editor as DateTimePicker;
EditMask Property (Column) · 329
}
if (ctl != null)
ctl.ShowUpDown = true;
}
•
Delphi
// store times in column 1, use masked editor
fg.Cols[1].DataType := typeof(DateTime);
fg.Cols[1].Format := 'hh:mm tt';
fg.Cols[1].EditMask := '99:99 LL';
// store times in column 2, use DateTimePicker but prevent drop-down
fg.Cols[2].DataType := typeof(DateTime);
fg.Cols[2].Format := 'hh:mm tt';
procedure fg_SetupEditor(sender: System.Object; e: RowColEventArgs);
var
ctl: DateTimePicker;
begin
if e.Col = 2 then
begin
if ctl is DateTimePicker then
begin
ctl := DateTimePicker(flex.Editor);
ctl.ShowUpDown := True;
end;
end;
end; // fg_SetupEditor
See Also
Column Class (page 320)
EditMask Property (Column)
Gets or sets the input mask to use when editing cells on this column.
Syntax
[VB]
Public EditMask As String
[C#]
public string EditMask {get; set;}
[Delphi]
property EditMask: string;
Remarks
The grid also has an EditMask property that applies to the entire grid.
For details on how to specify and use edit masks, see the grid's EditMask property and the Editing Cells
(page 34 )topic.
See Also
Column Class (page 320)
330 · C1FlexGrid Reference
Editor Property (Column)
Gets or sets the custom editor used to edit cells in this column.
Syntax
[VB]
Public Editor As Control
[C#]
public Control Editor {get;set;}
[Delphi]
property Editor: Control;
Remarks
The grid provides several built-in editors that are automatically selected based on the properties of the
cell being edited.
This property allows you to use external editors when editing values in a given column. Any control can
be used as an external editor, but to achieve complete integration with the grid, the external editor should
implement the IC1EmbeddedEditor interface.
You can associate external editors with columns at design time, using the grid's Column Editor, or at run
time.
For details, see the Editor property.
See Also
Editor Property (Row) (page 311)
IC1EmbeddedEditor Interface (page 423)
Format Property
Gets or sets a string that specifies how to format the data on this column.
Syntax
[VB]
Public Format As String
[C#]
public string Format {get; set;}
[Delphi]
property Format: string;
Remarks
The Format property affects how values are formatted for display, not the values stored internally. To
retrieve the formatted value of a cell, use the GetDataDisplay property.
Format Property · 331
The Format string has the same semantics as the format argument in the .NET String.Format method. For
details and a complete set of examples, see the .NET documentation. A brief summary of the most
commonly used options is given below.
Formatting Numeric Values
The following strings can be used to format numbers:
String
Name
Description
C or c
Currency
The number is converted to a string that represents a localized currency
amount.
E or e
Exponential
The number is converted to a string of the form "-d.ddd…E+ddd" or "d.ddd…e+ddd", where each 'd' indicates a digit (0-9).
F or f
Fixed-point
The number is converted to a string that represents a floating-point
number with a fixed number of decimals.
N or n
Number
The number is converted to a string with decimal separators and a fixed
number of decimals.
P or p
Percentage
The number is converted to a string that represents a percentage.
You can also build custom formats using the following characters:
Character
Name
Description
0
Zero Placeholder
If the value being formatted has a digit in the position where the '0'
appears in the format string, then that digit is copied to the output
string. The position of the leftmost '0' before the decimal point and
the rightmost '0' after the decimal point determines the range of
digits that are always present in the output string.
#
Digit Placeholder
If the value being formatted has a digit in the position where the '#'
appears in the format string, then that digit is copied to the output
string. Otherwise, nothing is stored in that position in the output
string.
.
Decimal point
The first '.' character in the format string determines the location of
the localized decimal separator in the formatted value; any
additional '.' characters are ignored.
,
Thousand
separator
Thousand separators are inserted between each group of three
digits to the left of the decimal separator. If the format string
contains one or more ',' characters immediately to the left of the
decimal point, then the number will be divided by the number of ','
characters multiplied by 1000 before it is formatted.
%
Percentage
Placeholder
The presence of a '%' character in a format string causes a number
to be multiplied by 100 before it is formatted.
;
Section
separator
The ';' character is used to separate sections for positive, negative,
and zero numbers in the format string.
332 · C1FlexGrid Reference
Formatting DateTime Values
The following strings can be used to format dates and times:
String
Name
d
Short Date
D
Long Date
t
Short Time
T
Long Time
You can also build custom formats using the following characters:
Character
Description
d
Displays the current day of the month, measured as a number between 1 and 31,
inclusive. If the day is a single digit only (1-9), then it is displayed as a single digit.
dd
Displays the current day of the month, measured as a number between 1 and 31,
inclusive. If the day is a single digit only (1-9), it is formatted with a preceding 0 (01-09).
ddd
Displays the abbreviated name of the day.
dddd
Displays the full name of the day.
M
Displays the current month, measured as a number between 1 and 12, inclusive. If the
month is a single digit (1-9), it is displayed as a single digit.
MM
Displays the current month, measured as a number between 1 and 12, inclusive. If the
month is a single digit (1-9), it is preceded by a zero.
MMM
Displays the abbreviated name of the month.
MMMM
Displays the full name of the month.
y
Displays the year as a maximum two-digit number. The first two digits of the year are
omitted. If the year is a single digit (1-9), it is displayed as a single digit.
yy
Displays the year as a two-digit number. The first two digits of the year are omitted. If the
year is a single digit (1-9), it is preceded by a zero.
yyyy
Displays the full year as a four-digit string.
/
Localized date separator.
See Also
Column Class (page 320)
ImageAlign Property (Column)
Determines how images are aligned within cells on this column.
ImageAlignFixed Property (Column) · 333
Syntax
[VB]
Public ImageAlign As ImageAlignEnum
[C#]
public ImageAlignEnum ImageAlign {get; set;}
[Delphi]
property ImageAlign: ImageAlignEnum;
Remarks
This property maps to the CellStyle associated with the column. For example:
•
Visual Basic
flex.Cols(1).ImageAlign = ImageAlignEnum.RightTop '
Console.WriteLine(flex.Cols(1).Style.ImageAlign)
ImageAlignEnum.RightTop
•
C#
flex.Cols[1].ImageAlign = ImageAlignEnum.RightTop;
Console.WriteLine(flex.Cols[1].Style.ImageAlign);
ImageAlignEnum.RightTop
•
Delphi
flex.Cols[1].ImageAlign := ImageAlignEnum.RightTop;
Console.WriteLine(flex.Cols[1].Style.ImageAlign);
ImageAlignEnum.RightTop;
See Also
Column Class (page 320)
ImageAlign Property (Row) (page 312)
ImageAlignFixed Property (Column)
Gets or sets how images are aligned within fixed cells in this column.
Syntax
[VB]
Public Property ImageAlignFixed As C1.Win.C1FlexGrid.ImageAlignEnum
[C#]
public ImageAlignEnum ImageAlignFixed {get; set;}
[Delphi]
property ImageAlignFixed: ImageAlignEnum;
See Also
Column Class (page 320)
ImageAlignFixed Property (Row) (page 313)
334 · C1FlexGrid Reference
ImageAndText Property
Determines whether images found in this column's ImageMap should be displayed instead of or in
addition to the cell text.
Syntax
[VB]
Public ImageAndText As Boolean
[C#]
public bool ImageAndText {get; set;}
[Delphi]
property ImageAndText: Boolean;
See Also
Column Class (page 320)
ImageMap Property (Column) (page 334)
ImageMap Property (Column)
Gets or sets the data map used to translate data values into images for this column.
Syntax
[VB]
Public ImageMap As IDictionary
[C#]
public IDictionary ImageMap {get; set;}
[Delphi]
property ImageMap: IDictionary;
Remarks
Use this property to associate data values in a column with images. For example, if a column contains
country names, you can use this property to display the corresponding country flags.
Use the ImageAndText property to determine whether the image is displayed instead of or in addition to
the cell text.
The code below shows how you can setup an ImageMap for a column. The example assumes you have
created an ImageList control and populated it with images of the country flags:
•
Visual Basic
Private Enum Countries
Australia
Brazil
Canada
Denmark
France
Germany
ImageMap Property (Column) · 335
Italy
Japan
Korea
Mexico
Netherlands
Portugal
Russia
Spain
Turkey
USA
End Enum 'Countries
' set up image map
Dim imgMap As New Hashtable()
For i = 0 To imgListFlags.Images.Count - 1
imgMap.Add(CType(i, Countries), imgListFlags.Images(i))
Next i
Dim col As Column = flex.Cols("countries")
col.ImageMap = imgMap
col.ImageAndText = False
col.ImageAlign = ImageAlignEnum.CenterCenter
•
C#
private enum Countries
{
Australia, Brazil, Canada, Denmark, France,
Germany, Italy, Japan, Korea, Mexico,
Netherlands, Portugal, Russia, Spain, Turkey, USA
};
// set up image map
Hashtable imgMap = new Hashtable();
for (i = 0; i < imgListFlags.Images.Count; i++)
imgMap.Add((Countries)i, imgListFlags.Images[i]);
Column col = flex.Cols["countries"];
col.ImageMap = imgMap;
col.ImageAndText = false;
col.ImageAlign = ImageAlignEnum.CenterCenter;
•
Delphi
type
Countries = (Australia, Brazil, Canada, Denmark, France, Germany,
Italy, Japan, Korea, Mexico, Netherlands, Portugal, Russia, Spain,
Turkey, USA);
var
col: Column;
imgMap: Hashtable;
begin
imgMap := Hashtable.Create;
for i := 0 to imgListFlags.Images.Count – 1 do
imgMap.Add(System.Object(i), imgListFlags.Images[i]);
col := flex.Cols['countries'];
col.ImageMap := imgMap;
col.ImageAndText := False;
col.ImageAlign := ImageAlignEnum.CenterCenter;
end;
See Also
Column Class (page 320)
336 · C1FlexGrid Reference
Index Property (Column)
Gets the index of this column in the Cols collection.
Syntax
[VB]
Public Index As Integer
[C#]
public int Index {get;}
[Delphi]
property Index: Integer;
Remarks
Returns –1 if the column is not a member of the collection.
See Also
Column Class (page 320)
SafeIndex Property (Column) (page 337)
Left Property
Gets the position of the left of this column, in pixels, relative to the grid (does not take scrolling into
account).
Syntax
[VB]
Public Left As Integer
[C#]
public int Left {get;}
[Delphi]
property Left: Integer;
Remarks
The value returned is the sum of column widths from the left of the grid. To account for horizontal
scrolling, you need to adjust the value using the grid's ScrollPosition property.
To retrieve the size and position of a cell, use the GetCellRect method.
See Also
Column Class (page 320)
Name Property (Column)
Gets or sets the name of this column. The name can be used as an index in the Cols property indexer.
Right Property · 337
Syntax
[VB]
Public Name As String
[C#]
public string Name {get; set;}
[Delphi]
property Name: string;
Remarks
When the grid is bound to a DataSource, the column names are set automatically.
See Also
Column Class (page 320)
Right Property
Gets the position of the right of this column, in pixels, relative to the grid (does not take scrolling into
account).
Syntax
[VB]
Public Right As Integer
[C#]
public int Right {get;}
[Delphi]
property Right: Integer;
Remarks
The value returned is the sum of column widths from the left of the grid. To account for horizontal
scrolling, you need to adjust the value using the grid's ScrollPosition property.
To retrieve the size and position of a cell, use the GetCellRect method.
See Also
Column Class (page 320)
SafeIndex Property (Column)
Gets the index of this column in the Column collection.
Syntax
[VB]
Public SafeIndex As Integer
338 · C1FlexGrid Reference
[C#]
public int SafeIndex {get;}
[Delphi]
property SafeIndex: Integer;
Remarks
This property is similar to the Index property, except it throws an exception when the row is not a
member of the collection.
See Also
Column Class (page 320)
Selected Property (Column)
Gets or sets whether this column is selected.
Syntax
[VB]
Public Selected As Boolean
[C#]
public bool Selected {get; set;}
[Delphi]
property Selected: Boolean;
See Also
Column Class (page 320)
Sort Property (Column)
Specifies how this column should be sorted.
Syntax
[VB]
Public Sort As SortFlags
[C#]
public SortFlags Sort {get; set;}
[Delphi]
property Sort: SortFlags;
Remarks
This property is used when you call the Sort method and use the SortFlags.UseColSort flag.
Style Property (Column) · 339
See Also
Column Class (page 320)
Sort Property (C1FlexGridClassic) (page 495)
Style Property (Column)
Gets or sets the custom style associated with this column.
Syntax
[VB]
Public Style As CellStyle
[C#]
public CellStyle Style {get; set;}
[Delphi]
property Style: CellStyle;
Remarks
If the column has a custom style, this property returns that style. Otherwise, it returns null.
See also the StyleDisplay and StyleNew properties.
See Also
Column Class (page 320)
StyleDisplay Property (Column)
Gets the style used to display scrollable cells in this column.
Syntax
[VB]
Public StyleDisplay As CellStyle
[C#]
public CellStyle StyleDisplay {get;}
[Delphi]
property StyleDisplay: CellStyle;
Remarks
If the column has a custom style, this property returns that style. Otherwise, it returns the stock style used
to display the column (e.g., Normal, Alternate, Fixed).
See Also
Column Class (page 320)
340 · C1FlexGrid Reference
StyleFixed Property
Gets the stock CellStyle used to paint fixed cells.
Syntax
[VB]
Public StyleFixed As CellStyle
[C#]
public CellStyle StyleFixed {get;}
[Delphi]
property StyleFixed: CellStyle;
See Also
Column Class (page 320)
Styles Property (page 159)
StyleFixedDisplay Property
Gets the style used to display fixed cells on this column.
Syntax
[VB]
Public StyleFixedDisplay As CellStyle
[C#]
public CellStyle StyleFixedDisplay {get;}
[Delphi]
property StyleFixedDisplay: CellStyle;
Remarks
If the column has a custom style associated with its fixed cells, this property returns that style. Otherwise,
it returns the stock style used to display the column (e.g., Normal, Fixed).
See Also
Column Class (page 320)
StyleFixedNew Property
Gets the custom style associated with fixed cells on this column, creates a new one of necessary.
Syntax
[VB]
Public StyleFixedNew As CellStyle
StyleNew Property (Column) · 341
[C#]
public CellStyle StyleFixedNew {get;}
[Delphi]
property StyleFixedNew: CellStyle;
Remarks
If the column has a custom style associated with its fixed cells, this property returns that style. Otherwise,
it creates a new custom style and returns a reference to it.
See Also
Column Class (page 320)
StyleNew Property (Column)
Gets the custom style associated with this column, creates a new one is necessary.
Syntax
[VB]
Public StyleNew As CellStyle
[C#]
public CellStyle StyleNew {get;}
[Delphi]
property StyleNew: CellStyle;
Remarks
If the column has a custom style, this property returns that style. Otherwise, it creates a new custom style
and returns a reference to it.
See Also
Column Class (page 320)
TextAlign Property (Column)
Gets or sets how text is aligned within cells on this column.
Syntax
[VB]
Public TextAlign As TextAlignEnum
[C#]
public TextAlignEnum TextAlign {get; set;}
[Delphi]
property TextAlign: TextAlignEnum;
342 · C1FlexGrid Reference
Remarks
This property maps to the CellStyle associated with the column. For example:
•
Visual Basic
flex.Cols(1).TextAlign = TextAlignEnum.RightTop '
Console.WriteLine(flex.Cols(1).Style.TextAlign)
•
C#
flex.Cols[1].TextAlign = TextAlignEnum.RightTop;
Console.WriteLine(flex.Cols[1].Style.TextAlign);
TextAlignEnum.RightTop
•
Delphi
flex.Cols[1].TextAlign := TextAlignEnum.RightTop;
Console.WriteLine(flex.Cols[1].Style.TextAlign);
TextAlignEnum.RightTop;
See Also
Column Class (page 320)
TextAlignFixed Property
Gets or sets how text is aligned within fixed cells on this column.
Syntax
[VB]
Public TextAlignFixed As TextAlignEnum
[C#]
public TextAlignEnum TextAlignFixed {get; set;}
[Delphi]
property TextAlignFixed: TextAlignEnum;
Remarks
This property maps to the CellStyle associated with the fixed cells in this column. For example:
•
Visual Basic
flex.Cols(1).TextAlign = TextAlignEnum.RightTop '
Console.WriteLine(flex.Cols(1).StyleFixed.TextAlign)
•
C#
flex.Cols[1].TextAlign = TextAlignEnum.RightTop;
Console.WriteLine(flex.Cols[1].StyleFixed.TextAlign);
TextAlignEnum.RightTop
•
Delphi
flex.Cols[1].TextAlign := TextAlignEnum.RightTop;
Console.WriteLine(flex.Cols[1].StyleFixed.TextAlign);
TextAlignEnum.RightTop;
See Also
Column Class (page 320)
UserData Property (Column) · 343
UserData Property (Column)
Gets or sets user data associated with this column.
Syntax
[VB]
Public UserData As Object
[C#]
public object UserData {get; set;}
[Delphi]
property UserData: Object;
Remarks
The UserData value is not used internally by the grid. It is reserved for additional data that you may
want to associate with a column.
See Also
Column Class (page 320)
Visible Property (Column)
Gets or sets the visibility of this column.
Syntax
[VB]
Public Visible As Boolean
[C#]
public bool Visible {get; set;}
[Delphi]
property Visible: Boolean;
Remarks
This property returns true if the column has non-zero width, even if it has been scrolled out of view. To
determine whether a column is currently within view, check the LeftCol and RightCol properties.
See Also
Column Class (page 320)
Width Property (Column)
Gets or sets the width of this column, in pixels (returns –1 is the column has the default width).
Syntax
[VB]
Public Width As Integer
344 · C1FlexGrid Reference
[C#]
public int Width {get; set;}
[Delphi]
property Width: Integer;
Remarks
Setting Width to -1 causes the grid to use the default column width (Cols.DefaultSize).
Width returns the width assigned to the column even if the column is invisible, and returns -1 if the
column has the default width. To obtain the actual display width of a column, use the WidthDisplay
property.
See Also
Column Class (page 320)
WidthDisplay Property
Gets or sets the display width for this column, in pixels.
Syntax
[VB]
Public WidthDisplay As Integer
[C#]
public int WidthDisplay {get; set;}
[Delphi]
property WidthDisplay: Integer;
Remarks
WidthDisplay returns the column width that is displayed to the user, taking into account the default
column width and column visibility. See also the Width property.
See Also
Column Class (page 320)
Column Methods
Clear Method (Column)
Clears this column.
Syntax
[VB]
Public Sub Clear(clearFlags As ClearFlags)
[C#]
public void Clear (ClearFlags clearFlags )
Move Method (Column) · 345
[Delphi]
procedure Clear(clearFlags: ClearFlags);
Parameter
Description
flags
One or more values from the ClearFlags enumeration, specifying what to clear.
Remarks
Use this method to reset column properties to their default values (width, visibility, style, user data, etc.).
This method does not affect the contents of cells in the column.
See Also
Column Class (page 320)
Move Method (Column)
Moves a column to a new position in the collection.
Syntax
[VB]
Public Sub Move(indexNew As Integer)
[C#]
public void Move ( int indexNew )
[Delphi]
procedure Move(indexNew: Integer);
Parameter
Description
indexNew
An integer specifying the column's new position.
See Also
Column Class (page 320)
CellStyleCollection class
This class manages the collection of CellStyle objects used to render the grid. There are two types of cell
styles: stock and custom.
Stock Styles
Stock styles are created by the grid. You can change their properties, but you cannot add or remove stock
styles. Cell styles are hierarchical (similar to cascading style sheets). All styles are based on the Normal
stock style. Any changes made to the Normal style are inherited by all other styles, unless that particular
property is explicitly overridden on the derived style. For example, if you change the Font property of the
346 · C1FlexGrid Reference
Normal style, the fixed and highlighted cells will be displayed using the new font, because be default the
Fixed and Highlight styles do not define a value for the Font property.
The style inheritance mechanism is also used by the grid to combined styles dynamically. For example, a
selected cell on an even scrollable row might be painted using the Selected style, inheriting from the
Alternate and Normal styles.
The stock styles defined by the grid are: Normal, Fixed, Alternate, Highlight, EmptyArea, Focus, Search,
GrandTotal, and Subtotal0 through Subtotal5.
You can access stock styles using properties exposed by the Styles collection or using one of the indexers
(e.g. Styles.Normal, Styles[0], Styles[CellStyleEnum.Normal], Styles["Normal"]).
Custom Styles
Custom styles are created using the Styles collection Add method. They can be accessed through the
Styles collection by name or index. Custom styles may be assigned to Row, Column, and CellRange
objects. The same inheritance rules used for stock styles apply to custom styles. For example, if you define
a custom style called "Small Number" and set its BackColor property to red, leaving all other properties
unspecified, cells with this style will inherit the Font and ForeGround properties from a stock style,
usually Normal, but possibly Alternate, Focus, Highlight, or from other custom styles assigned to the
Row or Column objects.
All CellStyleCollection Members
CellStyleCollection Class Public Properties
Alternate
Supported by the .NET Compact Framework.
Gets the CellStyle used to paint alternate rows.
Count
Supported by the .NET Compact Framework.
Gets the number of styles in the collection.
EmptyArea
Supported by the .NET Compact Framework.
Gets the CellStyle used to paint the empty area of
the grid.
Editor
Gets the CellStyle used to paint cells while they
are being edited.
Fixed
Supported by the .NET Compact Framework.
Gets the CellStyle used to paint fixed (nonscrollable) cells.
Focus
Supported by the .NET Compact Framework.
Gets the CellStyle used to paint the active cell
when the grid has the focus.
Frozen
Gets the stock CellStyle used to paint frozen cells.
Highlight
Supported by the .NET Compact Framework.
Gets the CellStyle used to highlight selected cells.
Item
Supported by the .NET Compact Framework.
Gets a reference to a style in the collection.
NewRow
Built-in style to display the new row template (only
used when AllowAddNew is set to true).
Normal
Supported by the .NET Compact Framework.
Gets the CellStyle used to paint regular scrollable
cells.
Search
Supported by the .NET Compact Framework.
Gets the CellStyle used to paint the current cell
during an AutoSearch
Alternate Property · 347
CellStyleCollection Class Public Methods
Add
Supported by the .NET Compact Framework.
Adds a custom style to the collection.
BuildString
Supported by the .NET Compact Framework.
Returns a compact string representation of all styles
defined in the collection.
Clear
Supported by the .NET Compact Framework.
Removes all custom styles from the collection and
resets the stock styles to their default values.
ClearUnused
This deletes styles that are unnamed and unused
Contains
Supported by the .NET Compact Framework.
Checks the collection contains a style with a given
name.
ParseString
Supported by the .NET Compact Framework.
Rebuilds the style collection based on the description
contained in a string.
Remove
Supported by the .NET Compact Framework.
Removes a custom style from the collection.
CellStyleCollection Properties
Alternate Property
Gets the stock CellStyle used to paint alternate rows.
Syntax
[VB]
Public Alternate As CellStyle
[C#]
public CellStyle Alternate {get;}
[Delphi]
property Alternate: CellStyle;
See Also
CellStyleCollection class (page 345)
Count Property (CellStyleCollection)
Gets the number of styles in the collection.
Syntax
[VB]
Public Count As Integer
[C#]
public int Count {get;}
348 · C1FlexGrid Reference
[Delphi]
property Count: Integer;
See Also
CellStyleCollection class (page 345)
Editor Property (CellStyleCollection)
Gets the stock CellStyle used to paint cells while they are edited.
Syntax
[VB]
Public Editor As CellStyle
[C#]
public CellStyle Editor {get;}
[Delphi]
property Editor: CellStyle;
Remarks
Elements in this style are applied to active cell editor controls. Not all editors support all style elements,
but most editors support at least the BackColor, ForeColor, and Font properties.
See Also
CellStyleCollection class (page 345)
EmptyArea Property
Gets the stock CellStyle used to paint the empty area of the grid.
Syntax
[VB]
Public EmptyArea As CellStyle
[C#]
public CellStyle EmptyArea {get;}
[Delphi]
property EmptyArea: CellStyle;
Remarks
Only the BackColor and Border elements of this style are used. They define the appearance of the space
between the last cell and the edge of the control.
The Border.Color element defines the color of the lines drawn around the edge of the sheet and between
frozen and scrollable cells.
Frozen Property · 349
See Also
CellStyleCollection class (page 345)
Frozen Property
Gets the stock CellStyle used to paint frozen cells.
Syntax
[VB]
Public Frozen As CellStyle
[C#]
public CellStyle Frozen {get;}
[Delphi]
property Frozen: CellStyle;
See Also
CellStyleCollection class (page 345)
AllowFreezing Property (page 111)
Fixed Property (CellStyleCollection)
Gets the stock CellStyle used to paint fixed (non-scrollable) cells.
Syntax
[VB]
Public Fixed As CellStyle
[C#]
public CellStyle Fixed {get;}
[Delphi]
property Fixed: CellStyle;
See Also
CellStyleCollection class (page 345)
Focus Property
Gets the stock CellStyle used to paint the active cell when the grid has the focus.
Syntax
[VB]
Public Focus As CellStyle
350 · C1FlexGrid Reference
[C#]
public CellStyle Focus {get;}
[Delphi]
property Focus: CellStyle;
See Also
CellStyleCollection class (page 345)
Highlight Property (CellStyleCollection)
Gets the stock CellStyle used to highlight selected cells.
Syntax
[VB]
Public Highlight As CellStyle
[C#]
public CellStyle Highlight {get;}
[Delphi]
property Highlight: CellStyle;
See Also
CellStyleCollection class (page 345)
Item Property (CellStyleCollection)
Gets a reference to a CellStyle object in the Styles collection, returns null if the style cannot be found.
Syntax
[VB]
Public Item (index As Integer) As CellStyle
Public Item(index As CellStyleEnum) As CellStyle
Public Item(name As String) As CellStyle
[C#]
public CellStyle this[int styleIndex]
public CellStyle this[CellStyleEnum styleType]
public CellStyle this[string styleName]
[Delphi]
property Item(index: Integer): CellStyle;
property Item(index: CellStyleEnum): CellStyle;
property Item(name: string): CellStyle;
NewRow Property · 351
See Also
CellStyleCollection class (page 345)
NewRow Property
Built-in style used to display the new row template (only used when AllowAddNew is set to True).
Syntax
[VB]
Public NewRow As CellStyle
[C#]
public CellStyle NewRow {get; }
[Delphi]
property NewRow: CellStyle;
Remarks
For example, the code below will display the new row template with a yellow background:
•
Visual Basic
_flex.Styles.NewRow.BackColor = Color.Yellow
•
C#
_flex.Styles.NewRow.BackColor = Color.Yellow;
•
Delphi
_flex.Styles.NewRow.BackColor := Color.Yellow;
See Also
CellStyleCollection class (page 345)
Normal Property
Gets the stock CellStyle used to paint regular scrollable cells.
Syntax
[VB]
Public Normal As CellStyle
[C#]
public CellStyle Normal {get;}
[Delphi]
property Normal: CellStyle;
Remarks
This is the parent style for most cells. Setting the control's BackColor, ForeColor, or Font properties
automatically sets the corresponding properties on the Normal style.
352 · C1FlexGrid Reference
If you change any properties in the Normal style, the changes will be reflected in all styles that do not
explicitly override those properties. For example, the following code causes the grid to use a regular
"Arial" font for all cells, a bold font for fixed cells, and an underlined font for the cell with the focus:
•
Visual Basic
flex.Styles.Normal.Font = New Font("Arial", 9)
flex.Styles.Fixed.Font = New Font("Arial", 9, FontStyle.Bold)
flex.Styles.Focus.Font = New Font("Arial", 9, FontStyle.Underline)
•
C#
flex.Styles.Normal.Font = new Font("Arial", 9);
flex.Styles.Fixed.Font = new Font("Arial", 9, FontStyle.Bold);
flex.Styles.Focus.Font = new Font("Arial", 9, FontStyle.Underline);
•
Delphi
flex.Styles.Normal.Font := Font.Create('Arial', 9);
flex.Styles.Fixed.Font := Font.Create('Arial', 9, FontStyle.Bold);
flex.Styles.Focus.Font := Font.Create('Arial', 9, FontStyle.Underline);
See Also
CellStyleCollection class (page 345)
Search Property
Gets the stock CellStyle used to paint the current cell during an AutoSearch.
Syntax
[VB]
Public Search As CellStyle
[C# ]
public CellStyle Search {get;}
[Delphi]
property Search: CellStyle;
Remarks
See also the AutoSearch property.
See Also
CellStyleCollection class (page 345)
CellStyleCollection Methods
Add Method (CellStyleCollection)
Adds a custom style to the collection.
BuildString Method · 353
Syntax
[VB]
Public Function Add(name As String) As CellStyle
Public Function Add(name As String, basedOn As CellStyle) As CellStyle
[C#]
public CellStyle Add (String name )
public CellStyle Add (String name , CellStyle basedOn )
[Delphi]
function Add(name: string): CellStyle;
function Add(name: string; basedOn: CellStyle): CellStyle;
Parameter
Description
styleName
The name for the new style. The name must be unique in the collection, and should
contain only alphanumeric characters or spaces.
basedOn
An existing style to inherit from. If omitted, the new style is based on the Style’s
Normal stock style.
Remarks
If the styleName parameter is provided, it must be unique and it may not contain curly brackets ("{" or
"}").
If the styleName parameter is set to null, a unique "anonymous" style is created. This type of style is not
added to the style collection and therefore cannot be accessed by name or index. This is useful in
applications that create and maintain their own style collections.
See Also
CellStyleCollection class (page 345)
BuildString Method
Returns a compact string representation of all styles defined in the collection.
Syntax
[VB]
Public Function BuildString(includeEmpty As Boolean) As String
[C#]
public String BuildString (Boolean includeEmpty )
[Delphi]
function BuildString(includeEmpty: Boolean): string;
354 · C1FlexGrid Reference
Parameter
Description
includeEmpties
A boolean value that specifies whether empty styles should be included in the
string definition. Empty styles have names, but do not define any properties. They
can be used as placeholders.
Remarks
Strings created with the BuildString method can be later applied using the ParseString method. This
provides an easy way to store and apply style collections as templates (also called "skins").
See Also
CellStyleCollection class (page 345)
Clear Method (CellStyleCollection)
Removes all custom styles from the collection and resets the stock styles to their default values.
Syntax
[VB]
Public Sub Clear()
[C#]
public void Clear ( )
[Delphi]
procedure Clear;
Remarks
The Clear method also removes any custom styles assigned to rows, columns, and cells.
See Also
CellStyleCollection class (page 345)
ClearUnused Method
This deletes styles that are unnamed and unused
Syntax
[VB]
Public Sub ClearUnused()
[C#]
public void ClearUnused ( )
[Delphi]
procedure ClearUnused;
Contains Method (CellStyleCollection) · 355
Remarks
It is created with StyleNew and no longer assigned to any rows, columns, or cell ranges.
See Also
CellStyleCollection class (page 345)
Contains Method (CellStyleCollection)
Checks the collection contains a style with a given name.
Syntax
[VB]
Public Function Contains(name As String) As Boolean
[C#]
public Boolean Contains (String name )
[Delphi]
function Contains(name: string): Boolean;
See Also
CellStyleCollection class (page 345)
ParseString Method (CellStyleCollection)
Rebuilds the style collection based on the description contained in a string.
Syntax
[VB]
Public Function ParseString(str As String) As Boolean
[C#]
public Boolean ParseString (String str )
[Delphi]
function ParseString(str: string): Boolean;
Parameter
Description
styleDefinition
A string returned by a cell to the BuildString method, containing a description of a
style collection.
Remarks
The ParseString method does not remove existing styles that are not defined in the style definition string.
To reset the current style collection, use the Clear method before calling ParseString.
See Also
CellStyleCollection class (page 345)
356 · C1FlexGrid Reference
Remove Method (CellStyleCollection)
Removes a custom style from the collection.
Syntax
[VB]
Public Sub Remove(index As Integer)
Public Sub Remove(style As CellStyle)
[C#]
public void Remove ( int index )
public void Remove (CellStyle style )
[Delphi]
procedure Remove(index: Integer);
procedure Remove(style: CellStyle);
Parameter
Description
index
The index of the style to remove. Because the style must be a custom style, the
index must be greater than or equal to (int)CellStyleEnum FirstCustomStyle.
name
The name of the style to remove.
Remarks
Only custom styles can be removed from the collection. The Remove method removes the custom style
from the collection and from any rows, columns, or cells that use it.
See Also
CellStyleCollection class (page 345)
CellStyle class
CellStyle objects contains formatting information used to render grid cells. This information includes the
background and foreground colors, font, text and image alignment, etc. The Styles property manages the
collection of all grid styles, and has methods that allow you to create and remove styles from the grid.
Individual styles may be assigned to CellRange, Row, and Column objects.
Styles follow a hierarchical model similar to styles in Microsoft Word or in cascading style sheets. Every
property in a CellStyle object may be left unassigned, in which case the value is inherited from a parent
style. The parent style is usually the built-in Normal style. To determine which elements are defined in a
particular style, use the DefinedElements property.
When you modify the properties of a CellStyle object, all cells that use that style are repainted to reflect
the changes.
CellStyle class · 357
All CellStyle Members
CellStyle Class Public Properties
BackColor
Supported by the .NET Compact Framework.
Gets or sets the color used to paint the cell
background.
Border
Supported by the .NET Compact Framework.
Gets the CellBorder object used to paint the cell
borders.
ComboList
Gets or sets the ComboList used to edit the cell.
DataMap
Gets or sets the DataMap used to associate values
stored in cells with display values.
DefinedElements
Supported by the .NET Compact Framework.
Gets or sets which elements are defined in this
CellStyle
Display
Gets or sets whether to display text and/or images
in the cell and also how to layout these elements in
the cell.
EditMask
Gets or sets the edit mask used to edit the cell.
Editor
Gets or sets the custom editor used to edit the cell.
Font
Supported by the .NET Compact Framework.
Gets or sets the font used to paint text in the cell.
ForeColor
Supported by the .NET Compact Framework.
Gets or sets the color of the text in the cell.
Format
Gets or sets the format used to convert cell values
into display strings.
ImageAlign
Supported by the .NET Compact Framework.
Gets or sets the image alignment for the cell.
ImageMap
Gets or sets the ImageMap used to associate
values stored in cells with images to be displayed in
the cell.
ImageSpacing
Supported by the .NET Compact Framework.
Gets or sets the spacing between the image and
text in the cell, in pixels.
Margins
Supported by the .NET Compact Framework.
Gets or sets the margins between the edges of the
cell and its contents, in pixels.
Name
Supported by the .NET Compact Framework.
Gets or sets the name for this CellStyle.
TextAlign
Supported by the .NET Compact Framework.
Gets or sets the text alignment for the cell.
TextDirection
Allows text to be displayed in the vertical direction
(up or down along the cell).
TextEffect
Supported by the .NET Compact Framework.
Gets or sets the 3D effect used for drawing text in
the cell.
Trimming
Supported by the .NET Compact Framework.
Specifies how to trim text that is too long to fit in the
cell.
358 · C1FlexGrid Reference
UserData
Gets or sets arbitrary data associated with this
CellStyle.
WordWrap
Supported by the .NET Compact Framework.
Specifies whether long strings are allowed to wrap
within the cell.
CellStyle Class Public Methods
BuildString
Supported by the .NET Compact Framework.
Returns a compact string representation of
thisCellStyle.
Clear
Supported by the .NET Compact Framework.
Clears selected elements from this CellStyle.
MergeWith
Copies all elements defined in a source CellStyle to
this CellStyle. Style elements not present in the
source CellStyle are preserved.
ParseString
Supported by the .NET Compact Framework.
Rebuilds this CellStyle based on a description
contained in a string.
Render
Renders strings and images into a Graphics object
using the attributes defined in this CellStyle.
CellStyle Properties
BackColor Property
Gets or sets the color used to paint the cell background.
Syntax
[VB]
Public BackColor As Color
[C# ]
public Color BackColor {get; set;}
[Delphi]
property BackColor: Color;
See Also
CellStyle class (page 356)
Border Property
Gets the CellBorder object used to paint the cell borders.
Syntax
[VB]
Public Border As CellBorder
ComboList Property (CellStyle) · 359
[C#]
public CellBorder Border {get;}
[Delphi]
property Border: CellBorder;
Remarks
The CellBorder object allows you to define the border style, color, and thickness.
See Also
CellStyle class (page 356)
ComboList Property (CellStyle)
Gets or sets the ComboList used to edit the cell.
Syntax
[VB]
Public ComboList As String
[C#]
public string ComboList {get; set}
[Delphi]
property ComboList: string;
Remarks
•
Visual Basic
Dim s As CellStyle = _flex.Styles.Add("TheList")
s.ComboList = "Fiat|Mercedes|Porsche|Pontiac"
Dim r As CellRange = _flex.GetCellRange(10, 10)
rg.Style = s
•
C#
CellStyle s = _flex.Styles.Add("TheList");
s.ComboList = "Fiat|Mercedes|Porsche|Pontiac";
CellRange r = _flex.GetCellRange(10,10);
rg.Style = s;
•
Delphi
var
r: CellRange;
s: CellStyle;
begin
s := _flex.Styles.Add('TheList');
s.ComboList := 'Fiat|Mercedes|Porsche|Pontiac';
r := _flex.GetCellRange(10, 10);
rg.Style := s;
end;
See Also
CellStyle class (page 356)
360 · C1FlexGrid Reference
DataMap Property (CellStyle)
Gets or sets the DataMap for individual cells and ranges (as opposed to the whole grid, or by
row/column, which are still available).
Syntax
[VB]
Public DataMap As IDictionary
[C#]
public IDictionary DataMap {get; set;}
[Delphi]
property DataMap: IDictionary;
Remarks
For details and examples, see the Column.DataMap property.
See Also
CellStyle class (page 356)
DefinedElements Property
Gets or sets which elements are defined in this CellStyle (other elements are inherited from the parent
CellStyle).
Syntax
[VB]
Public DefinedElements As StyleElementFlags
[C#]
public StyleElementFlags DefinedElements {get; set;}
[Delphi]
property DefinedElements: StyleElementFlags;
Remarks
Elements that are not defined in a particular style are automatically inherited from the parent style
(usually the Normal style). For example, if you create a custom style that defines the Font property, all
other elements (back color, alignment, etc) are inherited from the Normal style.
See Also
CellStyle class (page 356)
Display Property
Gets or sets whether to display text and/or images in the cell and also how to layout these elements in the
cell.
Editor Property (CellStyle) · 361
Syntax
[VB]
Public Display As DisplayEnum
[C#]
public DisplayEnum Display {get; set;}
[Delphi]
property Display: DisplayEnum;
See Also
CellStyle class (page 356)
Editor Property (CellStyle)
Gets or sets the custom editor used to edit cells that have this style.
Syntax
[VB]
Public Editor As Control
[C#]
public Control Editor {get;set;}
[Delphi]
property Editor: Control;
Remarks
The grid provides several built-in editors that are automatically selected based on the properties of the
cell being edited.
This property allows you to use external editors when editing values that have a given CellStyle. Any
control can be used as an external editor, but to achieve complete integration with the grid, the external
editor should implement the IC1EmbeddedEditor interface.
For details, see the Editor property.
See Also
IC1EmbeddedEditor Interface (page 423)
EditMask Property
Gets or sets the edit mask used to edit the cell.
Syntax
[VB]
Public EditMask As String
362 · C1FlexGrid Reference
[C#]
public string EditMask {get; set}
[Delphi]
property EditMask: string;
Remarks
•
Visual Basic
Dim s As CellStyle = _flex.Styles.Add("TheMask")
s.EditMask = "##-##-####"
Dim r As CellRange = _flex.GetCellRange(10, 10)
rg.Style = s
•
C#
CellStyle s = _flex.Styles.Add("TheMask");
s.EditMask = "##-##-####";
CellRange r = _flex.GetCellRange(10,10);
rg.Style = s;
•
Delphi
var
r: CellRange;
s: CellStyle;
begin
s := _flex.Styles.Add('TheMask');
s.EditMask := '##-##-####';
r := _flex.GetCellRange(10, 10);
rg.Style := s;
end;
See Also
CellStyle class (page 356)
Font Property (CellStyle)
Gets or sets the font used to paint text in the cell.
Syntax
[VB]
Public Font As Font
[C#]
public Font Font {get; set;}
[Delphi]
property Font: Font;
Remarks
Setting the control's Font property automatically sets the Font property of the Normal style.
See Also
CellStyle class (page 356)
ForeColor Property · 363
ForeColor Property
Gets or sets the color of the text in the cell.
Syntax
[VB]
Public ForeColor As Color
[C#]
public Color ForeColor {get; set;}
[Delphi]
property ForeColor: Color;
Remarks
Setting the control's ForeColor property automatically sets the ForeColor property of the Normal style.
See Also
CellStyle class (page 356)
Format Property (CellStyle)
Gets or sets the format used to convert cell values into display strings.
Syntax
[VB]
Public Format As String
[C#]
public string Format {get; set}
[Delphi]
property Format: string;
Remarks
•
Visual Basic
Dim s As
s.Format
Dim r As
rg.Style
•
CellStyle = _flex.Styles.Add("BigNumber")
= "#,##0.##"
CellRange = _flex.GetCellRange(10, 10)
= s
C#
CellStyle s = _flex.Styles.Add("BigNumber");
s.Format = "#,##0.##";
CellRange r = _flex.GetCellRange(10,10);
rg.Style = s;
•
Delphi
var
r: CellRange;
s: CellStyle;
364 · C1FlexGrid Reference
begin
s := _flex.Styles.Add('BigNumber');
s.Format := '#,##0.##';
r := _flex.GetCellRange(10, 10);
rg.Style := s;
end;
See Also
CellStyle class (page 356)
ImageAlign Property (CellStyle)
Gets or sets the image alignment for the cell.
Syntax
[VB]
Public ImageAlign As ImageAlignEnum
[C#]
public ImageAlignEnum ImageAlign {get; set;}
[Delphi]
property ImageAlign: ImageAlignEnum;
Property Value
One of the ImageAlignEnum values. The default is ImageAlignEnum.LeftCenter.
See Also
CellStyle class (page 356)
ImageMap Property
Gets or sets the ImageMap used to associate values stored in cells with images to be displayed in the cell.
Syntax
[VB]
Public ImageMap As Idictionary
[C#]
public.Idictionary ImageMap {get; set;}
[Delphi]
property ImageMap: Idictionary;
See Also
CellStyle class (page 356)
ImageMap Property (Column) (page 334)
ImageSpacing Property · 365
ImageSpacing Property
Gets or sets the spacing between the image and text in the cell, in pixels.
Syntax
[VB]
Public ImageSpacing As Integer
[C#]
public int ImageSpacing {get; set;}
[Delphi]
property ImageSpacing: Integer;
See Also
CellStyle class (page 356)
Margins Property
Gets or sets the margins between the edges of the cell and its contents, in pixels.
Syntax
[VB]
Public Margins As Margins
[C#]
public Margins Margins {get; set;}
[Delphi]
property Margins: Margins;
See Also
CellStyle class (page 356)
Name Property (CellStyle)
Gets or sets the name for this CellStyle.
Syntax
[VB]
Public Name As String
[C#]
public string Name {get; set}
[Delphi]
property Name: string;
366 · C1FlexGrid Reference
Remarks
The style name must be unique and must not contain curly brackets.
See Also
CellStyle class (page 356)
TextAlign Property (CellStyle)
Gets or sets the text alignment for the cell.
Syntax
[VB]
Public TextAlign As TextAlignEnum
[C#]
public TextAlignEnum TextAlign {get; set;}
[Delphi]
property TextAlign: TextAlignEnum;
Property Value
One of the TextAlignEnum values. The default is TextAlignEnum.GeneralCenter.
See Also
CellStyle class (page 356)
TextDirection Property
Allows text to be displayed in the vertical direction (up or down along the cell).
Syntax
[VB]
Public Property TextDirection As TextDirectionEnum
[C#]
public TextDirectionEnum TextDirection {get; set;}
[Delphi]
property TextDirection: TextDirectionEnum;
Remarks
Cells containing vertical text can wrap and be autosized as usual.
See Also
CellStyle class (page 356)
TextEffect Property
Gets or sets the 3D effect used for drawing text in the cell.
Trimming Property · 367
Syntax
[VB]
Public TextEffect As TextEffectEnum
[C#]
public TextEffectEnum TextEffect {get; set;}
[Delphi]
property TextEffect: TextEffectEnum;
Property Value
One of the TextEffectEnum values. The default is TextEffectEnum.Flat.
See Also
CellStyle class (page 356)
Trimming Property
Specifies how to trim text that is too long to fit in the cell.
Syntax
[VB]
Public Trimming As StringTrimming
[C#]
public StringTrimming Trimming {get; set;}
[Delphi]
property Trimming: StringTrimming;
Property Value
One of the StringTrimming values. The default is StringTrimming.None.
Remarks
The StringTrimming enumeration is defined in the System.Drawing namespace.
See Also
CellStyle class (page 356)
UserData Property (CellStyle)
Gets or sets user data associated with this CellStyle.
Syntax
[VB]
Public UserData As Object
368 · C1FlexGrid Reference
[C#]
public object UserData {get; set;}
[Delphi]
property UserData: Object;
Remarks
The UserData value is not used internally by the grid. It is reserved for additional data that you may
want to associate with a row.
See Also
CellStyle class (page 356)
WordWrap Property
Specifies whether long strings are allowed to wrap within the cell.
Syntax
[VB]
Public WordWrap As Boolean
[C#]
public bool WordWrap {get; set;}
[Delphi]
property WordWrap: Boolean;
Remarks
The WordWrap property controls soft line breaks. Strings that contains line break characters are always
wrapped.
See Also
CellStyle class (page 356)
CellStyle Methods
BuildString Method (CellStyle)
Returns a compact string representation of this CellStyle.
Syntax
[VB]
Public Function BuildString() As String
[C#]
public String BuildString ( )
[Delphi]
function BuildString: string;
Clear Method (CellStyle) · 369
Remarks
The string representation includes only elements defined in this style. To apply the string representation
to an existing CellStyle, use the ParseString method.
See Also
CellStyle class (page 356)
Clear Method (CellStyle)
Clears selected elements from this CellStyle.
Syntax
[VB]
Public Sub Clear(flags StyleElementFlags)
[C# ]
public void Clear (StyleElementFlags flags )
[Delphi]
procedure Clear(flags: StyleElementFlags);
Parameter
Description
flags
Contains a combination of flags that determine which style elements are to be
removed from the style. If omitted, all elements are removed.
See Also
CellStyle class (page 356)
MergeWith Method
Copies all elements defined in a source CellStyle to this CellStyle. Style elements not present in the
source CellStyle are preserved.
Syntax
[VB]
Public Sub MergeWith(sourceStyle As CellStyle)
[C# ]
public void MergeWith (CellStyle sourceStyle )
[Delphi]
procedure MergeWith(sourceStyle: CellStyle);
Remarks
This method allows you to apply visual styles to rows and columns without disturbing existing style
attributes such as ComboList and Format.
370 · C1FlexGrid Reference
•
Visual Basic
' add a combo box to a column (saved with the column style)
_flex.Cols(2).ComboList = "A|B|C|D|E|F"
' apply a new style to the column without disturbing the combo
_flex.Cols(2).Style.MergeWith(flex.Styles.Frozen)
' ** this wouldn't work, it would remove the ComboList saved with the
column style
'_ flex.Cols(2).Style = flex.Styles.Frozen
•
C#
' add a combo box to a column (saved with the column style)
_flex.Cols[2].ComboList = "A|B|C|D|E|F";
' apply a new style to the column without disturbing the combo
_flex.Cols[2].Style.MergeWith(flex.Styles.Frozen);
' ** this wouldn't work, it would remove the ComboList saved with the
column style
'_flex.Cols[2].Style = flex.Styles.Frozen;
•
Delphi
// add a combo box to a column (saved with the column style)
_flex.Cols[2].ComboList := 'A|B|C|D|E|F';
// apply a new style to the column without disturbing the combo
_flex.Cols[2].Style.MergeWith(flex.Styles.Frozen);
// ** this wouldn't work, it would remove the ComboList saved with the
column style
//_ flex.Cols(2).Style = flex.Styles.Frozen
See Also
CellStyle class (page 356)
ParseString Method (CellStyle)
Rebuilds this CellStyle based on a description contained in a string.
Syntax
[VB]
Public Function ParseString(str As String) As Boolean
[C#]
public Boolean ParseString(string str)
[Delphi]
function ParseString(str: string): Boolean;
Parameter
Description
styleDefinition
A string returned by a cell to the BuildString method, containing a description of a
style.
Render Method · 371
Remarks
The ParseString method does not remove existing elements that are not defined in the style definition
string. To reset the current style, use the Clear method before calling ParseString.
See Also
CellStyle class (page 356)
Render Method
Renders strings and images into a Graphics object using the attributes defined in this CellStyle.
Syntax
[VB]
Public Sub Render(g As Graphics, rc As Rectangle, s as String, img As Image, DrawCellFlags flags)
Public Sub Render(g As Graphics, rc As Rectangle, s as String, img As Image)
Public Sub Render(g As Graphics, rc As Rectangle, s as String)
Public Sub Render(g As Graphics, rc As Rectangle, img As Image)
[C#]
public void Render(Graphics g, Rectangle rc, string s, Image img, DrawCellFlags flags);
public void Render(Graphics g, Rectangle rc, string s, Image img);
public void Render(Graphics g, Rectangle rc, string s);
public void Render(Graphics g, Rectangle rc, Image img);
[Delphi]
procedure Render(g: Graphics, rc: Rectangle, s: String, img: Image, DrawCellFlags flags);
procedure Render(g: Graphics, rc: Rectangle, s: String, img: Image);
procedure Render(g: Graphics, rc: Rectangle, s: String);
procedure Render(g: Graphics, rc: Rectangle, img: Image);
Parameter
Description
g
The Graphics object in which to render the text and image.
rc
The Rectangle in which to render the text and image.
s
The text to render.
img
The image to render.
flags
Combination of one or more style elements to render (background, borders,
content). If omitted, all elements are rendered.
372 · C1FlexGrid Reference
Remarks
This method is used internally by the grid to render all cells. It provides a convenient mechanism for
reusing CellStyle objects to render text and images into other controls.
See Also
CellStyle class (page 356)
CellBorder class
The CellBorder class defines the appearance of the border in a CellStyle object. The CellBorder defines
the appearance of the grid lines in the control, and can be obtained using the CellStyle’s Border property.
All CellBorder Members
CellBorder Class Public Properties
Direction
Supported by the .NET Compact Framework.
Specifies the direction of the border.
Color
Supported by the .NET Compact Framework.
Specifies the color of the border.
Style
Specifies the type of border to be drawn around the cell.
Width
Supported by the .NET Compact Framework.
Specifies the width of the border, in pixels.
CellBorder Properties
Direction Property
Specifies the direction of the border.
Syntax
[VB]
Public Direction As BorderDirEnum
[C#]
public BorderDirEnum Direction {get; set;}
[Delphi]
property Direction: BorderDirEnum;
Property Value
One of the BorderStyleEnum values. The default is BorderStyleEnum.Both.
See Also
CellBorder class (page 372)
Color Property · 373
Color Property
Specifies the color of the border.
Syntax
[VB]
Public Color As Color
[C#]
public Color Color {get; set;}
[Delphi]
property Color: Color;
Remarks
The Color property has no effect on 3D borders, which are drawn using system colors.
See Also
CellBorder class (page 372)
Style Property
Specifies the type of border to be drawn around the cell.
Syntax
[VB]
Public Style As BorderStyleEnum
[C#]
public BorderStyleEnum Style {get; set;}
[Delphi]
property Style: BorderStyleEnum;
Property Value
One of the BorderStyleEnum values. The default is BorderStyleEnum.Flat.
See Also
CellBorder class (page 372)
Width Property (CellBorder)
Specifies the width of the border, in pixels.
Syntax
[VB]
Public Width As Integer
374 · C1FlexGrid Reference
[C#]
public int Width {get; set;}
[Delphi]
property Width: Integer;
Remarks
The Width property has no effect on 3D borders, which are drawn using predefined widths (1 or 2 pixels
depending on border type).
See Also
CellBorder class (page 372)
Node class
When you use the C1FlexGrid control as an outliner, rows can be used as outline nodes. The Node class
exposes properties that allow you to manipulate these rows, collapsing, expanding. moving, or sorting
them. You can create node rows using the Subtotal method or by setting the Row’s IsNode property to
true.
All Node Members
Node Class Public Properties
Children
Supported by the .NET Compact Framework.
Gets the number of child nodes under this node.
Collapsed
Supported by the .NET Compact Framework.
Gets or sets whether this node is collapsed.
Data
Supported by the .NET Compact Framework.
Gets or sets the data on this node row at the column
that contains the outline tree.
Expanded
Supported by the .NET Compact Framework.
Gets or sets whether this node is collapsed.
Image
Supported by the .NET Compact Framework.
Gets or sets the image on this node row at the
column that contains the outline tree.
Key
Supported by the .NET Compact Framework.
Gets or sets the Row’s UserData on this node row.
Level
Supported by the .NET Compact Framework.
Gets or sets the outline level for this node.
Row
Supported by the .NET Compact Framework.
Returns a reference to the Row object that
corresponds to this node.
Node Class Public Methods
AddNode
Supported by the .NET Compact Framework.
Creates a node row at a specified position relative to
this node.
EnsureVisible
Supported by the .NET Compact Framework.
Ensures that this node is visible, expanding its parent
nodes and scrolling it into view if necessary.
Children Property · 375
GetCellRange
Supported by the .NET Compact Framework.
Returns a CellRange object containing this row and
all its child rows.
GetNode
Supported by the .NET Compact Framework.
Returns a reference to a node located at a given
position relative to this node.
Move
Supported by the .NET Compact Framework.
Moves a mode to a new position.
RemoveNode
Supported by the .NET Compact Framework.
Removes this node row and all its child rows (nodes
and data) from the grid.
Select
Supported by the .NET Compact Framework.
Selects the current node.
Sort
Supported by the .NET Compact Framework.
Sorts the current node in the specified order.
Node Properties
Children Property
Gets the number of child nodes under this node. (Grand-child nodes are not included in the count).
Syntax
[VB]
Public Children As Integer
[C#]
public int Children {get;}
[Delphi]
property Children: Integer;
Remarks
See the Creating Custom Trees (page 48 )topic and the Outline Tutorial (page 81 )for examples that shows
how to use Node objects.
See Also
Node class (page 374)
Collapsed Property
Gets or sets whether this node is collapsed.
Syntax
[VB]
Public Collapsed As Boolean
[C#]
public bool Collapsed {get; set;}
376 · C1FlexGrid Reference
[Delphi]
property Collapsed: Boolean;
Remarks
See the Creating Custom Trees (page 48 )topic and the Outline Tutorial (page 81 )for examples that shows
how to use Node objects.
See Also
Node class (page 374)
Data Property (Node)
Gets or sets the grid data for the row that corresponds to this node and the column that contains the
outline tree.
Syntax
[VB]
Public Data As Object
[C#]
public object Data {get; set;}
[Delphi]
property Data: Object;
Remarks
The code below shows the relationship between the Node.Data property and the grid's GetData and
SetData methods:
•
Visual Basic
Dim o1 As Object = node.Data
Dim row As Integer = nd.Row.SafeIndex
Dim col As Integer = flex.Tree.Column
Dim o2 As Object = flex(row, col)
Debug.Assert(o1.Equals(o2), "o1 and o2 refer to the same object")
•
C#
object o1 = node.Data;
int row = nd.Row.SafeIndex;
int col = flex.Tree.Column;
object o2 = flex[row, col];
Debug.Assert(o1.Equals(o2), "o1 and o2 refer to the same object");
•
Delphi
var
o2: System.Object;
col: Integer;
row: Integer;
o1: System.Object;
begin
o1 := node.Data;
row := nd.Row.SafeIndex;
Expanded Property · 377
col := flex.Tree.Column;
o2 := flex[row];
Debug.Assert(o1.Equals(o2), 'o1 and o2 refer to the same object');
end;
See Also
Node class (page 374)
Expanded Property
Gets or sets whether this node is expanded.
Syntax
[VB]
Public Expanded As Boolean
[C#]
public bool Expanded {get; set;}
[Delphi]
property Expanded: Boolean;
Remarks
See the Creating Custom Trees (page 48 )topic and the Outline Tutorial (page 81 )for examples that shows
how to use Node objects.
See Also
Node class (page 374)
Image Property (Node)
Gets or sets the image on this node row at the column that contains the outline tree.
Syntax
[VB]
Public Image As Image
[C#]
public Image Image {get; set;}
[Delphi]
property Image: Image;
Remarks
The code below shows the relationship between the Node.Image property and the grid's GetCellImage
and SetCellImage methods:
•
Visual Basic
Dim img1 As Image = node.Image
Dim row As Integer = nd.Row.SafeIndex
378 · C1FlexGrid Reference
Dim col As Integer = flex.Tree.Column
Dim img2 As Image = flex.GetCellImage(row, col)
Debug.Assert(img1.Equals(img2), "img1 and img2 are the same image")
•
C#
Image img1 = node.Image;
int row = nd.Row.SafeIndex;
int col = flex.Tree.Column;
Image img2 = flex.GetCellImage(row, col);
Debug.Assert(img1.Equals(img2), "img1 and img2 are the same image");
•
Delphi
var
img2: Image;
col: Integer;
row: Integer;
img1: Image;
begin
img1 := node.Image;
row := nd.Row.SafeIndex;
col := flex.Tree.Column;
img2 := flex.GetCellImage(row, col);
Debug.Assert(img1.Equals(img2), 'img1 and img2 are the same image');
end;
See Also
Node class (page 374)
Key Property
Gets or sets the Row’s UserData on this node row.
Syntax
[VB]
Public Key As Object
[C#]
public object Key {get; set;}
[Delphi]
property Key: Object;
Remarks
The code below shows the relationship between the Node.Key property and the Row.UserData property:
•
Visual Basic
Dim o1 As Object = node.Key
Dim o2 As Object = nd.Row.UserData
Debug.Assert(o1.Equals(o2), "o1 and o2 refer to the same object")
•
C#
object o1 = node.Key;
object o2 = nd.Row.UserData;
Debug.Assert(o1.Equals(o2), "o1 and o2 refer to the same object");
Level Property · 379
•
Delphi
var
o2: System.Object;
o1: System.Object;
begin
o1 := node.Key;
o2 := nd.Row.UserData;
Debug.Assert(o1.Equals(o2), 'o1 and o2 refer to the same object');
end;
See Also
Node class (page 374)
Level Property
Gets or sets the outline level for this node.
Syntax
[VB]
Public Level As Integer
[C#]
public int Level {get; set;}
[Delphi]
property Level: Integer;
Remarks
Higher levels mean deeper nesting. Set the level to zero to create root nodes, or set the level to negative
values to create nodes that do not appear on the outline tree.
See the Creating Custom Trees (page 48) topic and the Outline Tutorial (page 81) for examples that shows
how to use Node objects.
See Also
Node class (page 374)
Row Property (Node)
Returns a reference to the Row object that corresponds to this node.
Syntax
[VB]
Public Row As Row
[C#]
public Row Row {get;}
[Delphi]
property Row: Row;
380 · C1FlexGrid Reference
See Also
Node class (page 374)
Node Methods
AddNode Method
Creates a node row at a specified position relative to this node.
Syntax
[VB]
Public Function AddNode(position As NodeTypeEnum, data As Object) As Node
Public Function AddNode(position As NodeTypeEnum, data As Object, key As Object, img As Image)
As Node
[C#]
public Node AddNode (NodeTypeEnum position , Object data , Object key , Image img )
public Node AddNode (NodeTypeEnum position , Object data )
[Delphi]
function AddNode(position: NodeTypeEnum; data: Object): Node;
function AddNode(position: NodeTypeEnum; data: Object; key: Object; img: Image): Node;
Parameter
Description
position
A value from the NodeTypeEnum enumeration that specifies where the new node
will be added with respect to this node (e.g. Child, Sibling).
data
Value of the Data property for the new node.
key
Value of the Key property for the new node.
image
Value of the Image property for the new node.
Return Value
A reference to the new Node added to the grid.
See Also
Node class (page 374)
EnsureVisible Method
Ensures that this node is visible, expanding its parent nodes and scrolling it into view if necessary.
Syntax
[VB]
Public Sub EnsureVisible()
GetCellRange Method (Node) · 381
[C#]
public void EnsureVisible ( )
[Delphi]
procedure EnsureVisible;
See Also
Node class (page 374)
GetCellRange Method (Node)
Returns a CellRange object containing this row and all its child rows (nodes and data rows).
Syntax
[VB]
Public Function GetCellRange() As CellRange
[C#]
public CellRange GetCellRange ( )
[Delphi]
function GetCellRange: CellRange;
Remarks
The CellRange object returned includes all columns.
See Also
Node class (page 374)
GetNode Method
Returns a reference to a node located at a given position relative to this node (e.g. first child, last sibling).
Syntax
[VB]
Public Function GetNode(position As NodeTypeEnum) As Node
[C#]
public Node GetNode (NodeTypeEnum position )
[Delphi]
function GetNode(position: NodeTypeEnum): Node;
Remarks
If the node requested does not exist, GetNode returns null (e.g. the root node does not have a previous
sibling).
382 · C1FlexGrid Reference
See Also
C1FlexGridClassic Class (page 429)
Node class (page 374)
Move Method
Syntax
[VB]
Public Function Move(moveTo As NodeMoveEnum, targetNode As Node) As Boolean
Public Function Move(moveTo As NodeMoveEnum) As Boolean
[C#]
public Boolean Move (NodeMoveEnum moveTo , Node targetNode )
public Boolean Move (NodeMoveEnum moveTo )
[Delphi]
function Move(moveTo: NodeMoveEnum; tragetNode: Node): Boolean;
function Move(moveTo: NodeMoveEnum): Boolean;
Parameter
Description
moveTo
A value from the NodeMoveEnum enumeration that specifies where the node will
be moved with respect to its current position.
targetNode
Node object to use as a target when the moveTo parameter is set to
NodeMoveEnum.ChildOf.
Return Value
Returns true if the method was successful, false otherwise.
See Also
Node class (page 374)
RemoveNode Method
Removes this node row and all its child rows (nodes and data) from the grid.
Syntax
[VB]
Public Sub RemoveNode()
[C#]
public void RemoveNode ( )
Select Method (Node) · 383
[Delphi]
procedure RemoveNode;
See Also
Node class (page 374)
Select Method (Node)
Selects the current node.
Syntax
[VB]
Public Sub Select()
[C#]
public void Select ( )
[Delphi]
procedure Select;
See Also
Node class (page 374)
Sort Method (Node)
Sorts the child nodes in the specified order.
Syntax
[VB]
Public Sub Sort(order As SortFlags)
Public Sub Sort(order As SortFlags, col1 As Integer, col2 As Integer)
[C#]
public void Sort (SortFlags order )
public void Sort (SortFlags order , int col1 , int col2 )
[Delphi]
procedure Sort(order: SortFlags);
procedure Sort(order: SortFlags; col1: Integer; col2: Integer);
Parameter
Description
order
One or more flags from the SortFlags enumeration that specify how the node is
sorted.
col
Index of the column that contains the data to be sorted. If not specified, the column
displaying the tree is used by default (this column is specified by the Tree’s
Column property).
384 · C1FlexGrid Reference
Remarks
This method does not affect the order of rows that are not nodes.
See Also
Node class (page 374)
GridGlyphs Class
The GridGlyphs class represents an array of glyphs (images) indexed by glyph type (GlyphEnum type).
It contains the images used by the grid to indicate column sorting, collapsed and expanded outline
groups, checkboxes, cursors, error information, etc.
Use the Glyphs property to retrieve a GridGlyphs object, and use the indexer to get or set the images.
All GridGlyphs Members
GridGlyphs Class Public Properties
Gets or sets the glyph for a particular GlyphEnum.
Item
GridGlyphs Properties
Item Property (GridGlyphs)
Image used by the grid to convey information about a row, column or cell.
Syntax
[VB]
Public Item(type As GlyphEnum) As Image
[C#]
public Image this[GlyphEnum type] {get;set;}
[Delphi]
property Item(type: GlyphEnum): Image;
Remarks
Use this property to modify the image used by the grid to convey information about a row, column or
cell. For example, the code below changes the images used by the grid to display the column sorting
order:
•
Visual Basic
_flex.Glyphs(GlyphEnum.Ascending) = imgAscending
_flex.Glyphs(GlyphEnum.Descending) = imgDescending
•
C#
_flex.Glyphs[GlyphEnum.Ascending] = imgAscending;
_flex.Glyphs[GlyphEnum.Descending] = imgDescending;
Column Property · 385
•
Delphi
_flex.Glyphs[GlyphEnum.Ascending] := imgAscending;
_flex.Glyphs[GlyphEnum.Descending] := imgDescending;
See Also
GridGlyphs class (page 384)
GridTree class
When you use the C1FlexGrid control as an outliner, rows can be used as outline nodes. The GridTree
class exposes properties that allow you to specify the appearance, position, and behavior of the outline
tree. Each grid has a single GridTree object, which can be obtained using the Tree property.
All GridTree Members
GridTree Class Public Properties
Column
Gets or sets the index of the column whether the outline tree
is displayed.
Indent
Gets or sets the indentation, in pixels, of each tree level.
LineColor
Gets or sets the color of the lines in the outline tree.
LineStyle
Determines the style used to draw the outline tree.
NodeImageCollapsed
Gets or sets the image displayed next to collapsed nodes.
NodeImageExpanded
Gets or sets the image displayed next to expanded nodes.
Style
Gets or sets the style of the outline tree.
GridTree Class Public Methods
Show
Expands all nodes up to the specified level, collapsed others.
Sort
Sorts all nodes a the given level.
GridTree Properties
Column Property
Gets or sets the index of the column whether the outline tree is displayed.
Syntax
[VB]
Public Column As Integer
[C#]
public int Column {get; set;}
386 · C1FlexGrid Reference
[Delphi]
propery Column: Integer;
Remarks
By default, this property is set to -1, which causes the tree to be hidden.
See Also
GridTree class (page 385)
Indent Property
Gets or sets the indentation, in pixels, of each tree level.
Syntax
[VB]
Public Indent As Integer
[C#]
public int Indent {get; set;}
[Delphi]
property Indent: Integer;
Remarks
If you set the Indent property to a value that is too narrow to fit the NodeImageCollapsed and
NodeImageExpanded images, the grid automatically adjusts it so that the images will fit.
See Also
GridTree class (page 385)
LineColor Property
Gets or sets the color of the lines in the outline tree.
Syntax
[VB]
Public LineColor As Color
[C#]
public Color LineColor {get; set;}
[Delphi]
property LineColor: Color;
Remarks
See also the Style property.
See Also
GridTree class (page 385)
LineStyle Property · 387
LineStyle Property
Determines the style used to draw the outline tree.
Syntax
[VB]
Public LineStyle As DashStyle
[C#]
public DashStyle LineStyle {get; set;}
[Delphi]
property LineStyle: DashStyle;
Remarks
Determines the style used to draw the outline tree. By default, this property is set to DashStyle.Dot,
which causes the tree to be drawn with dotted lines.
See Also
GridTree class (page 385)
NodeImageCollapsed Property
Gets or sets the image displayed next to collapsed nodes.
Syntax
[VB]
Public NodeImageCollapsed As Image
[C#]
public Image NodeImageCollapsed {get; set;}
[Delphi]
property NodeImageCollapsed: Image;
Remarks
Setting this property to null resets it and causes the grid to use the default image (a plus sign). To hide the
images, use the Tree.Style property.
See Also
GridTree class (page 385)
NodeImageExpanded Property
Gets or sets the image displayed next to expanded nodes.
Syntax
[VB]
Public NodeImageExpanded As Image
388 · C1FlexGrid Reference
[C#]
public Image NodeImageExpanded {get; set;}
[Delphi]
property NodeImageExpanded: Image;
Remarks
Setting this property to null resets it and causes the grid to use the default image (a minus sign). To hide
the images, use the Tree.Style property.
See Also
GridTree class (page 385)
Style Property (GridTree)
Gets or sets the style of the outline tree.
Syntax
[VB]
Public Style As TreeStyleFlags
[C#]
public TreeStyleFlags Style {get; set;}
[Delphi]
property Style: TreeStyleFlags;
Remarks
Use the Style property to determine whether the outline tree should include lines connecting the nodes
and buttons for collapsing and expanding the nodes. Use the Column property to determine where the
grid will show the outline tree.
See Also
GridTree class (page 385)
GridTree Methods
Show Method
Expands all nodes up to the specified level, collapsed others.
Syntax
[VB]
Public Sub Show(level As Integer)
[C#]
public void Show ( int level )
Sort Method (GridTree) · 389
[Delphi]
procedure Show(level: Integer);
Parameter
Description
level
The level to show. Any nodes with Level higher than this will be collapsed, others
will be expanded.
See Also
GridTree class (page 385)
Sort Method (GridTree)
Sorts all nodes a the given level.
Syntax
[VB]
Public Sub Sort(level As Integer, order As SortFlags, col1 As Integer, col2 As Integer)
[C#]
public void Sort ( int level , SortFlags order , int col1 , int col2 )
[Delphi]
procedure Sort(level: Integer; order: SortFlags; col12: Integer; col2: Integer);
Parameter
Description
level
The level to sort. Nodes at the given level will be sorted.
order
One or more values from the SortFlags enumeration that specify how the sorting
will be performed.
col1, col2
Range of columns containing the values to be sorted.
Remarks
The grid's Sort method sorts data rows within nodes. It does not move the node rows.
The Tree.Sort method sorts row nodes, moving the data rows with each node. For example, the code
below sorts a data tree in ascending order, based on the values stored in the "Sales" column:
•
Visual Basic
Private Sub SortTree(sf As SortFlags)
Dim col As Integer = flex.Cols("Sales").SafeIndex
flex.Tree.Sort(0, sf, col, col) ' << sort level 0 nodes
flex.Tree.Sort(1, sf, col, col) ' << sort level 1 nodes
flex.Tree.Show(0) ' << show levels 0 and 1
End Sub 'SortTree
390 · C1FlexGrid Reference
•
C#
private void SortTree(SortFlags sf)
{
int col = flex.Cols["Sales"].SafeIndex;
flex.Tree.Sort(0, sf, col, col); // << sort level 0 nodes
flex.Tree.Sort(1, sf, col, col); // << sort level 1 nodes
flex.Tree.Show(0);
// << show levels 0 and 1
}
•
Delphi
procedure Class1.SortTree(sf: SortFlags);
var
col: Integer;
begin
col := flex.Cols['Sales'].SafeIndex;
flex.Tree.Sort(0, sf, col, col);
flex.Tree.Sort(1, sf, col, col);
flex.Tree.Show(0);
end;
The pictures below show the effect of the code:
Tree sorted in ascending order, by Sales.
Tree sorted in descending order, by Sales.
Footer Property · 391
See Also
GridTree class (page 385)
GridPrinter Class
The PrintParameters property returns a reference to the GridPrinter object that manages printing the
grid. The GridPrinter object exposes properties that allow you to control low-level parameters that affect
printing, such as page and printer settings.
AllMembers
GridPrinter Class Public Properties
Footer
Allows you to customize the footer of the grid's PrintDocument.
FooterFont
Specifies the font to use for footers when the grid is printed with the
PrintGrid method.
Header
Allows you to customize the header of the grid's PrintDocument.
HeaderFont
Specifies the font to use for headers when the grid is printed with the
PrintGrid method.
PageNumber
Gets the number of the page being printed.
PageCount
Gets the total number of the pages in a print document.
PrintDocument
Gets the PrintDocument object that specifies the page and printer settings.
PrintPreviewDialog
Allows you to specify properties for the built-in PrintPreview dialog.
GridPrinter Properties
Footer Property
Allows you to customize the footer of the grid's PrintDocument in case you want to display the grid
preview in your own dialog.
Syntax
[VB]
Public Property Footer As String
[C#]
public string Footer {get; set;}
[Delphi]
property Footer: string;
Example
The following code customizes the footer of the grid’s PrintDocument.
392 · C1FlexGrid Reference
•
Visual Basic
Dim gp As GridPrinter = _flex.PrintParameters
gp.Footer = "Hello" + ControlChars.Tab + "World" + ControlChars.Tab +
"Footer"
gp.PrintGridFlags = C1.Win.C1FlexGrid.PrintGridFlags.FitToPageWidth
Dim dlg As New PrintPreviewDialog()
dlg.Document = gp.PrintDocument
dlg.ShowDialog()
•
C#
GridPrinter gp = _flex.PrintParameters;
gp.Footer = "Hello\tWorld\tFooter";
gp.PrintGridFlags =
C1.Win.C1FlexGrid.PrintGridFlags.FitToPageWidth;
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = gp.PrintDocument;
dlg.ShowDialog();
•
Delphi
var
dlg: PrintPreviewDialog;
gp: GridPrinter;
begin
gp := _flex.PrintParameters;
gp.Footer := 'Hello'#9'World'#9'Footer';
gp.PrintGridFlags := C1.Win.C1FlexGrid.PrintGridFlags.FitToPageWidth;
dlg := PrintPreviewDialog.Create;
dlg.Document := gp.PrintDocument;
dlg.ShowDialog;
end;
See Also
GridPrinter Class (page 391)
FooterFont Property
Specifies the font to use for footers when the grid is printed with the PrintGrid method.
Syntax
[VB]
Public FooterFont As Font
[C#]
public Font FooterFont {get; set;}
[Delphi]
property FooterFont: Font;
Example
The code below prints the grid with a large bold footer.
•
Visual Basic
Dim gp As GridPrinter = flex.PrinterSettings
gp.FooterFont = New Font("Arial", 16, FontStyle.Bold)
flex.PrintGrid("my grid", PrintGridFlags.ActualSize, _
Header Property · 393
"Header" + vbTab + vbTab + "{0}", "Footer")
•
C#
GridPrinter gp = flex.PrinterSettings;
gp.FooterFont = new Font("Arial", 16, FontStyle.Bold);
flex.PrintGrid("my grid",
PrintGridFlags.ActualSize, "Header\t\t{0}", "Footer");
•
Delphi
var
gp: GridPrinter;
begin
gp := flex.PrinterSettings;
gp.FooterFont := Font.Create('Arial', 16, FontStyle.Bold);
flex.PrintGrid('my grid', PrintGridFlags.ActualSize,
'Header'#9#9'{0}', 'Footer');
end;
See Also
GridPrinter Class (page 391)
Header Property
Allows you to customize the header of the grid's PrintDocument in case you want to display the grid
preview in your own dialog.
Syntax
[VB]
Public Property Header As String
[C#]
public string Header {get; set;}
[Delphi]
property Header: string;
Example
The code below customizes the header of the grid’s PrintDocument.
•
Visual Basic
Dim gp As GridPrinter = _flex.PrintParameters
gp.Header = "Hello" & vbTab & "World" &_
vbTab + "Header"
gp.PrintGridFlags = C1.Win.C1FlexGrid.PrintGridFlags.FitToPageWidth
Dim dlg As New PrintPreviewDialog()
dlg.Document = gp.PrintDocument
dlg.ShowDialog()
•
C#
GridPrinter gp = _flex.PrintParameters;
gp.Header = "Hello\tWorld\tHeader";
gp.PrintGridFlags =
C1.Win.C1FlexGrid.PrintGridFlags.FitToPageWidth;
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = gp.PrintDocument;
394 · C1FlexGrid Reference
dlg.ShowDialog();
•
Delphi
var
dlg: PrintPreviewDialog;
gp: GridPrinter;
begin
gp := _flex.PrintParameters;
gp.Header := 'Hello'#9'World'#9'Header';
gp.PrintGridFlags := C1.Win.C1FlexGrid.PrintGridFlags.FitToPageWidth;
dlg := PrintPreviewDialog.Create;
dlg.Document := gp.PrintDocument;
dlg.ShowDialog;
end;
See Also
GridPrinter Class (page 391)
HeaderFont Property
Specifies the font to use for headers when the grid is printed with the PrintGrid method.
Syntax
[VB]
Public HeaderFont As Font
[C#]
public Font HeaderFont {get; set;}
[Delphi]
property HeaderFont: Font;
Example
The code below prints the grid with a large bold header.
•
Visual Basic
Dim gp As GridPrinter = flex.PrinterSettings
gp.HeaderFont = New Font("Arial", 16, FontStyle.Bold)
flex.PrintGrid("my grid", PrintGridFlags.ActualSize, _
"Header" + vbTab + vbTab + "{0}", "Footer")
•
C#
GridPrinter gp = flex.PrinterSettings;
gp.HeaderFont = new Font("Arial", 16, FontStyle.Bold);
flex.PrintGrid("my grid", PrintGridFlags.ActualSize,
"Header\t\t{0}", "Footer");
•
Delphi
var
gp: GridPrinter;
begin
gp := flex.PrinterSettings;
gp.HeaderFont := Font.Create('Arial', 16, FontStyle.Bold);
flex.PrintGrid('my grid', PrintGridFlags.ActualSize,
'Header'#9#9'{0}', 'Footer');
end;
PageNumber Property · 395
See Also
GridPrinter Class (page 391)
PageNumber Property
Gets the number of the page being printed.
Syntax
[VB]
Public PageNumber As Integer
[C#]
public int PageNumber {get;}
[Delphi]
property PageNumber: Integer;
Remarks
This property can be used to provide user feedback while the grid is being printed.
See Also
GridPrinter Class (page 391)
PageCount Property
Gets the total number of the pages in a print document.
Syntax
[VB]
Public PageCount As Integer
[C#]
public int PageCount {get;}
[Delphi]
property PageCount: Integer;
Remarks
This property can be used to provide user feedback while the grid is being printed.
See Also
GridPrinter Class (page 391)
PrintDocument Property
Gets the PrintDocument object that specifies the page and printer settings.
396 · C1FlexGrid Reference
Syntax
[VB]
Public PrintDocument As PrintDocument
[C#]
public PrintDocument PrintDocument {get;}
[Delphi]
property PrintDocument: PrintDocument;
Remarks
The PrintDocument class is part of the .NET framework, defined in the System.Drawing.Printing
namespace. It contains properties that specify page and printer settings for the document.
Example
The code below prints a grid in landscape mode:
•
Visual Basic
Dim gp As GridPrinter = flex.PrinterSettings
gp.DefaultPageSettings.Landscape = True
flex.PrintGrid("my grid")
•
C#
GridPrinter gp = flex.PrinterSettings;
gp.DefaultPageSettings.Landscape = true;
flex.PrintGrid("my grid");
•
Delphi
var
gp: GridPrinter;
begin
gp := flex.PrinterSettings;
gp.DefaultPageSettings.Landscape := True;
flex.PrintGrid('my grid');
end;
See Also
GridPrinter Class (page 391)
PrintPreviewDialog Property
Allows you to specify properties for the built-in PrintPreview dialog.
Syntax
[VB]
Public PrintPreviewDialog As PrintDocument
[C#]
public PrintDocument PrintPreviewDialog {get;}
AggregateEnum Enumeration · 397
[Delphi]
property PrintPreviewDialog: PrintDocument;
Remarks
For example, the code below sets the caption and size of the built-in PrintPreview dialog:
•
Visual Basic
Dim dlg As PrintPreviewDialog =
_flex.PrintParameters.PrintPreviewDialog
dlg.Text = "Custom Caption in Preview Dialog"
dlg.ClientSize = New Size(500, 500)
•
C#
PrintPreviewDialog dlg = _flex.PrintParameters.PrintPreviewDialog;
dlg.Text = "Custom Caption in Preview Dialog";
dlg.ClientSize = new Size(500,500);
•
Delphi
var
dlg: PrintPreviewDialog;
begin
dlg := _flex.PrintParameters.PrintPreviewDialog;
dlg.Text := 'Custom Caption in Preview Dialog';
dlg.ClientSize := Size.Create(500, 500);
end;
See Also
GridPrinter Class (page 391)
C1FlexGrid Enumerations
AggregateEnum Enumeration
Specifies the type of aggregate function to calculate with the Aggregate and Subtotal methods.
Syntax
[VB]
Public Enum AggregateEnum
[C#]
public sealed enum AggregateEnum : System.Enum
[Delphi]
type AggregateEnum = (Average, Clear, Count, Max, Min, None, Percent, Std, StdPop, Sum, Var,
VarPop);
Members
Member Name
Description
None
No aggregate. This setting is used with the Subtotal method to create an outline
tree without any numerical aggregates.
398 · C1FlexGrid Reference
Member Name
Description
Clear
Clear existing aggregates. This setting is used with the Subtotal method to clear
any existing subtotals, usually before calculating new subtotals.
Sum
Returns the sum of all values in the range.
Percent
Percent of grand total. This setting is used with the Subtotal method to calculate
the percentage of the grand total represented by each sub group. (This setting
cannot be used with the Aggregate method).
Count
Returns the count of non-null cells in a range.
Average
Returns the average of non-null cells in a range.
Max
Returns the maximum value in a range.
Min
Returns the minimum value in a range.
Std
Returns the sample standard deviation of the values in a range (uses the formula
based on n-1).
Var
Returns the sample variance of the values in a range (uses the formula based on n1).
StdPop
Returns the population standard deviation of the values in a range (uses the formula
based on n).
VarPop
Returns the population variance of the values in a range (uses the formula based on
n).
AggregateFlags Enumeration
Specifies options to use when calculating aggregates with the Aggregate method.
Syntax
[VB]
Public Enum AggregateFlags
[C# ]
public sealed enum AggregateFlags : System.Enum
[Delphi]
type AggregateFlags = (AggregateDates, ExcludeNodes, None);
Members
Member Name
Description
None
Include all rows and use numerical values only.
ExcludeNodes
Exclude node rows from aggregate. This option is useful when the grid contains
subtotal rows, which are marked as nodes and contain values that are subtotals
and should thus be excluded from aggregates.
AggregateDates
Calculate aggregates for dates instead of numerical values. Only a few
aggregate functions are meaningful for dates: count, maximum, and minimum.
AllowFreezingEnum Enumeration · 399
Member Name
Description
Causes the control to include boolean cells in aggregates:
AggregateBooleans
True values count as 1, False as 0. For example, you can get the number of
checked cells in a range using:
// sum values in the range, count true values as 1
double sum = _flex.Aggregate(AggregateEnum.Sum, 1, 1, 49, 1,
AggregateFlags.AggregateBooleans);
AllowFreezingEnum Enumeration
Specifies whether cells of the grid can be frozen or not.
Syntax
[VB]
Public Enum AllowFreezingEnum
[C# ]
public sealed enum AllowFreezingEnum : System.Enum
[Delphi]
type AllowFreezingEnum = (Both, Columns, None, Rows);
Members
Member Name
Description
None
The user cannot freeze rows and columns with the mouse (default).
Columns
The user can freeze columns with the mouse.
Rows
The user can freeze rows with the mouse.
Both
The user can freeze rows and columns with the mouse.
AllowMergingEnum Enumeration
Specifies which cells are allowed to merge.
Syntax
[VB]
Public Enum AllowMergingEnum
[C# ]
public sealed enum AllowMergingEnum : System.Enum
[Delphi]
type AllowMergingEnum = (FixedOnly, Free, Nodes, None, RestrictAll, RestrictCols, RestrictRows,
Spill);
400 · C1FlexGrid Reference
Members
Member Name
Description
None
Do not merge cells.
Free
Merge any adjacent cells with same contents.
RestrictRows
Merge rows only if cells above are also merged.
RestrictCols
Merge columns only if cells to the left are also merged.
RestrictAll
Merge cells only if cells above or to the left are also merged.
FixedOnly
Merge only fixed cells. This setting is useful for setting up complex headers for
the data and preventing the data itself from being merged.
Spill
Allow long entries to spill into empty adjacent cells.
Nodes
Allow entries in Node rows to spill into empty adjacent cells.
AllowResizingEnum Enumeration
Specifies which grid elements (rows and/or columns) can be resized using the mouse.
Syntax
[VB]
Public Enum AllowResizingEnum
[C#]
public sealed enum AllowResizingEnum : System.Enum
[Delphi]
type AllowResizingEnum = (Both, BothUniform, Columns, ColumnsUniform, None, Rows,
RowsUniform);
Members
Member Name
Description
None
The user may not resize rows or columns.
Columns
The user may resize columns by dragging the edges of the fixed cells along the
top of the grid. Double clicking the edge of the fixed cells adjusts the column to fit
the widest entry in the column.
ColumnsUniform
The user may resize columns with the mouse. When a column is resized, the
new column height is applied to all columns.
Rows
The user may resize rows by dragging the edges of the fixed cells along the left
of the grid. Double clicking the edge of the fixed cells adjusts the row to fit the
tallest entry in the row.
Both
The user may resize rows and columns with the mouse.
RowsUniform
The user may resize rows with the mouse. When a row is resized, the new row
height is applied to all rows.
AllowDraggingEnum Enumeration · 401
Member Name
Description
BothUniform
The user may resize rows and columns with the mouse. When a row or column is
resized, the new size is applied to all rows or columns.
AllowDraggingEnum Enumeration
Specifies which grid elements (rows and/or columns) can be dragged using the mouse.
Syntax
[VB]
Public Enum AllowDraggingEnum
[C#]
public sealed enum AllowDraggingEnum : System.Enum
[Delphi]
type AllowDraggingEnum = (Both, Columns, None, Rows);
Members
Member Name
Description
None
The user cannot drag rows and columns with the mouse.
Columns
The user can drag columns to new positions with the mouse.
Rows
The user can drag rows to new positions with the mouse.
Both
The user can drag rows and columns to new positions with the mouse.
AllowSortingEnum Enumeration
Specifies whether columns can be sorted with the mouse.
Syntax
[VB]
Public Enum AllowSortingEnum
[C#]
public sealed enum AllowSortingEnum : System.Enum
[Delphi]
type AllowSortingEnum = (MultiColumn, SingleColumn, None);
402 · C1FlexGrid Reference
Members
Member Name
Description
None
The user cannot sort columns with the mouse.
SingleColumn
The user can sort columns with the mouse. Clicking on a column header sorts
that column in ascending or descending order.
This setting provides the behavior seen in most standard applications such as
the Windows Explorer.
MultiColumn
The user can sort columns with the mouse. Clicking on a column header sorts all
columns form the first to the one that was clicked in ascending or descending
order.
This setting is useful when data is grouped by categories, from left to right, and
you want to preserve the grouping when the data is sorted.
AutoSearchEnum Enumeration
Specifies where the grid should start searching for cells when using the AutoSearch property.
Syntax
[VB]
Public Enum AutoSearchEnum
[C#]
public sealed enum AutoSearchEnum : System.Enum
[Delphi]
type AutoSearchEnum = (FromCursor, FromTop, None);
Members
Member Name
Description
None
Disable auto searching.
FromTop
When the user starts typing, look for matches starting from the top of the grid.
FromCursor
When the user starts typing, look for matches starting from the current row.
AutoSizeFlags Enumeration
Specifies options to use when automatically sizing grid rows and/or columns.
Syntax
[VB]
Public Enum AutoSizeFlags
[C#]
public sealed enum AutoSizeFlags : System.Enum
BorderDirEnum Enumeration · 403
[Delphi]
type AutoSizeFlags = (IgnoreHidden, IgnoreMerged, None, SameSize);
Members
Member Name
Description
None
Standard auto sizing behavior.
SameSize
Apply the same size to all rows (or columns) being resized.
IgnoreHidden
Ignore hidden rows and columns when calculating cell sizes.
IgnoreMerged
Ignore merged rows and columns when calculating cell sizes.
BorderDirEnum Enumeration
Specifies the direction of cell borders.
Syntax
[VB]
Public Enum BorderDirEnum
[C#]
public sealed enum BorderDirEnum : System.Enum
[Delphi]
type BorderDirEnum = (Both, Horizontal, Vertical);
Members
Member Name
Description
Both
Draw cell borders in both directions.
Horizontal
Draw cell borders only in the horizontal direction.
Vertical
Draw cell borders only in the vertical direction.
BorderStyleEnum Enumeration
Specifies the type of cell border.
Syntax
[VB]
Public Enum BorderStyleEnum
[C#]
public sealed enum BorderStyleEnum : System.Enum
[Delphi]
type BorderStyleEnum = (Dotted, Double, Fillet, Flat, Groove, Inset, None, Raised);
404 · C1FlexGrid Reference
Members
Member Name
Description
None
No border.
Flat
Solid flat border, drawn using specified width and color.
Double
Double border, drawn with a given width and color.
Raised
Raised 1-pixel border, drawn using system colors.
Inset
Inset 1-pixel border, drawn using system colors.
Groove
Compound border (inset+raised).
Fillet
Compound border (raised+inset).
Dotted
Dotted 1-pixel border drawn using a specified color.
CellStyleEnum Enumeration
Specifies built-in styles (can be used as an index into the Styles property).
Syntax
[VB]
Public Enum CellStyleEnum
[C#]
public sealed enum CellStyleEnum : System.Enum
[Delphi]
type CellStyleEnum = (Alternate, EmptyArea, FirstCustomStyle, Fixed, Focus, Frozen, GrandTotal,
Highlight, NewRow, Normal, Search, Subtotal0,, Subtotal1, Subtotal2, Subtotal3, Subtotal4, Subtotal5);
Members
Member Name
Description
Normal
Style used to render scrollable normal cells.
Alternate
Style used to render scrollable cells in even-numbered rows. By default, this style is
empty, so all scrollable cells are rendered using the Normal style.
Fixed
Style used to render fixed cells. By default, this style has a custom background
color.
Highlight
Style used to render cells that are selected and highlighted. By default, this style
has custom background and foreground colors.
Focus
Style used to render the cell that has the focus. By default, this style is empty, so
focused cells are rendered using the normal style.
Editor
Style used to render cells being edited. By default, this style is empty, so cells being
edited are rendered using the focus style.
Search
Style used to render cells that are being selected as the user types (in AutoSerach
mode). By default, this style has a custom background color.
CheckEnum Enumeration · 405
Member Name
Description
Frozen
Style used to render cells that are frozen (editable and selectable, but not
scrollable). By default, this style has a custom background color.
NewRow
Style used to render the last row on the grid when the AllowAddNew property is set
to true. This is the row used to add new elements to the grid.
EmptyArea
Style used to render the are of the grid where there are no cells. The border used
for this style determines the type of border to be drawn around the entire group of
cells that the grid contains.
GrandTotal
Style automatically assigned to grand total rows created with the Subtotal method.
By default, this style has custom background and foreground colors.
Subtotal(0-5)
Styles automatically assigned to subtotal rows created with the Subtotal method.
By default, these styles have custom background and foreground colors.
CheckEnum Enumeration
Specifies the type of checkbox to draw in a cell.
Syntax
[VB]
Public Enum CheckEnum
[C#]
public sealed enum CheckEnum : System.Enum
[Delphi]
type CheckEnum = (Checked, None, TSChecked, TSGrayed, TSUnchecked, Unchecked);
Remarks
There are two types of check boxes: regular and tri-state.
Regular check boxes are used to display simple boolean values. They cycle through settings Checked and
Unchecked when clicked with the mouse.
Tri-state check boxes are used to display values that may be true, false, or indeterminate (grayed). They
cycle through settings TSChecked, TSGrayed, and TSUnchecked when clicked with the mouse.
Visually, Checked and Unchecked look the same as TSChecked and TSUnchecked.
Members
Member Name
Description
None
No check box.
Checked
Check box with a check mark in it.
Unchecked
Empty check box.
TSChecked
Tri-state check box with a check mark in it.
TSUnchecked
Tri-state empty check box.
TSGrayed
Tri-state check box in grayed state.
406 · C1FlexGrid Reference
ClearFlags Enumeration
Specifies which grid elements to clear when using the Clear method.
Syntax
[VB]
Public Enum ClearFlags
[C#]
public sealed enum ClearFlags : System.Enum
[Delphi]
type ClearFlags = (All, Content, Style, UserData);
Members
Member Name
Description
Content
Clear cell data, including image and checkboxes if any.
Style
Clear custom styles assigned to cells.
UserData
Clear user data associated with cells.
All
All of the above.
DisplayEnum Enumeration
A type of the CellStyle.Display property. Each grid cell may contain a value (displayed as text) and an
image. The Display property determines which of these are displayed and how they are arranged in the
cell.
Syntax
[VB]
Public enum DisplayEnum
[C#]
public sealed enum DisplayEnum : System.Enum
[Delphi]
type DisplayEnum = (ImageOnly, None, OverLay, Stack, TextOnly);
Remarks
Use the members of this enumeration to set the value of an argument of the Display Property in the
C1FlexGrid control.
Member Name
Description
ImageOnly
Display image only (no value).
None
Nothing (cell stays blank).
DragModeEnum Enumeration · 407
Member Name
Description
OverLay
Image and value (overlaid).
Stack
Image and value (side by side).
TextOnly
Display value only (no image).
DragModeEnum Enumeration
Specifies how OLE drag-drop operations are handled.
Syntax
[VB]
Public Enum DragModeEnum
[C#]
public sealed enum DragModeEnum : System.Enum
[Delphi]
type DragModeEnum = (Automatic, AutomaticCopy, AutomaticMove, Manual);
Members
Member Name
Description
Manual
The control does not provide any drag support.
Automatic
The control provides automatic move and copy dragging.
AutomaticCopy
The control provides automatic copy dragging.
AutomaticMove
The control provides automatic move dragging.
DrawCellFlags Enumeration
Specifies which grid elements to draw.
Syntax
[VB]
Public Enum DrawCellFlags
[C#]
public sealed enum DrawCellFlags : System.Enum
[Delphi]
type DrawCellFlags = (All, Background, Border, Content);
Remarks
This enumeration is used when rendering owner-drawn cells.
If you set the DrawMode property to DrawModeEnum.OwnerDraw, the grid will fire the
OwnerDrawCell event to allow custom cell drawing. The OwnerDrawCellEventArgs parameter has a
408 · C1FlexGrid Reference
DrawCell method that allows you to use the standard drawing routines for rendering the cell's
background, border, and/or cell content. For example, you can paint a custom background and use the
standard drawing routines for the cell borders and content.
See the OwnerDrawCell event for an example.
Members
Member Name
Description
Background
Paint the cell background.
Border
Paint the cell border.
Content
Paint the cell content (text, image, and checkboxes).
All
All of the above.
DrawModeEnum Enumeration
Specifies how grid cells are drawn.
Syntax
[VB]
Public Enum DrawModeEnum
[C#]
public sealed enum DrawModeEnum : System.Enum
[Delphi]
type DrawModeEnum = (Normal, OwnerDraw);
Members
Member Name
Description
Normal
Grid cells are drawn by the control.
OwnerDraw
The grid fires the OwnerDrawCell event to allow custom cell drawing.
DropModeEnum Enumeration
Specifies how the control handles OLE drag-drop operations.
Syntax
[VB]
Public Enum DropModeEnum
[C#]
public sealed enum DropModeEnum : System.Enum
EditFlags Enumeration · 409
[Delphi]
type DropModeEnum = (Automatic, Manual, None);
Members
Member Name
Description
None
The control is not a drop target.
Manual
The control fires events.
Automatic
The control automatically handles dropping of text or filename data.
EditFlags Enumeration
Specifies editing options for use with the EditOptions property.
Syntax
[VB]
Public Enum EditFlags
[C#]
public sealed enum EditFlags : System.Enum
[Delphi]
type EditFlags = (Automatic, Manual, None);
Members
Member Name
Description
None
No flags, disable all options.
AutoSearch
Provide auto search capabilities when editing with the built-in ComboBoxes.
This option causes the grid to search and select entries in the editor as you
type. The interval before the search buffer is cleared is determined by the
AutoSearchDelay property.
CycleOnDoubleClick
Automatically select the next value when the user double-clicks a cell that has
an associated ComboList or DataMap.
MultiCheck
Toggle all selected check boxes when any check box is toggled.
All
Enable all options. This is the default setting for the EditOptions property.
FileFlags Enumeration
Specifies options for use with the SaveGrid and LoadGrid methods.
Syntax
[VB]
Public Enum FileFlags
410 · C1FlexGrid Reference
[C#]
public sealed enum FileFlags : System.Enum
[Delphi]
type FileFlags = (None, IncludeFixedCells, VisibleOnly, SelectedRowsOnly);
Members
Member Name
Description
None
No flags, use default settings.
IncludeFixedCells
Include fixed cells when loading or saving the grid.
VisibleOnly
Save only visible rows and columns. (Does not apply to Excel files).
SelectedRowsOnly
Save only selected columns. (Does not apply to Excel files).
FileFormatEnum Enumeration
Specifies the type of file to save or load with the SaveGrid and LoadGrid methods.
Syntax
[VB]
Public Enum FileFormatEnum
[C#]
public sealed enum FileFormatEnum : System.Enum
[Delphi]
type FileFormatEnum = (TextComma, TextCustom, TextTab);
Members
Member Name
Description
TextComma
Cells are separated with commas.
TextTab
Cells are separated with tabs.
TextCustom
Cells are separated with the character specified in the ClipSeparators property.
Excel
Save and load Microsoft Excel files (xls).
FocusRectEnum Enumeration
Specifies the appearance of the focus rectangle on the grid.
Syntax
[VB]
Public Enum FocusRectEnum
GlyphEnum Enumeration · 411
[C#]
public sealed enum FocusRectEnum : System.Enum
[Delphi]
type FocusRectEnum = (Heavy, Inset, Light, None, Raised, Solid);
Members
Member Name
Description
None
No focus rectangle.
Light
One-pixel wide dotted rectangle.
Heavy
Two-pixel wide dotted rectangle.
Solid
One-pixel wide solid rectangle. The color is the same as the one used to draw the
selection background (Styles.Highlight.BackColor).
Raised
One-pixel wide raised rectangle draw using system colors.
Inset
One-pixel wide inset rectangle draw using system colors.
GlyphEnum Enumeration
Specifies a type of glyph (image) used by the grid to convey information about a row, column, or cell.
Syntax
[VB]
Public Enum GlyphEnum
[C#]
public sealed enum GlyphEnum : System.Enum
[Delphi]
type GlyphEnum = (Ascending, Checked, Collapsed, DBAdd, DBCursor, Descending, ErrorInfo,
Expanded, Grayed, Unchecked);
Members
Member Name
Description
Ascending
Indicates column sorted in ascending order (default is hollow triangle pointing up).
Descending
Indicates column sorted in descending order (default is hollow triangle pointing
down).
Checked
Checkbox in checked state.
Unchecked
Checkbox in unchecked state.
Grayed
Checkbox in gray (undefined) state.
Collapsed
Collapsed tree node (default is plus sign).
Expanded
Expanded tree node (default is minus sign).
412 · C1FlexGrid Reference
Member Name
Description
DBCursor
Indicates current record (default is black triangle pointing right).
DBAdd
Indicates row being added to data source (default is asterisk).
ErrorInfo
Indicates row or cell error (default is red exclamation sign).
GridChangedTypeEnum Enumeration
Specifies the type of change that fired a GridChanged event.
Syntax
[VB]
Public Enum GridChangedTypeEnum
[C#]
public sealed enum GridChangedTypeEnum : System.Enum
[Delphi]
type GridChangedTypeEnum = (AfterCollapse, AfterSelChange, BeforeCollapse, BeforeSetChange,
ColAdded, ColMoved, ColRemoved, ColSelected, EnsureVisible, GridChanged, LayoutChanged, None,
RepaintCell, RepaintGrid, RepaintRange, RowAdded, RowMoved, RowRemoved, RowSelected, Select,
StyleChanged, update);
Members
Member Name
Description
None
No action.
GridChanged
The number of rows or columns changed.
LayoutChanged
The number of fixed rows or columns changed.
StyleChanged
One or more styles have changed.
StyleApplied
A new style has been applied to a range.
RepaintGrid
The grid is about to be repainted.
RepaintCell
A cell is about to be repainted.
RepaintRange
A range of cells is about to be repainted.
Update
The grid window will be updated.
BeforeCollapse
A node row is about to be collapsed or expanded.
AfterCollapse
A node row was collapsed or expanded.
EnsureVisible
A node row is being brought into view.
Select
A node row is about to be selected.
RowMoved
A row was moved.
RowAdded
A row was added.
RowRemoved
A row was deleted.
HighLightEnum Enumeration · 413
Member Name
Description
RowSelected
A row was selected.
ColMoved
A column was moved.
ColAdded
A column was added.
ColRemoved
A column was deleted.
ColSelected
A column was selected.
BeforeSelChange
The selection is about to change.
AfterSelChange
The selection has changed.
HighLightEnum Enumeration
Specifies when the current selection is highlighted.
Syntax
[VB]
Public Enum HighLightEnum
[C#]
public sealed enum HighLightEnum : System.Enum
[Delphi]
type HighLightEnum = (Always, Never, WithFocus);
Members
Member Name
Description
Never
Never highlight the selection.
Always
Always highlight the selection.
WithFocus
Highlight the selection when the control has the focus.
HitTestTypeEnum Enumeration
Type of grid element at a specific point on the control.
Syntax
[VB]
Public Enum HitTestTypeEnum
[C#]
public sealed enum HitTestTypeEnum : System.Enum
[Delphi]
type HitTestTypeEnum = (Cell, Checkbox, ColumnFreeze, ColumnHeader, ColumnResize, EditButton,
None, OutlineBar, OutlineTree, RowFreeze, RowHeader, RowResize);
414 · C1FlexGrid Reference
Members
Member Name
Description
None
The point is in the grid's empty area.
Cell
The point is on a grid cell. (The cell coordinates are stored in the HitTestInfo object's
Row Column properties).
ColumnHeader
The point is on a fixed row, over a column.
ColumnResize
The point is near the right edge of a fixed cell, in the column resizing area.
ColumnFreeze
The point is near the right edge of the last frozen column, in the column freezing
area.
RowHeader
The point is on a fixed column, next to a row.
RowResize
The point is near the bottom edge of a fixed cell, in the row resizing area.
RowFreeze
The point is near the bottom edge of the last frozen row, in the row freezing area.
CheckBox
The point is on a check box.
EditButton
The point is on an edit button (drop down, popup editors).
OutlineBar
The point is on the outline bar (visible when the grid's Tree.Style property contains
the ButtonBar flag).
OutlineTree
The point is on the collapse/expand button on an outline tree (visible when the grid's
Tree.Style property contains the Symbols flag).
ImageAlignEnum Enumeration
Specifies how images are aligns in grid cells.
Syntax
[VB]
Public Enum ImageAlignEnum
[C#]
public sealed enum ImageAlignEnum : System.Enum
[Delphi]
type ImageAlignEnum = (CenterBottom, CenterCenter, CenterTop, Hide, LeftBottom, LeftCenter,
LeftTop, RightBottom, RightCenter, RightTop, Scale, Stretch, Tile);
Members
Member Name
Description
LeftTop
Image is horizontally aligned to the left and vertically aligned to the top of the cell.
LeftCenter
Image is horizontally aligned to the left and vertically aligned to the center of the cell.
LeftBottom
Image is horizontally aligned to the left and vertically aligned to the bottom of the cell.
CenterTop
Image is horizontally aligned to the center and vertically aligned to the top of the cell.
KeyActionEnum Enumeration · 415
Member Name
Description
CenterCenter
Image is horizontally aligned to the center and vertically aligned to the center of the cell.
CenterBottom
Image is horizontally aligned to the center and vertically aligned to the bottom of the
cell.
RightTop
Image is horizontally aligned to the right and vertically aligned to the top of the cell.
RightCenter
Image is horizontally aligned to the right and vertically aligned to the center of the cell.
RightBottom
Image is horizontally aligned to the right and vertically aligned to the bottom of the cell.
Scale
Image is scaled to fit the maximum area within the cell while preserving the picture's
original aspect ratio.
Stretch
Image is stretched to cover the whole cell.
Tile
Image is tiled to cover the whole cell.
Hide
Image is not displayed.
KeyActionEnum Enumeration
Specifies the action to perform when certain keys are pressed.
Syntax
[VB]
Public Enum KeyActionEnum
[C#]
public sealed enum KeyActionEnum : System.Enum
[Delphi]
type KeyActionEnum = (None, MoveAcross, MoveDown);
Members
Member Name
Description
None
No special action (allow system to handle the cell). For example, the Tab key is
normally used to cycle through the controls on a form.
MoveDown
Move to the next row when the key is pressed.
MoveAcross
Move to the next column when the key is pressed. At the end of the column, move to
the next row and back to the first column.
MoveAcrossOut
Move to the next column when the key is pressed. At the end of the column, move to
the next row and back to the first column. At the end of the last column, move the
focus to the next control on the form.
NodeMoveEnum Enumeration
Specifies the destination of nodes when they are moved with the Node.Move method.
416 · C1FlexGrid Reference
Syntax
[VB]
Public Enum NodeMoveEnum
[C#]
public sealed enum NodeMoveEnum : System.Enum
[Delphi]
type NodeMoveEnum = (ChildOf, Down, First, In, Last, Out, up);
Members
Member Name
Description
In
Move the node one level deeper into the outline.
Out
Move the node one level out, towards the root.
Up
Move the node to a position before its previous sibling.
Down
Move the node to a position after its next sibling.
First
Move the node to a position before its first sibling.
Last
Move the node to a position after its last sibling.
ChildOf
Make the node a child of the specified node.
NodeTypeEnum Enumeration
Specifies the node to retrieve with the Node.GetNode method.
Syntax
[VB]
Public Enum NodeTypeEnum
[C#]
public sealed enum NodeTypeEnum : System.Enum
[Delphi]
type NodeTypeEnum = (FirstChild, FirstSibling, LastChild, LastSibling, NextSibling, Parent,
PreviousSibling, Root);
Members
Member Name
Description
Root
The node's top-level parent.
Parent
The node's immediate parent.
FirstChild
The node's first child.
LastChild
The node's last child.
PrintGridFlags Enumeration · 417
Member Name
Description
FirstSibling
The node's first sibling (node with same level and same parent).
LastSibling
The node's last sibling.
NextSibling
The node's next sibling.
PreviousSibling
The node's previous sibling.
PrintGridFlags Enumeration
Contains flags that specify printing options to use with the PrintGrid method.
Syntax
[VB]
Public Enum PrintGridFlags
[C#]
public sealed enum PrintGridFlags : System.Enum
[Delphi]
type PrintGridFlags = (ActualSize, FitToPage, FitToPageWidth, ShowPageSetupDialog,
ShowPrintDialog, ShowPreviewDialog);
Members
Member Name
Description
ActualSize
Print the grid in actual (screen size). If the grid is too wide to fit on a page,
columns spill onto separate pages. If the grid is too tall to fit on a page, rows
spill onto additional pages.
FitToPageWidth
Scale the grid so its width will fit on a single page. If the grid is too tall to fit on a
page, rows spill onto additional pages.
FitToPage
Scale the grid so it will fit on a single page (rows and columns).
ShowPageSetupDialog
Show a page setup dialog before printing so the user can select paper size,
orientation, and margins.
ShowPrintDialog
Show a print setup dialog before printing so the user can select the printer to
use.
ShowPreviewDialog
Show a print preview dialog before printing so the user can inspect the
document before printing it.
SelectionModeEnum Enumeration
Specifies the type of grid selection to use.
Syntax
[VB]
Public Enum SelectionModeEnum
418 · C1FlexGrid Reference
[C#]
public sealed enum SelectionModeEnum : System.Enum
[Delphi]
type SelectionModeEnum = (Cell, CellRange, Column, ColumnRange, Default, ListBox, Row,
RowRange);
Members
Member Name
Description
Default
The user can select continuous blocks of cells using the keyboard and the mouse.
Clicking on header cells selects entire rows and columns.
Cell
The user can select only a single cell at a time.
CellRange
The user can select continuous blocks of cells using the keyboard and the mouse.
Clicking on header cells does not affect the selection.
Row
The user can select a single row at a time.
RowRange
The user can select a range of contiguous rows at a time.
Column
The user can select a single column at a time.
ColumnRange
The user can select a range of contiguous columns at a time.
ListBox
The user can select non-contiguous rows (by control-clicking on them).
ShowButtonsEnum Enumeration
Specifies when the grid should display drop down and popup buttons in editable cells.
Syntax
[VB]
Public Enum ShowButtonsEnum
[C#]
public sealed enum ShowButtonsEnum : System.Enum
[Delphi]
type ShowButtonsEnum = (Always, WhenEditing, WithFocus);
Members
Member Name
Description
WhenEditing
Buttons are drawn only while the user is editing the cell.
WithFocus
Buttons are drawn when the cell has the focus (default).
Always
Buttons are drawn whenever the cell is visible.
SortFlags Enumeration · 419
SortFlags Enumeration
Contains flags that specify sorting options to use with the Sort method.
Syntax
[VB]
Public Enum SortFlags
[C#]
public sealed enum SortFlags : System.Enum
[Delphi]
type SortFlags = (Ascending, AsDisplayed, Descending, IgnoreCase, None, UseColSort);
Members
Member Name
Description
None
Do not sort. This setting is useful for skipping certain columns when sorting column
ranges.
Ascending
Sort in ascending order.
Descending
Sort in descending order.
AsDisplayed
Sort using the string representation of the data. In this mode, "100" appears before
"2".
IgnoreCase
Ignore case when sorting strings.
UseColSort
Use the sort flags specified by the Sort property of individual Column objects.
StyleElementFlags Enumeration
Contains flags that specify which style elements are defined in a CellStyle object.
Syntax
[VB]
Public Enum StyleElementFlags
[C#]
public sealed enum StyleElementFlags : System.Enum
[Delphi]
type StyleElementFlags = (All, BackColor, Border, ComboList, DataMap, DataType, Display, EditMask,
Font, ForeColor, Format, ImageAlign, ImageMap, ImageSpacing, Margins, None, TextAlign,
TextEffect,Trimming, WordWrap);
Remarks
CellStyle objects define elements used to render grid cells. Elements that are not defined in a particular
style are inherited from the parent.
Use the DefinedElements property to determine which elements are present in a given CellStyle object.
420 · C1FlexGrid Reference
Members
Member Name
Description
None
No elements are defined.
Font
The style defines a font.
BackColor
The style defines a background color.
ForeColor
The style defines a foreground color.
Margins
The style defines margins.
Border
The style defines borders.
TextAlign
The style defines the text alignment.
TextEffect
The style defines a 3D effect for the text.
ImageAlign
The style defines the image alignment.
ImageSpacing
The style defines the spacing between images and text.
Trimming
The style defines how long strings are trimmed to fit within cells.
WordWrap
The style defines whether long strings are allowed to wrap within cells.
Display
The style defines whether to display text and/or images, in the cells.
Format
The style defines a format string used to convert data into strings.
EditMask
The style defines an edit mask used to constrain values entered in the cells.
ComboList
The style defines a list of choices used to populate drop down editors.
ImageMap
The style defines an IDictionary used to associate cell data with images.
DataMap
The style defines an IDictionary used to associate cell data with display values.
DataType
The style defines the Type of values contained in the cells.
TextDirection
The style defines whether text should be rendered horizontally or vertically.
Editor
The style defines an external control to be used as an editor for the cells.
UserData
The style contains arbitrary user data (not used by the control).
All
The style defines all elements.
SubTotalPositionEnum Enumeration
Specifies whether the Subtotal method should add node rows above or below the data being
summarized.
Syntax
[VB]
Public Enum SubTotalPositionEnum
[C#]
public sealed enum SubtotalPositionEnum : System.Enum
TextAlignEnum Enumeration · 421
[Delphi]
type SubtotalPositionEnum = (AboveData, BelowData);
Members
Member Name
Description
AboveData
Node rows appear above data rows (default).
BelowData
Node rows appear below data rows.
TextAlignEnum Enumeration
Specifies how text is aligned in a grid cell.
Syntax
[VB]
Public Enum TextAlignEnum
[C#]
public sealed enum TextAlignEnum : System.Enum
[Delphi]
type TextAlignEnum = (CenterBottom, CenterCenter, CenterTop, GeneralBottom, GeneralCenter,
GeneralTop, LeftBottom, LeftCenter, LeftTop, RightBottom, Rightcenter, RightTop);
Members
Member Name
Description
LeftTop
Text is horizontally aligned to the left and vertically aligned to the top of the cell.
LeftCenter
Text is horizontally aligned to the left and vertically aligned to the center of the cell.
LeftBottom
Text is horizontally aligned to the left and vertically aligned to the bottom of the cell.
CenterTop
Text is horizontally aligned to the center and vertically aligned to the top of the cell.
CenterCenter
Text is horizontally aligned to the center and vertically aligned to the center of the
cell.
CenterBottom
Text is horizontally aligned to the center and vertically aligned to the bottom of the
cell.
RightTop
Text is horizontally aligned to the right and vertically aligned to the top of the cell.
RightCenter
Text is horizontally aligned to the right and vertically aligned to the center of the cell.
RightBottom
Text is horizontally aligned to the right and vertically aligned to the bottom of the
cell.
GeneralTop
Numbers are aligned to the right, other values to the left, and vertically aligned to
the top.
GeneralCenter
Numbers are aligned to the right, other values to the left, and vertically aligned to
the center.
422 · C1FlexGrid Reference
Member Name
Description
GeneralBottom
Numbers are aligned to the right, other values to the left, and vertically aligned to
the bottom.
TextDirectionEnum Enumeration
Specifies the direction to use when rendering text in a grid cell.
Syntax
[VB]
Public Enum TextDirectionEnum
[C#]
public sealed enum TextDirectionEnum : System.Enum
[Delphi]
type TextDirectionEnum = (Normal, Up, Down);
Remarks
The text direction also affects row and column auto sizing.
Members
Member Name
Description
Normal
Text is rendered in the horizontal direction.
Up
Text is rendered from the bottom of the cell to the top.
Down
Text is rendered from the top of the cell to the bottom.
TextEffectEnum Enumeration
Specifies a 3D effect to use when rendering cell text.
Syntax
[VB]
Public Enum TextEffectEnum
[C#]
public sealed enum TextEffectEnum : System.Enum
[Delphi]
type TextEffectEnum = (Flag, Inset, Raised);
Remarks
To create a 3D effect for the text, the grid creates a brush that is a blend between the foreground and
background colors, and uses that brush to create a shadow. The quality of the effect depends on the
colors and font used.
TreeStyleFlags Enumeration · 423
Members
Member Name
Description
Flat
No 3D effect.
Raised
Text is drawn with a shadow offset by one pixel to the right and below the text.
Inset
Text is drawn with a shadow offset by one pixel to the left and above the text.
TreeStyleFlags Enumeration
Specifies the appearance of the outline tree defined with the Tree property.
Syntax
[VB]
Public Enum TreeStyleFlags
[C#]
public sealed enum TreeStyleFlags : System.Enum
[Delphi]
type TreeStyleFlags = (ButtonBar, Complete, CompleteLeaf, Leaf, Lines, None, Simple, SimpleLeaf,
Symbols);
Members
Member Name
Description
None
Do not show the outline tree.
Lines
Show tree lines next to node rows.
Symbols
Show expand/collapse symbols.
ButtonBar
Show outline buttons across the top fixed row.
Leaf
Show tree lines next to all rows (nodes and data).
Complete
Combination of Lines, Symbols, and ButtonBar.
Simple
Combination of Lines and Symbols
CompleteLeaf
Combination of Lines, Symbols, ButtonBar, and Leaf.
SimpleLeaf
Combination of Lines, Symbols, and Leaf
C1FlexGrid Interfaces
IC1EmbeddedEditor Interface
IC1EmbeddedEditor is a public interface declared in C1Common.dll. Controls that implement this
interface have better integration with the grid than plain controls. For example, they can adopt the visual
style of the host control and provide custom behavior for keyboard interaction, validation, and
positioning.
424 · C1FlexGrid Reference
The IC1EmbeddedEditor interface contains the following members:
•
void C1EditorInitialize(object value, IDictionary editorAttributes)
This method is called to initialize the editor content and styles.
The parameter 'value' contains the grid data that should be displayed in the editor.
The parameter 'editorAttributes' contains an IDictionary object with keys that correspond to style
element names and the values for the cell being edited (e.g., Font, BackColor). The editor can use
these styles to emulate the look and feel provided by the host control (the grid). The editor is free
to use whatever attributes make sense to it and ignore the others.
The 'editorAttributes' dictionary contains the following elements:
Key
Type
Description
BackColor
Color
Cell background color
ContentAlignment
ContentAlignment
Cell text alignment
DataType
Type
Type of value being edited
EditMask
String
Cell editing mask (e.g., "(999) 999-9999")
Font
Font
Cell font
ForeColor
Color
Cell foreground color
Format
String
Cell format string (e.g., "#,##0.##")
Margins
Margins
Extra margins around the cell content (in
pixels)
WordWrap
Boolean
The editor should perform word wrapping
The default handler sets the editor's Text property and ignores all styles.
•
object C1EditorGetValue()
Returns the current value of the editor. This can be of any data type.
The default handler returns the editor's Text property.
•
object C1EditorSetValue()
Sets the current value of the editor. This can be of any data type.
The default handler sets the editor's Text property.
•
bool C1EditorValueIsValid()
Returns true if the editor currently has valid content (e.g., it contains an EditMask and all
required positions have been filled).
The default handler always returns true.
IC1EmbeddedEditor Interface · 425
•
UITypeEditorEditStyle C1EditorGetStyle()
Returns the editor style, which determines the type of button that is displayed in the cell before
and during editing (DropDown, Modal, None).
The default handler returns DropDown for ComboBoxes, DateTimePickers, and UpDown
controls. It returns None for other control types.
NOTE: The UITypeEditorEditStyle enumeration is defined in the System.Drawing.Design
namespace. The available settings are DropDown, Modal, and None.
•
void C1EditorUpdateBounds(Rectangle rc)
Moves the editor to the given rectangle so it stays over the cell upon initialization and whenever
the grid scrolls.
The default handler sets the control's Bounds property.
•
bool C1EditorKeyDownFinishEdit(KeyEventArgs e)
Returns true if the given key should finalize editing and be handled by the grid.
The default handler returns true for the Tab, Enter, and Escape keys. It also handles the arrow
keys for editors based on TextBox, ComboBox, and DateTimePicker controls.
•
string C1EditorFormat(object value, string mask)
Formats a given value using a specified mask.
The default handler returns a string representation of the value (C1EditorGetValue().ToString()).
C1FlexGridClassic Control · 427
C1FlexGridClassic Control
C1FlexGridClassic is a control that derives from C1FlexGrid and provides an object model that is
virtually identical to the VSFlexGrid ActiveX control. C1FlexGridClassic was developed to allow easy
migration of existing VSFlexGrid projects.
The source code for C1FlexGridClassic is provided as a sample. You can use it as a reference that shows
how to use the C1FlexGrid control as a base class in the development of custom grid controls.
C1FlexGridClassic Class · 429
C1FlexGridClassic Reference
C1FlexGridClassic Class
All C1FlexGridClassic Members
C1FlexGridClassic Properties
AllowBigSelection
Returns or sets whether clicking on the fixed area will
select entire columns and rows.
AllowDragging
Supported by the .NET Compact Framework.
Specifies whether the user can drag rows and/or
columns with the mouse.
AllowEditing
Supported by the .NET Compact Framework.
Specifies whether the user can edit cells.
AllowMerging
Supported by the .NET Compact Framework.
Specifies whether cells with similar contents will be
merged.
AllowResizing
Supported by the .NET Compact Framework.
Specifies whether the user can resize rows or columns
with the mouse.
AllowSelection
Returns or sets whether the user can select ranges of
cells with the mouse and keyboard.
AllowSorting
Supported by the .NET Compact Framework.
Specifies whether the user can sort columns with the
mouse.
AllowUserResizing
Returns or sets whether the user is allowed to resize
rows and columns with the mouse.
AutoSizeMode
Returns or sets whether AutoSize will adjust column
widths or row heights to fit cell contents.
BackColorAlternate
Returns or sets the background color for alternate rows
(set to 0 to disable).
BackColorBkg
Returns or sets the background color of the area not
covered by any cells.
BackColorFixed
Returns or sets the background color of the fixed rows
and columns.
BackColorSel
Returns or sets the background color of the selected
cells.
BackgroundImage
Returns or sets the background image of the selected
cells.
Cell
Returns a Cell object.
CellAlignment
Returns or sets the alignment of text in the selected
cell or range.
CellBackColor
Returns or sets the background color of the selected
cell or range.
430 · C1FlexGridClassic Reference
CellButtonImage
Specifies the image used in cell buttons.
CellButtonPicture
Specifies the picture used in cell buttons.
CellChecked
Returns or sets whether a grid cell has a check mark in
it.
CellFont
Returns or sets the font attribute of the selected cell or
range.
CellFontBold
Returns or sets the Bold attribute of the font of the
selected cell or range.
CellFontItalic
Returns or sets the Italic attribute of the font of the
selected cell or range.
CellFontName
Returns or sets the name of the font of the selected
cell or range.
CellFontSize
Returns or sets the size of the font of the selected cell
or range.
CellFontStrikeThru
Returns or sets the Strikethru attribute of the font of the
selected cell or range.
CellFontUnderline
Returns or sets the Underline attribute of the font of the
selected cell or range.
CellForeColor
Returns or sets the foreground color of the selected
cell or range.
CellHeight
Returns the height of the selected cell, in twips. Also
brings the cell into view, scrolling if necessary.
CellLeft
The left portion of the cell.
CellPicture
Returns or sets the picture displayed in a selected cell
or range.
CellPictureAlignment
Returns or sets the alignment of the pictures in the
selected cell or range.
CellTextStyle
Returns or sets 3D effects for text in a selected cell or
range.
CellTop
The top of the cell.
CellWidth
Returns the width of the selected cell, in twips. Also
brings the cell into view, scrolling if necessary.
Cols
Supported by the .NET Compact Framework.
Gets the collection of columns in the grid.
ColumnCollection
Returns or sets the ColumnCollection.
ColWidthMax
Returns or sets the maximum column width, in twips.
ColWidthMin
Returns or sets the minimum column width, in twips.
ComboCount
Returns the number of items in the editor's combo list.
ComboIndex
Returns or sets the zero-based index of the current
selection in the editor's combo list.
Editable
Returns or sets whether the control allows in-cell
editing.
C1FlexGridClassic Class · 431
EditSelLength
Returns or the number of characters selected in the
editor.
EditSelStart
Returns or sets the starting point of text selected in the
editor.
EditSelText
Returns or sets the string containing the current
selection in the editor.
EditText
Returns or sets the text in the cell editor.
EditWindow
Returns a handle to the grid's editing window, or 0 if
the grid is not in edit mode.
Ellipsis
Returns or sets whether the control will display ellipsis
(...) after long strings.
ExplorerBar
Returns or sets whether column headers are used to
sort and/or move columns.
FillStyle
Returns or sets whether changes to the Text or format
properties apply to the current cell or to the entire
selection.
FixedCols
Returns or sets the number of fixed (non-scrollable)
columns.
FixedRows
Returns or sets the number of fixed (non-scrollable)
rows.
FontBold
Specifies whether text is bold.
FontItalic
Specifies whether text is italicized.
FontName
Specifies the name of the font used to display text.
FontSize
Specifies the font size for text displayed with an object.
FontStrikeThru
Specifies whether text has the Strikethru style.
FontUnderline
Specifies whether text is underlined.
ForeColorFixed
Returns or sets the foreground color of the fixed rows
and columns.
ForeColorSel
Returns or sets the foreground color of the selected
cells.
FrozenCols
Returns or sets the number of frozen (editable but nonscrollable) columns.
FrozenRows
Returns or sets the number of frozen (editable but nonscrollable) rows.
GridColor
Returns or sets the color used to draw the grid lines
between the non-fixed cells.
GridColorFixed
Returns or sets the color used to draw the grid lines
between the fixed cells.
GridLines
Returns or sets the type of lines to be drawn between
non-fixed cells.
GridLinesFixed
Returns or sets the type of lines to be drawn between
fixed cells.
432 · C1FlexGridClassic Reference
GridLineWidth
Returns or sets the width of the grid lines, in pixels.
KeyActionEnter
Supported by the .NET Compact Framework.
Specifies the action to be performed when the user
presses the Enter key.
KeyActionTab
Supported by the .NET Compact Framework.
Specifies the action to be performed when the user
presses the Tab key.
MergeCells
Returns or sets whether cells with the same contents
will be merged into a single cell.
NodeClosedPicture
Returns or sets the picture to be used for closed
outline nodes.
NodeOpenPicture
Returns or sets the picture to be used for open outline
nodes.
OutlineBar
Returns or sets the type of outline bar that should be
displayed.
OutlineCol
Returns or sets the column used to display the outline
tree.
Picture
Returns a picture of the entire control.
Redraw
Specifies whether the grid should paint its contents.
RowHeightMax
Returns or sets the maximum row height, in twips.
RowHeightMin
Returns or sets the minimum row height, in twips.
Rows
Gets the collection of rows in the grid.
SelectedRows
Returns the number of selected rows when
SelectionMode is set to flexSelectionListBox.
SelectionMode
Specifies the selection behavior of the grid.
SheetBorder
Returns or sets the color used to draw the border
around the sheet.
Sort
Specifies a sorting order.
Styles
Gets the collection of cell styles in the grid.
TabBehavior
Returns or sets whether the tab key will move focus
between controls (VB default) or between grid cells.
Text
Returns or sets the contents of the selected cell or
range.
TextStyle
Returns or sets 3D effects for displaying text in nonfixed cells.
TextStyleFixed
Returns or sets 3D effects for displaying text in fixed
cells.
TreeColor
Returns or sets the color used to draw the outline tree.
Value
Returns the numeric value of the current cell.
WallPaper
Returns or sets a picture to be used as a background
for the control's scrollable area.
WordWrap
Specifies whether long strings are allowed to wrap
within the cell.
C1FlexGridClassic Class · 433
C1FlexGridClassic Methods
AutoSize
Resizes column widths or row heights to fit cell contents.
Clear
Clears the contents of the control. Optional parameters specify what to
clear and where.
ComboItem
Returns the string associated with an item in the editor's combo list.
EditCell
Activates edit mode.
FindRow
Finds a row that contains a given string or object.
get_Cell
Returns cell properties for an arbitrary range.
get_ColAlignment
Returns the alignment of the given column.
get_ColComboList
Returns the list to be used as a drop-down on the specified column.
get_ColData
Returns a user-defined variant associated with the given column.
get_ColDataType
Returns the data type for the column.
get_ColEditMask
Returns the input mask used to edit cells on the specified column.
get_ColFormat
Returns the format used to display numeric values.
get_ColHidden
Returns whether a column is hidden.
get_ColIndent
Returns the indentation of the given column, in twips.
get_ColIndex
Returns the column index that matches the given key.
get_ColIsVisible
Returns whether a given column is currently within view.
get_ColKey
Returns a key used to identify the given column.
get_ColPos
Returns the left (x) coordinate of a column relative to the edge of the
control, in twips.
get_ColSort
Returns the sorting order for each column (for use with the Sort
property).
get_ColWidth
Returns the width of the specified column, in twips.
get_FixedAlignment
Returns the alignment for the fixed rows in a column.
get_IsCollapsed
Returns whether a row is collapsed.
get_IsSelected
Returns whether a row is selected (for listbox-type selections).
get_IsSubtotal
Returns whether a row contains subtotals (as opposed to data).
get_MergeCol
Returns whether a column will have its cells merged (see also the
MergeCells property).
GetMergedRange
Returns the range of merged cells that includes a given cell.
get_MergeRow
Returns whether a row will have its cells merged.
GetNode
Returns an outline node object for a given subtotal row.
GetNodeRow
Returns the number of a row's parent, first, or last child in an outline.
get_RowData
Returns a user-defined variant associated with the given row.
get_RowHeight
Returns the height of the specified row, in twips.
434 · C1FlexGridClassic Reference
get_RowHidden
Returns whether a row is hidden.
get_RowIsVisible
Returns whether a given row is currently within view.
get_RowOutlineLevel
Returns the outline level for a subtotal row.
get_RowPos
Returns the top (y) coordinate of a row relative to the edge of the
control, in twips.
GetSelection
Returns the current selection ordered so that Row1 <= Row2 and Col1
<= Col2.
get_TextMatrix
Returns the contents of a cell identified by its row and column
coordinates.
get_ValueMatrix
Returns the numeric value of a cell identified by its row and column
coordinates.
Outline
Sets an outline level for displaying subtotals.
PrintGrid
Prints the grid, optionally showing a print preview dialog.
RemoveItem
Removes a row from the control.
SelectedRow
Returns the position of a selected row when SelectionMode is set to
flexSelectionListBox.
set_Cell
Sets cell properties for an arbitrary range.
set_ColAlignment
Sets the alignment of the given column.
set_ColComboList
Sets the list to be used as a drop-down on the specified column.
set_ColData
Sets a user-defined variant associated with the given column.
set_ColDataType
Sets the data type for the column.
set_ColEditMask
Sets the input mask used to edit cells on the specified column.
set_ColFormat
Sets the format used to display numeric values.
set_ColHidden
Sets whether a column is hidden.
set_ColImageList
Sets a handle to an ImageList to be used as a source of pictures for a
given column.
set_ColIndent
Sets the indentation of the given column, in twips.
set_ColKey
Sets a key used to identify the given column.
set_ColPosition
Moves a given column to a new position.
set_ColSort
Sets the sorting order for each column (for use with the Sort property).
set_ColWidth
Sets the width of the specified column, in twips.
set_FixedAlignment
Sets the alignment for the fixed rows in a column.
set_IsCollapsed
Sets whether a row is collapsed.
set_IsSelected
Sets whether a row is selected (for listbox-type selections).
set_IsSubtotal
Sets whether a row contains subtotals (as opposed to data).
set_MergeCol
Sets whether a column will have its cells merged (see also the
MergeCells property).
AllowBigSelection Property · 435
set_MergeRow
Sets whether a row will have its cells merged (see also the MergeCells
property).
set_RowData
Sets a user-defined variant associated with the given row.
set_RowHeight
Sets the height of the specified row, in twips.
set_RowHidden
Sets whether a row is hidden.
set_RowOutlineLevel
Sets the outline level for a subtotal row.
set_RowPosition
Moves a given row to a new position.
set_TextMatrix
Sets the contents of a cell identified by its row and column
coordinates.
C1FlexGridClassic Properties
AllowBigSelection Property
Returns or sets whether clicking on the fixed area will select entire columns and rows.
Syntax
[VB]
Public Property AllowBigSelection As Boolean
[C#]
public bool AllowBigSelection {get; set;}
[Delphi]
property AllowBigSelection: Boolean;
Remarks
If AllowBigSelection is set to True, clicking on the top left fixed cell selects the entire grid.
See Also
C1FlexGridClassic Class (page 429)
SelectionMode Property (page 156)
AllowDragging Property (C1FlexGridClassic)
Specifies whether the user can drag rows and/or columns with the mouse.
Syntax
[VB]
Public AllowDragging As AllowDraggingEnum
[C#]
public AllowDraggingEnum AllowDragging {get; set;}
[Delphi]
property AllowDragging: AllowDraggingEnum;
436 · C1FlexGridClassic Reference
Property Value
One of the AllowDraggingEnum values. The default is AllowDraggingEnum.Columns.
Member Name
Description
None
The user cannot drag rows and columns with the mouse.
Columns
The user can drag columns to new positions with the mouse.
Rows
The user can drag rows to new positions with the mouse.
Both
The user can drag rows and columns to new positions with the mouse.
Remarks
You can prevent specific rows and columns from being dragged by setting their AllowDragging property
to False. For example:
•
Visual Basic
flex.AllowDragging = AllowDraggingEnum.Columns
flex.Cols(2).AllowDragging = False
•
C#
flex.AllowDragging = AllowDraggingEnum.Columns;
flex.Cols[2].AllowDragging = false;
•
Delphi
flex.AllowDragging := AllowDraggingEnum.Columns;
flex.Cols[2].AllowDragging := false;
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
AllowEditing Property (C1FlexGridClassic)
Specifies whether the user can edit cells.
Syntax
[VB]
Public AllowEditing As Boolean
[C#]
public bool AllowEditing { get; set;}
[Delphi]
property AllowEditing: Boolean;
Property Value
The default value is True.
AllowMerging Property (C1FlexGridClassic) · 437
Remarks
You can prevent specific rows and columns from being edited by setting their AllowEditing property to
False. For example:
•
Visual Basic
flex.AllowEditing = True
flex.Cols(2).AllowEditing = False ' prevent editing column 2
•
C#
flex.AllowEditing = true;
flex.Cols[2].AllowEditing = false; // prevent editing column 2
•
Delphi
flex.AllowEditing := true;
flex.Cols[2].AllowEditing := false; // prevent editing column 2
For more details and examples on cell editing, see Editing Cells (page 34).
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
AllowMerging Property (C1FlexGridClassic)
Specifies whether cells with similar contents will be merged.
Syntax
[VB]
Public AllowMerging As AllowMergingEnum
[C#]
public AllowMergingEnum AllowMerging {get; set;}
[Delphi]
property AllowMerging: AllowMergingEnum;
Property Value
One of the AllowMergingEnum values. The default is AllowMergingEnum.None.
Member Name
Description
None
Do not merge cells.
Free
Merge any adjacent cells with same contents.
RestrictRows
Merge rows only if cells above are also merged.
RestrictCols
Merge columns only if cells to the left are also merged.
RestrictAll
Merge cells only if cells above or to the left are also merged.
FixedOnly
Merge only fixed cells. This setting is useful for setting up complex headers for
the data and preventing the data itself from being merged.
438 · C1FlexGridClassic Reference
Member Name
Description
Spill
Allow long entries to spill into empty adjacent cells.
Nodes
Allow entries in Node rows to spill into empty adjacent cells.
Remarks
Merging cells allows you to display data in a clear, appealing way because it highlights groups of
identical information. It also gives you flexibility to build tables similar to the ones you can create in
HTML or using Microsoft Word, both of which support merged cells.
To create tables with merged cells, you must set the AllowMerging property to a value other than
AllowMergingEnum.None, and then set the AllowMerging property of individual rows and columns
true for the rows and columns you wish to merge. After these properties are set, the grid will
automatically merge neighboring cells that have the same contents. Whenever the cell contents change,
the grid updates the merging state.
Example
The code below causes the grid to merge adjacent cells with the same data in column 1:
•
Visual Basic
flex.AllowMerging = AllowMergingEnum.Free
flex.Cols(1).AllowMerging = True ' merge values in column 1
•
C#
flex.AllowMerging = AllowMergingEnum.Free;
flex.Cols[1].AllowMerging = true; // merge values in column 1
•
Delphi
flex.AllowMerging := AllowMergingEnum.Free;
flex.Cols[1].AllowMerging := true; // merge values in column 1
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
AllowResizing Property (C1FlexGridClassic)
Specifies whether the user can resize rows or columns with the mouse.
Syntax
[VB]
Public AllowResizing As AllowResizingEnum
[C#]
public AllowResizingEnum AllowResizing {get; set;}
[Delphi]
property AllowResizing: AllowResizingEnum;
AllowSelection Property · 439
Property Value
One of the AllowResizingEnum values. The default is AllowResizingEnum.Columns.
Member Name
Description
None
The user may not resize rows or columns.
Columns
The user may resize columns by dragging the edges of the fixed cells along the
top of the grid. Double clicking the edge of the fixed cells adjusts the column to fit
the widest entry in the column.
ColumnsUniform
The user may resize columns with the mouse. When a column is resized, the
new column height is applied to all columns.
Rows
The user may resize rows by dragging the edges of the fixed cells along the left
of the grid. Double clicking the edge of the fixed cells adjusts the row to fit the
tallest entry in the row.
Both
The user may resize rows and columns with the mouse.
RowsUniform
The user may resize rows with the mouse. When a row is resized, the new row
height is applied to all rows.
BothUniform
The user may resize rows and columns with the mouse. When a row or column is
resized, the new size is applied to all rows or columns.
Remarks
To resize rows or columns, the mouse must be over the fixed area of the grid, and close to a border
between rows or columns. The mouse pointer will then change into a sizing pointer and the user can drag
the row or column to change the row height or column width.
If a group of columns is selected (from first to last row) and the user resizes one of them, all selected
columns are resized. The same applies to rows.
If column sizing is allowed, users may double-click the resizing area to resize a column so it will
automatically fit the longest entry.
Rows with zero height and columns with zero width cannot be resized by the user. If you want to make
them very small but still resizable, set their height or width to one pixel, not to zero.
The BeforeResizeRow and BeforeResizeColumn events fire before resizing starts, and may be used to
prevent resizing of specific rows and columns. The AfterResizeRow and AfterResizeColumn fire after
resizing, and may be used to validate the user's action and to update the display.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
AllowSelection Property
Returns or sets whether the user can select ranges of cells with the mouse and keyboard.
440 · C1FlexGridClassic Reference
Syntax
[VB]
Public AllowSelection As Boolean
[C#]
public bool AllowSelection {get; set;}
[Delphi]
property AllowSelection: Boolean;
Remarks
Set this property to False to prevent users from extending the selection by clicking and dragging or using
the shift plus cursor keys. In this case, clicking and dragging the mouse will move the current cell, but
will not extend the selection.
This capability is useful when using the C1FlexGridClassic control to implement certain user interface
elements such as menus, property sheets, or explorer-style trees.
See Also
C1FlexGridClassic Class (page 429)
SelectionMode Property (page 156)
AllowSorting Property (C1FlexGridClassic)
Specifies whether the user can sort columns with the mouse.
Syntax
[VB]
Public AllowSorting As AllowSortingEnum
[C#]
public AllowSortingEnum AllowSorting {get; set;}
[Delphi]
property AllowSorting: AllowSortingEnum;
Property Value
One of the AllowSortingEnum values. The default is AllowSortingEnum.SingleColumn.
Member Name
Description
None
The user cannot sort columns with the mouse.
SingleColumn
The user can sort columns with the mouse. Clicking on a column header sorts
that column in ascending or descending order.
This setting provides the behavior seen in most standard applications such as
the Windows Explorer.
AllowUserResizing Property · 441
Member Name
Description
MultiColumn
The user can sort columns with the mouse. Clicking on a column header sorts all
columns form the first to the one that was clicked in ascending or descending
order.
This setting is useful when data is grouped by categories, from left to right, and
you want to preserve the grouping when the data is sorted.
Remarks
When the grid is used in bound mode, the sorting is performed on the underlying data table.
When the grid is unbound, you can also sort data using the Sort property.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
AllowUserResizing Property
Returns or sets whether the user is allowed to resize rows and columns with the mouse.
Syntax
[VB]
Public AllowUserResizing As AllowUserResizeSettings
[C#]
public AllowUserResizeSettings AllowUserResizing {get; set;}
[Delphi]
property AllowUserResizing: AllowUserResizeSettings;
Remarks
Valid settings for the AllowUserResizing property are:
Member Name
Description
flexResizeNone (0)
The user may not resize rows or columns.
flexResizeColumns (1)
The user may resize column widths.
flexResizeRows (2)
The user may resize row heights.
flexResizeBoth (3)
The user may resize column widths and row heights.
flexResizeBothUniform (4)
The user may resize column widths and row heights.
flexResizeRowsUniform (5)
When a row height is resized, the new height is applied
to all rows.
To resize rows or columns, the mouse must be over the fixed area of the control, and close to a border
between rows or columns. The mouse pointer will then change into a sizing pointer and the user can drag
442 · C1FlexGridClassic Reference
the row or column to change the row height or column width.
A group of columns is selected (from first to last row) and the user resizes one of them, all selected
columns are resized. The same applies to rows. To allow users to select entire rows and columns, set the
AllowBigSelection property to True.
If column sizing is allowed and the AutoSizeMouse property is set to True, users may double-click the
resizing area to resize a column so it will automatically fit the longest entry.
Rows with zero height and columns with zero width cannot be resized by the user. If you want to make
them very small but still resizable, set their height or width to one pixel, not to zero. For example:
•
Visual Basic
fg.set_ColWidth(5,1)
•
C#
fg.set_ColWidth(5,1);
•
Delphi
fg.set_ColWidth(5, 1);
The BeforeUserResize event is fired before resizing starts, and may be used to prevent resizing of specific
rows and columns. The AfterUserResize event is fired after resizing, and may be used to validate the
user's action.
See Also
C1FlexGridClassic Class (page 429)
AllowResizing Property (page 113)
AutoSizeMode Property
Returns or sets whether AutoSize will adjust column widths or row heights to fit cell contents.
Syntax
[VB]
Public AutoSizeMode As AutoSizeSettings
[C#]
public AutoSizeSettings AutoSizeMode {get; set;}
[Delphi]
property AutoSizeMode: AutoSizeSettings;
Remarks
Valid settings for the AutoSizeMode property are:
Member Name
Description
flexAutoSizeColWidth
The user may not resize rows or columns.
flexAutoSizeRowHeight
The user may resize column widths.
BackColorAlternate Property · 443
The flexAutoSizeRowHeight setting is useful when text is allowed to wrap within cells (see the
WordWrap property) or when cells have fonts of different sizes (see the Cell property).
See Also
C1FlexGridClassic Class (page 429)
AutoSizeCol Method (page 165)
BackColorAlternate Property
Returns or sets the background color for alternate rows (set to 0 to disable).
Syntax
[VB]
Public BackColorAlternate As Color
[C#]
public Color BackColorAlternate {get; set;}
[Delphi]
property BackColorAlternate: Color;
Remarks
If you set the BackColorAlternate property to a non-zero value, the color specified is used to paint every
other row in the control, creating a checkbook look.
Using this property is faster and more efficient than using the CellBackColor property to paint every
other row. Besides, the alternating colors are preserved even if you sort the grid or add and remove rows.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
BackColorBkg Property
Returns or sets the background color of the area not covered by any cells.
Syntax
[VB]
Public BackColorBkg As Color
[C#]
public Color BackColorBkg {get; set}
[Delphi]
property BackColorBkg: Color;
444 · C1FlexGridClassic Reference
Remarks
See the BackColor property for a diagram that shows which colors are used to paint which areas of the
grid.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
BackColorFixed Property
Returns or sets the background color of the fixed rows and columns.
Syntax
[VB]
Public BackColorFixed As Color
[C#]
public Color BackColorFixed {get; set}
[Delphi]
property BackColorFixed: Color;
Remarks
See the BackColor property for a diagram that shows which colors are used to paint which areas of the
grid.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
BackColorSel Property
Returns or sets the background color of the selected cells.
Syntax
[VB]
Public BackColorSel As Color
[C#]
public Color BackColorSel {get; set}
[Delphi]
property BackColorSel: Color;
Remarks
See the BackColor property for a diagram that shows which colors are used to paint which areas of the
grid.
BackgroundImage Property · 445
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
BackgroundImage Property
Returns or sets the background image of the selected cells.
Syntax
[VB]
Public Property BackgroundImage As Image
[C#]
public Image BackgroundImage {get; set;}
[Delphi]
property BackgroundImage: Image;
See Also
C1FlexGridClassic Class (page 429)
Cell Property
Returns a Cell object.
Syntax
[VB]
Public ReadOnly Property Cell As C1.Win.C1FlexGrid.Classic.Cell
[C#]
public C1.Win.C1FlexGrid.Classic.Cell Cell {get;}
[Delphi]
property Cell: C1.Win.C1FlexGrid.Classic.Cell;
See Also
C1FlexGridClassic Class (page 429)
CellAlignment Property
Returns or sets the alignment of text in the selected cell or range.
Syntax
[VB]
Public CellAlignment As AlignmentSettings
446 · C1FlexGridClassic Reference
[C#]
public AlignmentSettings CellAlignment {get; set;}
[Delphi]
property CellAlignment: AlignmentSettings;
Remarks
Valid settings for the CellAlignment property are:
Member Name
Description
flexAlignLeftTop
Aligns to the left top.
flexAlignLeftCenter
Aligns to the left center.
flexAlignLeftBottom
Aligns to the left bottom.
flexAlignCenterTop
Aligns to the center top.
flexAlignCenterCenter
Aligns to the center.
flexAlignCenterBottom
Aligns to the center bottom.
flexAlignRightTop
Aligns to the right top.
flexAlignRightCenter
Aligns to the right center.
flexAlignRightBottom
Aligns to the right bottom.
flexAlignGeneral
Aligns text to the left and numbers and dates to the right.
Changing this property affects the current cell or the current selection, depending on the setting of the
FillStyle property. To set the alignment of an arbitrary range of cells (not necessarily the current
selection), use the Cell property instead.
This sample selects the first seven cells in column 3 and centers the text.
•
Visual Basic
With fg
'select rows 1 through 7 in Column 3
.Select 1, 3, 7, 3
.FillStyle = FillStyleSettings.flexFillRepeat
.CellAlignment = AlignmentSettings.flexAlignCenterCenter
'return .FillStyle to its default (if needed)
.FillStyle = FillStyleSettings.flexFillSingle
End With
•
C#
//select rows 1 through 7 in Column 3
fg.Select 1, 3, 7, 3;
fg.FillStyle = FillStyleSettings.flexFillRepeat;
df.CellAlignment = AlignmentSettings.flexAlignCenterCenter;
//return .FillStyle to its default (if needed)
fg.FillStyle = FillStyleSettings.flexFillSingle;
} With
CellBackColor Property · 447
•
Delphi
With fg do
begin
// select rows 1 through 7 in Column 3
Select(1, 3, 7, 3);
FillStyle := FillStyleSettings.flexFillRepeat;
CellAlignment := AlignmentSettings.flexAlignCenterCenter;
// return .FillStyle to its default (if needed)
FillStyle := FillStyleSettings.flexFillSingle;
end;
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellBackColor Property
Returns or sets the background color of the selected cell or range.
Syntax
[VB]
Public CellBackColor As Color
[C#]
public Color CellBackColor {get; set;}
[Delphi]
property CellBackColor: Color;
Remarks
Setting this property to zero (black) causes the control to paint the cell using the standard colors (set by
the BackColor and BackColorAlternate properties). Therefore, to set this property to black, use RGB(1,1,1)
instead of RGB(0,0,0).
The following code only changes the back color of the current cell:
•
Visual Basic
fg.CellBackColor = System.Drawing.Color.Red
•
C#
fg.CellBackColor = System.Drawing.Color.Red;
•
Delphi
fg.CellBackColor := System.Drawing.Color.Red;
Changing this property affects the current cell or the current selection, depending on the setting of the
FillStyle property. To set the back color of an arbitrary range of cells (not necessarily the current
selection), use the Cell property instead.
For example, the following code selects the first seven cells in column 3 and sets the BackColor for those
cells:
448 · C1FlexGridClassic Reference
•
Visual Basic
With fg
.Select (1, 3, 7, 3)
.FillStyle = FillStyleSettings.flexFillRepeat
.CellBackColor = System.Drawing.Color.Red
'return .FillStyle to its default (if needed)
.FillStyle = FillStyleSettings.flexFillSingle
'Make cell 1, 1 the current cell so we can view the change
.Select (1, 1)
End With
•
C#
fg.Select (1, 3, 7, 3);
fg.FillStyle = FillStyleSettings.flexFillRepeat;
fg.CellBackColor = System.Drawing.Color.Red;
//return .FillStyle to its default (if needed)
fg.FillStyle = FillStyleSettings.flexFillSingle;
//Make cell 1, 1 the current cell so we can view the change
fg.Select (1, 1);
•
Delphi
With fg do
begin
Select (1, 3, 7, 3);
FillStyle := FillStyleSettings.flexFillRepeat;
CellBackColor := System.Drawing.Color.Red;
// return .FillStyle to its default (if needed)
FillStyle := FillStyleSettings.flexFillSingle;
// Make cell 1, 1 the current cell so we can view the change
Select (1, 1);
end;
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellButtonImage Property (C1FlexGridClassic)
Specifies the image used in cell buttons.
Syntax
[VB]
Public CellButtonImage As Image
[C#]
public Image CellButtonImage {get; set;}
[Delphi]
property CellButtonImage: Image;
Remarks
This property allows you to customize the appearance of cell buttons. For details on how to create and
handle cell buttons, see the CellButtonClick event.
CellButtonPicture Property · 449
If you want to use a single picture for all cell buttons on the grid, assign the picture to the
CellButtonImage property at design time. To change pictures depending on the row, column, or cell
being edited, trap the BeforeEdit event and set the picture accordingly.
The pictures used for cell buttons should fit within the button (larger pictures are truncated). They should
also be transparent, so the button face can be seen through the empty parts of the picture. For best results,
use small icons (16 x 16 pixels) and draw the picture in the upper left 12 x 12 rectangle within the icon.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
CellButtonPicture Property
Specifies the picture used in cell buttons.
Syntax
[VB]
Public Property CellButtonPicture As System.Drawing.Image
[C#]
public Image CellButtonPicture {get; set;}
[Delphi]
property CellButtonPicture: Image;
See Also
C1FlexGridClassic Class (page 429)
CellChecked Property
Returns or sets whether a grid cell has a check mark in it.
Syntax
[VB]
Public CellChecked As CellCheckedSettings
[C#]
public CellCheckedSettings CellChecked {get; set;}
[Delphi]
property CellChecked: CellCheckedSettings;
Remarks
Valid settings for the CellChecked property are:
Member Name
Description
flexNoCheckbox
The cell has no check box. This is the default setting.
450 · C1FlexGridClassic Reference
Member Name
Description
flexChecked
The cell has a check box that is checked.
flexUnchecked
The cell has a check box that is not checked.
If the cell has a check box and the Editable property is set to True, the user can toggle the check boxes by
clicking them with the mouse or by hitting the space or return keys on the keyboard. Either way, the
AfterEdit event is fired after the toggle so you can take appropriate action.
The check box may appear on the left, right, or center of the cell, depending on the setting of the
CellPictureAlignment property.
Changing this property affects the current cell or the current selection, depending on the setting of the
FillStyle property. To set check box values of an arbitrary range of cells (not necessarily the current
selection), use the Cell property instead.
For example, the code below makes column 1:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim r&
For r = fg.FixedRows To fg.Rows - 1
fg.set_Cell(CellPropertySettings.flexcpChecked, _
r, 1, CellPropertySettings.flexcpChecked)
fg.set_Cell(CellPropertySettings.flexcpText, r, 1, "Row " &
r)
Next
fg.Editable = EditableSettings.flexEDKbdMouse
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim r&
For r = fg.FixedRows To fg.Rows - 1
If fg.get_Cell(CellPropertySettings.flexcpChecked, r, 1) =
_
CellPropertySettings.flexcpChecked Then
Debug.WriteLine(fg.get_TextMatrix(1, 1) & " is
checked")
End If
Next
End Sub
•
C#
private void Form1_Load( System.object sender, System.EventArgs e) {
r&;
for ( r = fg.FixedRows; r <= fg.Rows - 1
fg.set_Cell(CellPropertySettings.flexcpChecked,
r, 1, CellPropertySettings.flexcpChecked);
fg.set_Cell(CellPropertySettings.flexcpText, r, 1, "Row " +
r);
} //
fg.Editable = EditableSettings.flexEDKbdMouse;
}
private void Button1_Click( System.object sender, System.EventArgs e)
{
for (int r = fg.FixedRows; r <= fg.Rows – 1; r++)
{
CellFont Property · 451
if ( fg.get_Cell(CellPropertySettings.flexcpChecked, r, 1)
==
CellPropertySettings.flexcpChecked ) {
Console.WriteLine(fg.get_TextMatrix(1, 1) + " is
checked");
}
} //
}
•
Delphi
procedure Form1_Load(sender: System.Object; e: System.EventArgs);
var
r: Integer;
begin
For r := fg.FixedRows To fg.Rows – 1 do
begin
fg.set_Cell(CellPropertySettings.flexcpChecked, _
r, 1, CellPropertySettings.flexcpChecked);
fg.set_Cell(CellPropertySettings.flexcpText, r, 1, 'Row ' +
System.Object(r).ToString)
end;
fg.Editable := EditableSettings.flexEDKbdMouse
end;
procedure Button1_Click(sender: System.Object;
e: System.EventArgs);
var
r: Integer;
begin
For r := fg.FixedRows To fg.Rows – 1 do
begin
If fg.get_Cell(CellPropertySettings.flexcpChecked, r, 1) = _
CellPropertySettings.flexcpChecked Then
Debug.WriteLine(fg.get_TextMatrix(1, 1).ToString + " is checked")
end;
end;
See Also
C1FlexGridClassic Class (page 429)
Checkbox Property (page 277)
CellFont Property
Returns or sets the font attribute of the selected cell or range.
Syntax
[VB]
Public CellFont As Boolean
[C#]
public bool CellFont {get; set;}
[Delphi]
property CellFont: Boolean;
452 · C1FlexGridClassic Reference
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellFontBold Property
Returns or sets the Bold attribute of the font of the selected cell or range.
Syntax
[VB]
Public CellFontBold As Boolean
[C#]
public bool CellFontBold {get; set;}
[Delphi]
property CellFontBold: Boolean;
Remarks
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To set the font of an arbitrary range of cells (not necessarily the current selection), use
the Cell property instead.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellFontItalic Property
Returns or sets the Italic attribute of the font of the selected cell or range.
Syntax
[VB]
Public CellFontItalic As Boolean
[C#]
public bool CellFontItalic {get; set;}
[Delphi]
property CellFontItalic: Boolean;
Remarks
Changing this property affects the current cell or the current selection, depending on the setting of the
FillStyle property. To set the font of an arbitrary range of cells (not necessarily the current selection), use
the Cell property instead.
CellFontName Property · 453
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellFontName Property
Returns or sets the name of the font of the selected cell or range.
Syntax
[VB]
Public CellFontName As String
[C#]
public string CellFontName {get; set;}
[Delphi]
property CellFontName: string;
Remarks
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To set the font of an arbitrary range of cells (not necessarily the current selection), use
the Cell property instead.
Setting this property to an empty string resets the cell formatting and causes the default font to be used.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellFontSize Property
Returns or sets the size of the font of the selected cell or range.
Syntax
[VB]
Public CellFontSize As Integer
[C#]
public int CellFontSize {get; set;}
[Delphi]
property CellFontSize: Integer;
Remarks
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To set the font of an arbitrary range of cells (not necessarily the current selection), use
the Cell property instead.
Setting this property to zero resets the cell formatting and causes the default font to be used.
454 · C1FlexGridClassic Reference
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellFontStrikeThru Property
Returns or sets the Strikethru attribute of the font of the selected cell or range.
Syntax
[VB]
Public CellFontStrikeThru As Boolean
[C#]
public bool CellFontStrikeThru {get; set;}
[Delphi]
property CellFontStrikeThru: Boolean;
Remarks
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To set the font of an arbitrary range of cells (not necessarily the current selection), use
the Cell property instead.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellFontUnderline Property
Returns or sets the Underline attribute of the font of the selected cell or range.
Syntax
[VB]
Public CellFontUnderline As Boolean
[C#]
public bool CellFontUnderline {get; set;}
[Delphi]
property CellFontUnderline: Boolean;
Remarks
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To set the font of an arbitrary range of cells (not necessarily the current selection), use
the Cell property instead.
CellForeColor Property · 455
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellForeColor Property
Returns or sets the foreground color of the selected cell or range.
Syntax
[VB]
Public CellForeColor As Color
[C#]
public Color CellForeColor {get; set;}
[Delphi]
property CellForeColor: Color;
Remarks
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To set the font of an arbitrary range of cells (not necessarily the current selection), use
the Cell property instead.
Setting this property to zero (black) causes the control to paint the cell using the standard color (set by the
ForeColor property). Thus, to set this property to black, use RGB(1,1,1) instead of RGB(0,0,0) or vbBlack.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellHeight Property
Returns the height of the selected cell, in twips. Also brings the cell into view, scrolling if necessary.
Syntax
[VB]
Public CellHeight As Integer
[C#]
public int CellHeight {get; set;}
[Delphi]
property CellHeight: Integer;
Remarks
The CellHeight, CellWidth, CellTop, and CellLeft properties are useful for placing other controls over
or near a specific cell. Whenever you read any of these properties, the control assumes that you want to
work on the current cell and it automatically brings it into view, scrolling if necessary.
456 · C1FlexGridClassic Reference
See Also
C1FlexGridClassic Class (page 429)
GetCellRect Method (page 176)
CellLeft Property
The left portion of the cell.
Syntax
[VB]
Public CellLeft As Integer
[C#]
public int CellLeft {get; set;}
[Delphi]
property CellLeft: Integer;
Remarks
The CellHeight, CellWidth, CellTop, and CellLeft properties are useful for placing other controls over
or near a specific cell. Whenever you read any of these properties, the control assumes that you want to
work on the current cell and it automatically brings it into view, scrolling if necessary.
See Also
C1FlexGridClassic Class (page 429)
GetCellRect Method (page 176)
CellPicture Property
Returns or sets the picture displayed in a selected cell or range.
Syntax
[VB]
Public CellPicture As Image
[C#]
public Image CellPicture {get; set;}
[Delphi]
property CellPicture: Image;
Remarks
The Picture object assigned to this property may be retrieved from another control (e.g., the Image
control's Picture property) or loaded from a disk file using Visual Basic's LoadPicture function.
Each cell may contain text and a picture. The relative position of the text and picture is determined by the
CellAlignment property and CellPictureAlignment property. If you want the text to be drawn over the
picture, set the PicturesOver property to True.
CellPictureAlignment Property · 457
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To assign pictures to an arbitrary range of cells (not necessarily the current selection),
use the Cell property instead.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellPictureAlignment Property
Returns or sets the alignment of the pictures in the selected cell or range.
Syntax
[VB]
Public CellPictureAlignment As PictureAlignmentSettings
[C#]
public PictureAlignmentSettings CellPictureAlignment {get; set;}
[Delphi]
property CellPictureAlignment: PictureAlignmentSettings;
Remarks
Valid settings for the CellPictureAlignment property are:
Member Name
Description
flexPicAlignLeftTop
Aligns to the left top.
flexPicAlignLeftCenter
Aligns to the left center.
flexPicAlignLeftBottom
Aligns to the left bottom.
flexPicAlignCenterTop
Aligns to the center top.
flexPicAlignCenterCenter
Aligns to the center.
flexPicAlignCenterBottom
Aligns to the center bottom.
flexPicAlignRightTop
Aligns to the right top.
flexPicAlignRightCenter
Aligns to the right center.
flexPicAlignRightBottom
Aligns to the right bottom.
flexPicAlignStretch
Stretches the picture to fit the cell.
flexPicAlignTile
Tiles the picture within the cell.
This property also governs the alignment of check boxes in the cells (see the CellChecked property).
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To set the picture alignment of an arbitrary range of cells (not necessarily the current
selection), use the Cell property instead.
458 · C1FlexGridClassic Reference
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellTextStyle Property
Returns or sets 3D effects for text in a selected cell or range.
Syntax
[VB]
Public CellTextStyle As TextStyleSettings
[C#]
public TextStyleSettings CellTextStyle {get; set;}
[Delphi]
property CellTextStyle: TextStyleSettings;
Remarks
The effect of the settings for the CellTextStyle property are described below:
Member Name
Description
flexTextFlat
Draw text normally.
flexTextRaised
Draw text with a strong raised 3-D effect.
flexTextInset
Draw text with a strong inset 3-D effect.
flexTextRaisedLight
Draw text with a light raised 3-D effect.
flexTextInsetLight
Draw text with a light inset 3-D effect.
Constants flexTextRaised and flexTextInset work best for large and bold fonts. Constants
flexTextRaisedLight and flexTextInsetLight work best for small regular fonts.
Changing this property affects the current cell or the current selection depending on the setting of the
FillStyle property. To set the picture alignment of an arbitrary range of cells (not necessarily the current
selection), use the Cell property instead.
See Also
C1FlexGridClassic Class (page 429)
CellStyle class (page 356)
CellTop Property
Returns or sets the top of the cell.
CellWidth Property · 459
Syntax
[VB]
Public CellTop As Integer
[C#]
public int CellTop {get; set;}
[Delphi]
property CellTop: Integer;
Remarks
The CellHeight, CellWidth, CellTop, and CellLeft properties are useful for placing other controls over
or near a specific cell. Whenever you read any of these properties, the control assumes that you want to
work on the current cell and it automatically brings it into view, scrolling if necessary.
See Also
C1FlexGridClassic Class (page 429)
GetCellRect Method (page 176)
CellWidth Property
Returns the width of the selected cell, in twips. Also brings the cell into view, scrolling if necessary.
Syntax
[VB]
Public CellWidth As Integer
[C#]
public int CellWidth {get; set;}
[Delphi]
property CellWidth: Integer;
Remarks
The CellHeight, CellWidth, CellTop, and CellLeft properties are useful for placing other controls over
or near a specific cell. Whenever you read any of these properties, the control assumes that you want to
work on the current cell and it automatically brings it into view, scrolling if necessary.
See Also
C1FlexGridClassic Class (page 429)
GetCellRect Method (page 176)
Cols Property (C1FlexGridClassic)
Gets the collection of columns in the grid.
460 · C1FlexGridClassic Reference
Syntax
[VB]
Public Cols As ColumnCollection
[C#]
public ColumnCollection Cols {get;}
[Delphi]
property Cols: ColumnCollection;
Remarks
The Cols property enables you to obtain a reference to the list of columns that are currently stored in the
grid. With this reference, you can add, remove, move, and count the columns. For more information on
the tasks that can be performed with this collection, see the ColumnCollection class reference topics.
This property is read-only. The grid creates and manages the collection.
Upgrade Note: In the VSFlexGrid ActiveX control, the Cols and FixedCols properties corresponded to
the number of columns and fixed columns on the grid. In C1FlexGrid, use Cols.Count and Cols.Fixed.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
ColumnCollection Property
Returns or sets the ColumnCollection.
Syntax
[VB]
Public Property ColumnCollection As C1.Win.C1FlexGrid.ColumnCollection
[C#]
public C1.Win.C1FlexGrid.ColumnCollection ColumnCollection {get; set;}
[Delphi]
property ColumnCollection: C1.Win.C1FlexGrid.ColumnCollection;
See Also
C1FlexGridClassic Class (page 429)
ColWidthMax Property
Returns or sets the maximum column width, in twips.
Syntax
[VB]
Public ColWidthMax As Integer
ColWidthMin Property · 461
[C#]
public int ColWidthMax {get; set;}
[Delphi]
property ColWidthMax: Integer;
Remarks
Set this property to a non-zero value to set a maximum limit to column widths. Set it to zero to remove
the maximum limit on column widths. Use the ColWidthMin property to set a minimum limit to column
widths.
Setting limits on column widths may be useful in conjunction with the AutoSize method to prevent
extremely long entries from making columns too wide or empty columns from becoming too narrow.
This example sets the maximum column width to 2 inches (2880 twips):
•
Visual Basic
fg.ColWidthMax = 2880
•
C#
fg.ColWidthMax = 2880;
•
Delphi
fg.ColWidthMax := 2880;
See Also
C1FlexGridClassic Class (page 429)
MaxSize Property (ColumnCollection) (page 300)
ColWidthMin Property
Returns or sets the minimum column width, in twips.
Syntax
[VB]
Public ColWidthMin As Integer
[C#]
public int ColWidthMin {get; set;}
[Delphi]
property ColWidthMin: Integer;
Remarks
Set this property to a non-zero value to set a minimum limit to column widths. Set it to zero to remove
the minimum limit on column widths. Use the ColWidthMax property to set a maximum limit to column
widths.
Setting limits on column widths may be useful in conjunction with the AutoSize method to prevent
extremely long entries from making columns too wide or empty columns from becoming too narrow.
462 · C1FlexGridClassic Reference
This example sets the minimum column width to 1/2 inch (720 twips):
•
Visual Basic
fg.ColWidthMin = 720
•
C#
fg.ColWidthMin = 720;
•
Delphi
fg.ColWidthMin := 720;
See Also
C1FlexGridClassic Class (page 429)
MinSize Property (ColumnCollection) (page 301)
ComboCount Property
Returns the number of items in the editor's combo list.
Syntax
[VB]
Public ReadOnly Property ComboCount As Integer
[C#]
public int ComboCount {get;}
[Delphi]
property ComboCount: Integer;
See Also
C1FlexGridClassic Class (page 429)
ComboIndex Property
Returns or sets the zero-based index of the current selection in the editor's combo list.
Syntax
[VB]
Public Property ComboIndex As Integer
[C#]
public int ComboIndex {get; set;}
[Delphi]
property ComboIndex: Integer;
See Also
C1FlexGridClassic Class (page 429)
Editable Property · 463
Editable Property
Returns or sets whether the control allows in-cell editing.
Syntax
[VB]
Public Editable As EditableSettings
[C#]
public EditableSettings Editable {get; set;}
[Delphi]
property Editable: EditableSettings;
Remarks
If the Editable property is set to a non-zero value, the user may edit the cell contents by typing into the
grid.
The settings for the Editable property are described below:
Member Name
Description
flexEDNone
The grid contents cannot be edited by the user.
flexEDKbd
The user may initiate edit mode by typing into the current cell.
flexEDKbdMouse
The user may initiate edit mode by typing into the current cell
or by double-clicking it with the mouse.
By default, the control goes into editing mode when the user presses the edit key (F2), the space bar, or
any printable character. If the Editable property is set to flexEDKbdMouse (2) the control will also go into
edit mode when the user double-clicks on a cell.
You may force the control into cell-editing mode using the StartEditing method, or prevent it from
entering edit mode by trapping the BeforeEdit event and setting the Cancel parameter to True. You may
cancel edit mode using the Select statement to select any cell (including the cell being edited).
You may choose to use a regular edit box, drop-down list or drop-down combo, depending on the setting
of the get_ColComboList method. You may also specify an editing mask using the EditMask property.
Set these properties in response to the BeforeEdit event.
Use the ValidateEdit event to perform data validation, and the AfterEdit event for post-editing work
such as re-sorting the control.
To determine whether the control is in edit mode, use the EditWindow property (if it has a non-zero
value, the control is in edit mode).
See Also
C1FlexGridClassic Class (page 429)
AllowEditing Property (C1FlexGrid) (page 111)
464 · C1FlexGridClassic Reference
EditSelLength Property
Returns or sets the number of characters selected in the editor.
Syntax
[VB]
Public EditSelLength As Integer
[C#]
public int EditSelLength {get; set;}
[Delphi]
property EditSelLength: Integer;
Remarks
This property works in conjunction with the EditSelStart and EditSelText properties, while the control is
in cell-editing mode.
Use these properties for tasks such as setting the insertion point, establishing an insertion range, selecting
substrings in the editor, or clearing text. Used in conjunction with the Visual Basic Clipboard object, these
properties are useful for copy, cut, and paste operations.
Notes:
1.
Setting SelLength less than 0 causes a runtime error.
2.
Setting SelStart greater than the text length sets the property to the existing text length.
3.
Changing SelStart changes the selection to an insertion point and sets SelLength to 0.
4.
Setting SelText to a new value replaces the selected text with the new string and sets SelLength to
0.
The following code selects characters 6 through 8 whenever a cell is clicked.
•
Visual Basic
Private Sub fg_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles fg.Click
fg.EditCell
fg.EditSelStart = 5
fg.EditSelLength = 3
End Sub
•
C#
private void fg_Click( System.object sender,
fg.Click {
fg.EditCell;
fg.EditSelStart = 5;
fg.EditSelLength = 3;
}
•
Delphi
procedure fg_Click(sender: System.Object;
e: System.EventArgs);
begin
System.EventArgs e)
EditSelStart Property · 465
fg.EditCell;
fg.EditSelStart := 5;
fg.EditSelLength := 3;
end;
See Also
C1FlexGridClassic Class (page 429)
Editor Property (C1FlexGrid) (page 133)
EditSelStart Property
Returns or sets the starting point of text selected in the editor.
Syntax
[VB]
Public EditSelStart As Integer
[C#]
public int EditSelStart {get; set;}
[Delphi]
property EditSelStart: Integer;
Remarks
This property works in conjunction with the EditSelLength and EditSelText properties, while the control
is in cell-editing mode.
Use these properties for tasks such as setting the insertion point, establishing an insertion range, selecting
substrings in the editor, or clearing text. Used in conjunction with the Visual Basic Clipboard object, these
properties are useful for copy, cut, and paste operations.
Notes:
1.
Setting SelLength less than 0 causes a runtime error.
2.
Setting SelStart greater than the text length sets the property to the existing text length.
3.
Changing SelStart changes the selection to an insertion point and sets SelLength to 0.
4.
Setting SelText to a new value replaces the selected text with the new string and sets SelLength to
0.
The following code selects characters 6 through 8 whenever a cell is clicked.
•
Visual Basic
Private Sub fg_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles fg.Click
fg.EditCell
fg.EditSelStart = 5
fg.EditSelLength = 3
End Sub
•
C#
private void fg_Click( System.object sender,
fg.Click {
System.EventArgs e)
466 · C1FlexGridClassic Reference
fg.EditCell;
fg.EditSelStart = 5;
fg.EditSelLength = 3;
}
•
Delphi
procedure fg_Click(sender: System.Object;
e: System.EventArgs);
begin
fg.EditCell;
fg.EditSelStart := 5;
fg.EditSelLength := 3;
end;
See Also
C1FlexGridClassic Class (page 429)
Editor Property (C1FlexGrid) (page 133)
EditSelText Property
Returns or sets the string containing the current selection in the editor.
Syntax
[VB]
Public EditSelText As String
[C#]
public string EditSelText {get; set;}
[Delphi]
property EditSelText: string;
Remarks
This property works in conjunction with the EditSelStart and EditSelLength properties, while the
control is in cell-editing mode.
Use these properties for tasks such as setting the insertion point, establishing an insertion range, selecting
substrings in the editor, or clearing text. Used in conjunction with the Visual Basic Clipboard object, these
properties are useful for copy, cut, and paste operations.
Notes:
1.
Setting SelLength less than 0 causes a runtime error.
2.
Setting SelStart greater than the text length sets the property to the existing text length.
3.
Changing SelStart changes the selection to an insertion point and sets SelLength to 0.
4.
Setting SelText to a new value replaces the selected text with the new string and sets SelLength to
0.
The following code replaces characters 6 through 8 with the word "COW" whenever a cell is
clicked.
EditText Property · 467
•
Visual Basic
Private Sub fg_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles fg.Click
fg.EditCell
fg.EditSelStart = 5
fg.EditSelLength = 3
fg.EditSelText = "COW"
End Sub
•
C#
private void fg_Click( System.object sender,
System.EventArgs e)
{
fg.EditCell;
fg.EditSelStart = 5;
fg.EditSelLength = 3;
fg.EditSelText = "COW";
}
•
Delphi
procedure fg_Click(sender: System.Object;
e: System.EventArgs);
begin
fg.EditCell;
fg.EditSelStart := 5;
fg.EditSelLength := 3;
fg.EditSelText := 'COW';
end;
See Also
C1FlexGridClassic Class (page 429)
Editor Property (C1FlexGrid) (page 133)
EditText Property
Returns or sets the text in the cell editor.
Syntax
[VB]
Public EditText As String
[C#]
public string EditText {get; set;}
[Delphi]
property EditText: string;
Remarks
The EditText property allows you to read and modify the contents of the cell editor while it is active.
This property is useful mainly for handling the ValidateEdit event. When ValidateEdit event is fired, the
cell still contains the original value. The new (edited) value is available only through the EditText
property.
468 · C1FlexGridClassic Reference
For example, the code below shows a typical handler for the ValidateEdit event. In this case, column 1
only accepts strings, and column 2 only accepts numbers greater than zero:
•
Visual Basic
Private Sub fg_ValidateEdit(ByVal sender As Object, _
ByVal e As C1.Win.C1FlexGrid.ValidateEditEventArgs) _
Handles fg.ValidateEdit
Dim c$
Select Case e.Col ' different validation rules for each column
Case 1 ' column 1 only accepts strings
c = Left$(fg.EditText, 1)
If UCaseS(c) < "A" Or UCase$(c) > "Z" Then Beep: e.Cancel = True
Case 2 ' column 2 only accepts numbers > 0
If Val(fg.EditText) <= 0 Then Beep: e.Cancel = True
End Select
End Sub
•
C#
private void fg_ValidateEdit( object sender,
C1.Win.C1FlexGrid.ValidateEditEventArgs e)
{
c$;
switch (e.Col) // different validation rules for each column
{
case 1: // column 1 only accepts strings
c = fg.EditText[0];
if ( s.ToUpper (c) < "A" || s.ToUpper(c) > "Z" ) e.Cancel = true;
case 2: // column 2 only accepts numbers > 0
try
{
int i = int.Parse(fg.EditText);
} catch {
e.Cancel = true;
}
}
}
•
Delphi
procedure fg_ValidateEdit(sender: System.Object; _
e: C1.Win.C1FlexGrid.ValidateEditEventArgs);
var
c: char;
begin
case e.Col of
// column 1 only accepts strings
1:
begin
c := fg.EditText.SubString(0, 1).ToUpper();
If (c < 'A') Or (c > 'Z') Then
e.Cancel := True;
end;
2:
begin
If Val(fg.EditText) <= 0 Then
e.Cancel := True;
end;
end;
End;
See Also
C1FlexGridClassic Class (page 429)
Editor Property (C1FlexGrid) (page 133)
EditWindow Property · 469
EditWindow Property
Returns a handle to the grid's editing window, or 0 if the grid is not in edit mode.
Syntax
[VB]
Public EditWindow As Integer
[C#]
public int EditWindow {get; set;}
[Delphi]
property EditWindow: Integer;
Remarks
You can use this property to determine whether the grid is in edit mode. If the grid is in edit mode,
EditWindow returns the window handle of the currently active text box or drop-down combo. If the grid
is not in edit mode, EditWindow returns zero.
For example, the following code prevents the user from scrolling the grid while a cell is being edited:
•
Visual Basic
Private Sub fg_BeforeScroll(ByVal sender As Object, _
ByVal e As C1.Win.C1FlexGrid.RangeEventArgs) Handles
fg.BeforeScroll
If Not fg.EditWindow.Equals(0) AndAlso e.OldRange.TopRow <>
e.NewRange.TopRow Then
e.Cancel = True
End Sub
•
C#
private void fg_BeforeScroll( object sender,
C1.Win.C1FlexGrid.RangeEventArgs e) fg.BeforeScroll {
if (!fg.EditWindow.Equals(0) && e.OldRange.TopRow !=
e.NewRange.TopRow ) {
e.Cancel = true;
}
•
Delphi
procedure fg_BeforeScroll(sender: System.Object;
e: C1.Win.C1FlexGrid.RangeEventArgs);
begin
If Not fg.EditWindow.Equals(0) and (e.OldRange.TopRow <>
e.NewRange.TopRow) Then
e.Cancel := True;
end;
See Also
C1FlexGridClassic Class (page 429)
Editor Property (C1FlexGrid) (page 133)
Ellipsis Property
Returns or sets whether the control will display ellipsis (...) after long strings.
470 · C1FlexGridClassic Reference
Syntax
[VB]
Public Ellipsis As EllipsisSettings
[C#]
public EllipsisSettings Ellipsis {get; set;}
[Delphi]
property Ellipsis: EllipsisSettings;
Remarks
The Ellipsis property determines how the control displays strings that are too long to fit the available
space in a cell. By setting this property to a non-zero value, you can force the display of an ellipsis symbol
("...") to indicate that part of the string has been truncated.
The settings for the Ellipsis property are described below:
Member Name
Description
flexNoEllipsis
Long strings are truncated, no ellipsis characters are displayed.
flexEllipsisEnd
Ellipsis characters are displayed at the end of long strings.
flexEllipsisPath
Ellipsis characters are displayed in the middle of long strings.
See Also
C1FlexGridClassic Class (page 429)
Trimming Property (page 367)
ExplorerBar Property
Returns or sets whether column headers are used to sort and/or move columns.
Syntax
[VB]
Public ExplorerBar As ExplorerBarSettings
[C#]
public ExplorerBarSettings ExplorerBar {get; set;}
[Delphi]
property ExplorerBar: ExplorerBarSettings;
Remarks
The ExplorerBar property allows users to use column headings to sort and move columns without any
code. Valid settings are described below:
ExplorerBar Property · 471
Member Name
Description
flexExNone
Long strings are truncated, no ellipsis characters are displayed.
flexExSort
Ellipsis characters are displayed at the end of long strings.
flexExMove
Ellipsis characters are displayed in the middle of long strings.
flexExSortAndMove
Users may sort and move columns.
flexExSortShow
Users may sort columns by clicking on their headings. The control will
show the current sorting order by drawing an arrow on the heading.
flexExSortShowAndMove
Users may sort and move columns. The control will show the current
sorting order by drawing an arrow on the heading.
flexExMoveRows *
Allows movement of rows by dragging them by the fixed cells on the
row.
*The setting, flexExMoveRows is actually a flag, and may be combined with other setting using the "Or"
operator. For example:
•
Visual Basic
'allow sorting, moving rows, and moving columns
fg.ExplorerBar = ExplorerBarSettings.flexExMoveRows Or
ExplorerBarSettings.flexExSortShowAndMove
•
C#
//allow sorting, moving rows, and moving columns
fg.ExplorerBar = ExplorerBarSettings.flexExMoveRows ||
ExplorerBarSettings.flexExSortShowAndMove;
•
Delphi
//allow sorting, moving rows, and moving columns
fg.ExplorerBar := (ExplorerBarSettings.flexExMoveRows or
ExplorerBarSettings.flexExSortShowAndMove);
Note that these values are a combination of binary flags and are not sequential.
By default, the ExplorerBar works like the one in Microsoft's Windows File Explorer. One click sorts the
column in ascending order, the next in descending order. Any non-fixed column may be dragged to any
non-fixed position. The control fires events that allow you to customize this behavior. The events are
BeforeSort, AfterSort, BeforeDragColumn, and AfterDragColumn.
The new ExplorerBar is easier to use. For example, when sorting, it shows sorting triangle glyphs. Also,
when moving columns, it clearly shows the new column position and scrolls the control to allow the
column to be moved anywhere.
You must have at least one fixed row to be able to use the ExplorerBar.
See Also
C1FlexGridClassic Class (page 429)
AllowResizing Property (page 113)
AllowSorting Property (C1FlexGrid) (page 114)
472 · C1FlexGridClassic Reference
FillStyle Property
Returns or sets whether changes to the Text or format properties apply to the current cell or to the entire
selection.
Syntax
[VB]
Public FillStyle As FillStyleSettings
[C#]
public FillStyleSettings FillStyle {get; set;}
[Delphi]
property FillStyle: FillStyleSettings;
Remarks
The settings for the FillStyle property are described below:
Member Name
Description
flexFillSingle
Setting the Text property or any of the cell formatting properties
affects the current cell only.
flexFillRepeat
Setting the Text property or any of the cell formatting properties
affects the entire selected range.
The FillStyle property also determines whether changes caused by in-cell editing should apply to the
current cell only or to the entire selection.
FillStyle is ignored if SelectionMode is flexSelectionListBox.
See Also
C1FlexGridClassic Class (page 429)
Selection Property (page 155)
FixedCols Property
Returns or sets the number of fixed (non-scrollable) columns.
Syntax
[VB]
Public FixedCols As Integer
[C#]
public int FixedCols {get; set;}
[Delphi]
property FixedCols: Integer;
FixedRows Property · 473
Remarks
Fixed columns remain visible when the user scrolls the contents of the grid. They are not selectable or
editable by the user (but you can select them with code and even allow the user to edit their contents by
selecting them and invoking the EditCell method). You can set FixedCols to any value between zero and
the total number of columns.
The following line of code places 3 fixed columns at the left edge of the grid.
•
Visual Basic
fg.FixedCols = 3
•
C#
fg.FixedCols = 3;
•
Delphi
fg.FixedCols := 3;
Fixed columns are typically used in spreadsheet applications to display row numbers or other types of
labels.
To format the fixed cells, use the BackColorFixed, ForeColorFixed, and GridLinesFixed, properties.
If the AllowUserResizing property is set to a non-zero value, the fixed cells allow the user to resize row
heights and column widths at run time.
See Also
C1FlexGridClassic Class (page 429)
Fixed Property (ColumnCollection) (page 298)
FixedRows Property
Returns or sets the number of fixed (non-scrollable) rows.
Syntax
[VB]
Public FixedRows As Integer
[C#]
public int FixedRows {get; set;}
[Delphi]
property FixedRows: Integer;
Remarks
Fixed rows remain visible when the user scrolls the contents of the grid. They are not selectable or
editable by the user (but you can select them with code and even allow the user to edit their contents by
selecting them and invoking the EditCell method). You can set FixedRows to any value between zero and
the total number of rows.
The following line of code places 3 fixed rows at the top edge of the grid.
474 · C1FlexGridClassic Reference
•
Visual Basic
fg.FixedRows = 3
•
C#
fg.FixedRows = 3;
•
Delphi
fg.FixedRows := 3;
Fixed rows are typically used in spreadsheet applications to display column headers, and in database
applications to display field names.
To format the fixed cells, use the BackColorFixed, ForeColorFixed, and GridLinesFixed properties.
If the AllowUserResizing property is set to a non-zero value, the fixed cells allow the user to resize row
heights and column widths at run time. If the ExplorerBar property is set to a non-zero value, the fixed
rows allow the user to sort and move columns with the mouse.
See Also
C1FlexGridClassic Class (page 429)
Fixed Property (RowCollection) (page 289)
FontBold Property
Specifies whether text is bold.
Syntax
[VB]
Public Property FontBold As Boolean
[C#]
public bool FontBold {get; set;}
[Delphi]
property FontBold: Boolean;
See Also
C1FlexGridClassic Class (page 429)
FontItalic Property
Specifies whether text is italicized.
Syntax
[VB]
Public Property FontItalic As Boolean
[C#]
public bool FontItalic {get; set;}
FontName Property · 475
[Delphi]
property FontItalic: Boolean;
See Also
C1FlexGridClassic Class (page 429)
FontName Property
Specifies the name of the font used to display text.
Syntax
[VB]
Public Property FontName As String
[C#]
public string FontName {get; set;}
[Delphi]
property FontName: String;
See Also
C1FlexGridClassic Class (page 429)
FontSize Property
Specifies the font size for text displayed with an object.
Syntax
[VB]
Public Property FontSize As Single
[C#]
public Single FontSize {get; set;}
[Delphi]
property FontSize: Single;
See Also
C1FlexGridClassic Class (page 429)
FontStrikeThru Property
Specifies whether text has the Strikethru style.
Syntax
[VB]
Public Property FontStrikeThru As Boolean
476 · C1FlexGridClassic Reference
[C#]
public bool FontStrikeThru {get; set;}
[Delphi]
property FontStrikeThru: Boolean;
See Also
C1FlexGridClassic Class (page 429)
FontUnderline Property
Specifies whether text is underlined.
Syntax
[VB]
Public Property FontUnderline As Boolean
[C#]
public bool FontUnderline {get; set;}
[Delphi]
property FontUnderline: Boolean;
See Also
C1FlexGridClassic Class (page 429)
ForeColorFixed Property
Returns or sets the foreground color of the fixed rows and columns.
Syntax
[VB]
Public ForeColorFixed As Color
[C#]
public Color ForeColorFixed {get; set;}
[Delphi]
property ForeColorFixed: Color;
Remarks
This property works to specify the color used to draw text.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
ForeColorSel Property · 477
ForeColorSel Property
Returns or sets the foreground color of the selected cells.
Syntax
[VB]
Public ForeColorSel As Color
[C#]
public Color ForeColorSel {get; set;}
[Delphi]
property ForeColorSel: Color;
Remarks
This property works to specify the color used to draw text.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
FrozenCols Property
Returns or sets the number of frozen (editable but non-scrollable) columns.
Syntax
[VB]
Public Property FrozenCols As Integer
[C#]
public int FrozenCols {get; set;}
[Delphi]
property FrozenCols: Integer;
Remarks
Cells in frozen columns can be selected and edited, but they remain visible when the user scrolls the
contents of the control horizontally.
Freezing columns is useful when the grid is used as a data browser. It allows users to user to scroll the
contents of the control while keeping the FrozenCols leftmost columns visible.
See Also
C1FlexGridClassic Class (page 429)
FrozenRows Property
Returns or sets the number of frozen (editable but non-scrollable) rows.
478 · C1FlexGridClassic Reference
Syntax
[VB]
Public Property FrozenRows As Integer
[C#]
public int FrozenRows {get; set;}
[Delphi]
property FrozenRows: Integer;
Remarks
Cells in frozen rows can be selected and edited, but they remain visible when the user scrolls the contents
of the control vertically.
Freezing rows is useful when the top rows are used to display information that should be kept visible,
such as subtotals or a "query-by-example" search row.
See Also
C1FlexGridClassic Class (page 429)
GridColor Property
Returns or sets the color used to draw the grid lines between the non-fixed cells.
Syntax
[VB]
Public GridColor As Color
[C#]
public Color GridColor {get; set;}
[Delphi]
property GridColor: Color;
Remarks
The GridColor and GridLines properties determine the appearance of the grid lines displayed in the
scrollable area of the grid. GridColorFixed and GridLinesFixed determine the appearance of the grid
lines displayed in the fixed area of the grid.
The GridColor property is ignored when GridLines is set to one of the 3D styles. Raised and inset grid
lines are always drawn using the system-defined colors for shades and highlights.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
GridColorFixed Property
Returns or sets the color used to draw the grid lines between the fixed cells.
GridLines Property · 479
Syntax
[VB]
Public GridColorFixed As Color
[C#]
public Color GridColorFixed {get; set;}
[Delphi]
property GridColorFixed: Color;
Remarks
The GridColorFixed and GridLinesFixed properties determine the appearance of the grid lines
displayed in the fixed area of the grid. GridColor and GridLines determine the appearance of the grid
lines displayed in the scrollable area of the grid.
The GridColorFixed property is ignored when GridLinesFixed is set to one of the 3D styles. Raised and
inset grid lines are always drawn using the system-defined colors for shades and highlights.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
GridLines Property
Returns or sets the type of lines to be drawn between non-fixed cells.
Syntax
[VB]
Public GridLines As GridStyleSettings
[C#]
public GridStyleSettings GridLines {get; set;}
[Delphi]
property GridLines: GridStyleSettings;
Remarks
The GridLines and GridColor properties determine the appearance of the grid lines displayed in the
scrollable area of the grid. GridLinesFixed and GridColorFixed determine the appearance of the grid
lines displayed in the fixed area of the grid.
The settings for the GridLines property are described below:
Member Name
Description
flexGridNone
Do not draw grid lines between cells.
flexGridFlat
Draw flat lines with color and width determined by the GridColor
and GridLineWidth properties.
480 · C1FlexGridClassic Reference
Member Name
Description
flexGridInset
Draw inset lines between cells.
flexGridRaised
Draw raised lines between cells.
flexGridFlatHorz
Draw flat lines between rows, no lines between columns.
flexGridInsetHorz
Draw inset lines between rows, no lines between columns.
flexGridRaisedHorz
Draw raised lines between rows, no lines between columns
flexGridSkipHorz
Draw an inset effect around every other row.
flexGridFlatVert
Draw flat lines between columns, no lines between rows.
flexGridInsetVert
Draw inset lines between columns, no lines between rows.
flexGridRaisedVert
Draw raised lines between columns, no lines between rows.
flexGridSkipVert
Draw an inset effect around every other column.
flexGridExplorer
Draw button-like frames around each cell.
flexGridExcel
Draw button-like frames around each cell, highlighting the
headings for the current selection. This setting should only be
applied to the GridLinesFixed property.
The GridColor property is ignored when GridLines is set to one of the 3D styles. Raised and inset grid
lines are always drawn using the system-defined colors for shades and highlights.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
GridLinesFixed Property
Returns or sets the type of lines to be drawn between fixed cells.
Syntax
[VB]
Public GridLinesFixed As GridStyleSettings
[C#]
public GridStyleSettings GridLinesFixed {get; set;}
[Delphi]
property GridLinesFixed: GridStyleSettings;
Remarks
The GridLinesFixed and GridColorFixed properties determine the appearance of the grid lines
displayed in the fixed area of the grid. GridLines and GridColor determine the appearance of the grid
lines displayed in the scrollable area of the grid.
The settings for the GridLinesFixed property are the same as those used for the GridLines property. The
flexGridExcel setting should only be used with the GridLinesFixed property. This setting causes the fixed
GridLineWidth Property · 481
rows and columns to show a highlighted area corresponding to the current selection. This makes it easy
for users to identify which rows and columns are selected on large grids.
The GridColorFixed property is ignored when GridLinesFixed is set to one of the 3D styles. Raised and
inset grid lines are always drawn using the system-defined colors for shades and highlights.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
GridLineWidth Property
Returns or sets the width of the grid lines, in pixels.
Syntax
[VB]
Public GridLineWidth As Integer
[C#]
public int GridLineWidth {get; set;}
[Delphi]
property GridLineWidth: Integer;
Remarks
The GridLineWidth property determines the thickness, in pixels, of the grid lines when the
GridLineWidth property or GridLinesFixed property is set to one of the flat styles (flexGridFlat,
flexGridFlatHorz, flexGridFlatVert). Raised and inset grid lines have fixed width and cannot be changed.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
KeyActionEnter Property (C1FlexGridClassic)
Specifies the action to be performed when the user presses the Enter key.
Syntax
[VB]
Public KeyActionEnter As KeyActionEnum
[C#]
public KeyActionEnum KeyActionEnter {get; set;}
[Delphi]
property KeyActionEnter: KeyActionEnum;
Property Value
One of the KeyActionEnum values. The default is KeyActionEnum.MoveDown.
482 · C1FlexGridClassic Reference
Member Name
Description
None
No special action (allow system to handle the cell). For example, the Tab key is
normally used to cycle through the controls on a form.
MoveDown
Move to the next row when the key is pressed.
MoveAcross
Move to the next column when the key is pressed. At the end of the column, move
to the next row and back to the first column.
MoveAcrossOut
Move to the next column when the key is pressed. At the end of the column, move
to the next row and back to the first column. At the end of the last column, move the
focus to the next control on the form.
Remarks
By default, the grid will move the selection to the next visible row when the user presses the Enter key. If
the grid is editable, pressing Enter will cause the grid to enter edit mode, and pressing Enter while in edit
mode will cause the cursor to move down.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
KeyActionTab Property (C1FlexGridClassic)
Specifies the action to be performed when the user presses the Tab key.
Syntax
[VB]
Public KeyActionTab As KeyActionEnum
[C#]
public KeyActionEnum KeyActionTab {get; set;}
[Delphi]
property KeyActionTab: KeyActionEnum;
Property Value
One of the KeyActionEnum values. The default is KeyActionEnum.None.
Member Name
Description
None
No special action (allow system to handle the cell). For example, the Tab key is
normally used to cycle through the controls on a form.
MoveDown
Move to the next row when the key is pressed.
MoveAcross
Move to the next column when the key is pressed. At the end of the column, move
to the next row and back to the first column.
MoveAcrossOut
Move to the next column when the key is pressed. At the end of the column, move
to the next row and back to the first column. At the end of the last column, move the
focus to the next control on the form.
KeyActionTab Property (C1FlexGridClassic) · 483
Remarks
By default, the grid will ignore the Tab key and it will be handled by the form, moving the focus to the
next control. If you set the KeyActionTab property to a value other than KeyActionEnum.None, the grid
will trap the Tab key and use it for navigating cells.
Example
The code below changes the value of the KeyActionTab property based on the current cell. The user can
press the Tab key to navigate across cells until he reaches the last cell on the grid. If he pressed Tab again,
the focus will move to the next control.
•
Visual Basic
Private Sub flex_Enter(sender As Object, e As System.EventArgs)
flex.Select(flex.Rows.Fixed, flex.Cols.Fixed)
End Sub 'flex_Enter
Private Sub flex_RowColChange(sender As Object, e As System.EventArgs)
Dim lastCell As Boolean
lastCell = flex.Col = flex.Cols.Count - 1 And _
flex.Row = flex.Rows.Count - 1
If lastCell Then
flex.KeyActionTab = KeyActionEnum.None
Else
flex.KeyActionTab = KeyActionEnum.MoveAcross
End If
End Sub 'flex_RowColChange
•
C#
private void flex_Enter(object sender, System.EventArgs e)
{
flex.Select(flex.Rows.Fixed, flex.Cols.Fixed);
}
private void flex_RowColChange(object sender, System.EventArgs e)
{
bool lastCell = (flex.Col == flex.Cols.Count-1 &&
flex.Row == flex.Rows.Count-1);
flex.KeyActionTab = (lastCell)
? KeyActionEnum.None
: KeyActionEnum.MoveAcross;
}
•
Delphi
procedure Class1.flex_Enter(sender: System.Object; e:
System.EventArgs);
begin
flex.Select(flex.Rows.Fixed, flex.Cols.Fixed);
end;
procedure flex_RowColChange(sender: System.Object; e:
System.EventArgs);
var
lastCell: Boolean;
begin
lastCell := (flex.Col = flex.Cols.Count – 1_ And
(flex.Row = flex.Rows.Count – 1);
if lastCell then
flex.KeyActionTab := KeyActionEnum.None
Else
flex.KeyActionTab := KeyActionEnum.MoveAcross;
end; // flex_RowColChange
484 · C1FlexGridClassic Reference
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
MergeCells Property
Returns or sets whether cells with the same contents will be merged into a single cell.
Syntax
[VB]
Public MergeCells As MergeSettings
[C#]
public MergeSettings MergeCells {get; set;}
[Delphi]
property MergeCells: MergeSettings;
Remarks
Valid settings for the MergeCells property are:
Member Name
Description
flexMergeNever
Do not merge cells.
flexMergeFree
Merge any adjacent cells with same contents (if they are on a row with
RowMerge set to True or a column with MergeCol set to True).
flexMergeRestrictRows
Merge rows only if cells above are also merged.
flexMergeRestrictColumns
Merge columns only if cells to the left are also merged.
flexMergeRestrictAll
Merge cells only if cells above or to the left are also merged.
flexMergeFixedOnly
Merge only fixed cells. This setting is useful for setting up complex
headers for the data and preventing the data itself from being merged.
flexMergeSpill
Allow long entries to spill into empty adjacent cells.
flexMergeOutline
Makes entries in subtotal rows spill to fill adjacent empty cells. This
setting is useful when you want to display only a node name on the
outline nodes and data on the regular (non-node) rows.
The MergeCells property is used in conjunction with the set_MergeRow and set_MergeCol methods to
control whether and how cells are merged for display. Merging cells allows you to display data in a clear,
appealing way because it highlights groups of identical information. It also gives you flexibility to build
tables similar to the ones you can create in HTML or using Microsoft Word, both of which support
merged cells.
To create tables with merged cells, you must set the MergeCells property to a value other than
flexMergeNever, and then set the set_MergeRow and set_MergeCol methods to True for the rows and
columns you wish to merge (except when using the flexMergeSpill mode). After these properties are set,
MergeCells Property · 485
the control will automatically merge neighboring cells that have the same contents. Whenever the cell
contents change, the control updates the merging state.
The flexMergeSpill setting is a little different from the others. It is the only setting that does not require
you to set the set_MergeRow and set_MergeCol methods, and that does not merge cells with identical
settings. Instead, it allows cells with long entries to spill into adjacent cells as long as they are empty. This
is often useful when creating outlines. You may use a narrow column to hold group titles, which can then
spill into the cells to the right. The picture below shows an example using the flexMergeSpill setting.
Notice how some cells with long entries spill into adjacent empty cells or get truncated if the adjacent cell
is not empty:
The flexMergeOutline setting is similar to flexMergeSpill, except it merges cells in subtotal rows with empty
adjacent cells. This is good when you want to display only a node name on the subtotal rows (nodes) and
data on the regular (non-node) rows.
The difference between the Free and Restricted settings is whether cells with the same contents should
always be merged (Free settings) or only when adjacent cells to the left or to the top are also merged. The
examples below illustrate the difference.
•
Visual Basic
' regular spreadsheet view
fg.MergeCells = MergeSettings.flexMergeNever
fg.set_MergeCol(0, True)
fg.set_MergeCol(1, True)
fg.set_MergeCol(2, True)
fg.set_MergeCol(3, False)
•
C#
// regular spreadsheet view
fg.MergeCells = MergeSettings.flexMergeNever;
fg.set_MergeCol(0, true);
fg.set_MergeCol(1, true);
fg.set_MergeCol(2, true);
fg.set_MergeCol(3, false);
•
Delphi
begin
fg.MergeCells := MergeSettings.flexMergeNever;
fg.set_MergeCol(0, True);
fg.set_MergeCol(1, True);
fg.set_MergeCol(2, True);
fg.set_MergeCol(3, False);
end;
486 · C1FlexGridClassic Reference
•
Visual Basic
' free merging: notice how the first region cell (East) merges
' across employees (Donna and John) to its left.
fg.MergeCells = MergeSettings.flexMergeFree
fg.set_MergeCol(0, True)
fg.set_MergeCol(1, True)
fg.set_MergeCol(2, True)
fg.set_MergeCol(3, False)
•
C#
// free merging: notice how the first region cell (East) merges
// across employees (Donna and John) to its left.
fg.MergeCells = MergeSettings.flexMergeFree;
fg.set_MergeCol(0, true);
fg.set_MergeCol(1, true);
fg.set_MergeCol(2, true);
fg.set_MergeCol(3, false);
•
Delphi
begin
// free merging: notice how the first region cell (East) merges
// across employees (Donna and John) to its left.
fg.MergeCells := MergeSettings.flexMergeFree;
fg.set_MergeCol(0, True);
fg.set_MergeCol(1, True);
fg.set_MergeCol(2, True);
fg.set_MergeCol(3, False);
end;
NodeClosedPicture Property · 487
•
Visual Basic
' restricted merging: notice how the first region cell (East)
' no longer merges across employees to its left.
fg.MergeCells = MergeSettings.flexMergeRestrictAll
fg.set_MergeCol(0, True)
fg.set_MergeCol(1, True)
fg.set_MergeCol(2, True)
fg.set_MergeCol(3, False)
•
C#
// restricted merging: notice how the first region cell (East)
// no longer merges across employees to its left.
fg.MergeCells = MergeSettings.flexMergeRestrictAll;
fg.set_MergeCol(0, true);
fg.set_MergeCol(1, true);
fg.set_MergeCol(2, true);
fg.set_MergeCol(3, false);
•
Delphi
begin
// restricted merging: notice how the first region cell (East)
// no longer merges across employees to its left.
fg.MergeCells := MergeSettings.flexMergeRestrictAll;
fg.set_MergeCol(0, True);
fg.set_MergeCol(1, True);
fg.set_MergeCol(2, True);
fg.set_MergeCol(3, False);
end;
See Also
C1FlexGridClassic Class (page 429)
NodeClosedPicture Property
Returns or sets the picture to be used for closed outline nodes.
Syntax
[VB]
Public Property NodeClosedPicture As System.Drawing.Image
488 · C1FlexGridClassic Reference
[C#]
public System.Drawing.Image NodeClosedPicture {get; set;}
[Delphi]
property NodeClosedPicture: System.Drawing.Image;
Remarks
If a custom picture is not provided, closed outline nodes are represented by a plus sign in a rectangle.
See Also
C1FlexGridClassic Class (page 429)
NodeOpenPicture Property
Returns or sets the picture to be used for open outline nodes.
Syntax
[VB]
Public Property NodeOpenPicture As System.Drawing.Image
[C#]
public System.Drawing.Image NodeOpenPicture {get; set;}
[Delphi]
property NodeOpenPicture: System.Drawing.Image;
Remarks
If a custom picture is not provided, closed outline nodes are represented by a minus sign in a rectangle.
See Also
C1FlexGridClassic Class (page 429)
OutlineBar Property
Returns or sets the type of outline bar that should be displayed.
Syntax
[VB]
Public Property OutlineBar As C1.Win.C1FlexGrid.Classic.OutlineBarSettings
[C#]
public OutlineBarSettings OutlineBar {get; set;}
[Delphi]
property OutlineBar: OutlineBarSettings;
OutlineCol Property · 489
Remarks
Valid settings for the OutlineBar property are:
Member Name
Description
flexOutlineBarComplete
Complete outline tree plus button row on top. (Buttons are
only displayed if the OutlineBar is on a fixed column).
flexOutlineBarCompleteLeaf
Similar to flexOutlineBarComplete, but empty nodes are
displayed without symbols.
flexOutlineBarNone
Do not show the outline bar
flexOutlineBarSimple
Complete outline tree, no buttons across the top.
flexOutlineBarSimpleLeaf
Similar to flexOutlineBarSimple, but empty nodes are
displayed without symbols.
flexOutlineBarSymbols
Outline symbols but no connecting lines.
flexOutlineBarSymbolsLeaf
Similar to flexOutlineBarSymbols, but empty nodes are
displayed without symbols.
See Also
C1FlexGridClassic Class (page 429)
OutlineCol Property
Returns or sets the column used to display the outline tree.
Syntax
[VB]
Public Property OutlineCol As Integer
[C#]
public int OutlineCol {get; set;}
[Delphi]
property OutlineCol: Integer;
Remarks
The OutlineCol property works in conjunction with the OutlineBar property to control the appearance
and behavior of the outline tree.
By default, the OutlineCol property is set to zero, so the outline bar (if present) is displayed on the first
column of the control. You may use OutlineCol to place the outline tree in a different column. If you place
the outline tree in a column that contains data, the entries will be indented to accommodate the tree.
You should normally use the AutoSize method after setting this property, to ensure that the tree and data
on the OutlineCol column are fully visible.
See Also
C1FlexGridClassic Class (page 429)
490 · C1FlexGridClassic Reference
Picture Property
Returns a picture of the entire control.
Syntax
[VB]
Public ReadOnly Property Picture As System.Drawing.Image
[C#]
public System.Drawing.Image Picture {get;}
[Delphi]
property Picture: System.Drawing.Image;
Remarks
This property returns a picture (metafile) representation of the entire control, including rows and
columns that are not visible on the screen. If you have a control with 1000 rows, for example, the picture
will include all of them.
Internally, this property calls the base class CreateImage method. CreateImage has overloads that allow
you to specify ranges to be included in the picture.
See Also
C1FlexGridClassic Class (page 429)
Redraw Property (C1FlexGridClassic)
Specifies whether the grid should paint its contents.
Syntax
[VB]
Public Property Redraw As C1.Win.C1FlexGrid.Classic.RedrawSettings
[C#]
public RedrawSettings Redraw {get; set;}
[Delphi]
property Redraw: RedrawSettings;
Remarks
Valid settings for the Redraw property are:
Member Name
Description
flexRDBuffered
The grid paints its contents on an off-screen buffer, then
transfers the complete image to the screen. This mode is
slightly slower than flexRDDirect, but it eliminates flicker.
flexRDDirect
The grid paints its contents directly on the screen.
This is the fastest repaint mode, but there occasionally it may
cause a little flicker.
RowHeightMax Property · 491
Member Name
Description
flexRDNone
The grid does not repaint itself.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
RowHeightMax Property
Returns or sets the maximum row height, in twips.
Syntax
[VB]
Public RowHeightMax As Integer
[C#]
public int RowHeightMax {get; set;}
[Delphi]
property RowHeightMax: Integer;
Remarks
Set this property to a non-zero value to set a maximum limit to row heights. This is often useful when
you use the AutoSize method to automatically set row heights, to prevent some rows from becoming too
large.
See also the ColWidthMin, ColWidthMax, and RowHeightMin properties.
See Also
C1FlexGridClassic Class (page 429)
MaxSize Property (RowCollection) (page 290)
RowHeightMin Property
Returns or sets the minimum row height, in twips.
Syntax
[VB]
Public RowHeightMin As Integer
[C#]
public int RowHeightMin {get; set;}
[Delphi]
property RowHeightMin: Integer;
492 · C1FlexGridClassic Reference
Remarks
Set this property to a non-zero value to set a minimum limit to row heights. This is often useful when you
use the AutoSize method to automatically set row heights, to prevent some rows from becoming too
short. This may also be useful when you want to use small fonts, but don't want the rows to become
short.
See also the ColWidthMin, ColWidthMax, and RowHeightMax properties.
See Also
C1FlexGridClassic Class (page 429)
MinSize Property (RowCollection) (page 291)
Rows Property (C1FlexGridClassic)
Gets the collection of rows in the grid.
Syntax
[VB]
Public Rows As RowCollection
[C#]
public RowCollection Rows {get;}
[Delphi]
property Rows: RowCollection;
Remarks
The Rows property returns a reference to the list of rows that make up the grid. With this reference, you
can add, remove, move, and count the rows. For more information on the tasks that can be performed
with this collection, see the RowCollection class reference topics.
This property is read-only. The grid creates and manages the row collection for you.
Upgrade Note: In the VSFlexGrid ActiveX control, the Rows and FixedRows properties corresponded to
the number of Rows and fixed Rows on the grid. In C1FlexGrid, use Rows.Count and Rows.Fixed.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
SelectedRows Property
Returns the number of selected rows when SelectionMode is set to flexSelectionListBox.
Syntax
[VB]
Public SelectedRows As Integer
SelectionMode Property (C1FlexGridClassic) · 493
[C#]
public int SelectedRows {get; set;}
[Delphi]
property SelectedRows: Integer;
Remarks
This property is especially useful when the SelectionMode property is set to flexSelectionListBox (3),
which allows the user to select multiple, non-adjacent rows.
The code below prints the number of selected rows to the debug window when the selection changes:
•
Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs)
fg.SelectionMode = SelModeSettings.flexSelectionListBox
End Sub
Private Sub fg_SelChange(ByVal sender As Object, ByVal e As
System.EventArgs)
Debug.WriteLine (fg.SelectedRows)
End Sub
•
C#
private void Form1_Load( System.object sender, System.EventArgs e) {
fg.SelectionMode = SelModeSettings.flexSelectionListBox;
}
private void fg_SelChange( object sender,
Debug.WriteLine (fg.SelectedRows);
}
•
System.EventArgs e) {
Delphi
procedure Form1_Load(sender: System.Object;
e: System.EventArgs);
begin
fg.SelectionMode := SelModeSettings.flexSelectionListBox;
end;
procedure fg_SelChange(sender: System.Object; e: System.EventArgs);
begin
Debug.WriteLine(fg.SelectedRows);
end;
See Also
C1FlexGridClassic Class (page 429)
Selection Property (page 155)
SelectionMode Property (C1FlexGridClassic)
Specifies the selection behavior of the grid.
494 · C1FlexGridClassic Reference
Syntax
[VB]
Public SelectionMode As SelModeSettings
[C#]
public SelModeSettings SelectionMode {get; set;}
[Delphi]
property SelectionMode: SelModeSettings;
Remarks
Valid settings for the SelectionMode property are:
Member Name
Description
flexSelectionByColumn
Forces selections to span entire columns. Useful for selecting
ranges for a chart or fields for sorting.
flexSelectionByRow
Forces selections to span entire rows. Useful for
implementing record-based displays.
flexSelectionFree
Allows selections to be made as usual, spreadsheet-style.
flexSelectionListBox
Similar to flexSelectionByRow, but allows non-continuous
selections. CTRL-clicking with the mouse toggles the
selection for an individual row. Dragging the mouse over a
group of rows toggles their selected state.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
SheetBorder Property
Returns or sets the color used to draw the border around the sheet.
Syntax
[VB]
Public SheetBorder As Color
[C#]
public Color SheetBorder {get; set;}
[Delphi]
property SheetBorder: Color;
Remarks
This property is useful if you want to make a grid look like a page, with no border around the cells. To do
this, set the SheetBorder property to the same color as the grid background (BackColor property).
Sort Property (C1FlexGridClassic) · 495
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
Sort Property (C1FlexGridClassic)
Specifies a sorting order.
Syntax
[VB]
Public Sort As SortSettings
[C#]
public SortSettings Sort {get; set;}
[Delphi]
property Sort: SortSettings;
Remarks
Valid settings for the Sort property are:
Member Name
Description
flexSortNone
Ignore this column when sorting. This setting is useful
when you assign it to a column's Cols property, then set
Sort to flexSortUseColSort.
flexSortGenericAscending
Sort strings and numbers in ascending order.
flexSortGenericDescending
Sort strings and numbers in descending order.
flexSortNumericAscending
Sort numbers in ascending order.
flexSortNumericDescending
Sort numbers in descending order.
flexSortStringNoCaseAscending
Sort strings in ascending order, ignoring capitalization.
flexSortStringNoCaseDescending
Sort strings in descending order, ignoring capitalization.
flexSortStringAscending
Sort strings in ascending order.
flexSortStringDescending
Sort strings in descending order.
flexSortCustom
Fire a Compare event and use the return value to sort the
columns.
flexSortUseColSort
This setting allows you to use different settings for each
column, as determined by the ColSort property. Using this
setting, you may sort some columns in ascending and
others in descending order.
The Sort property allows you to sort a range or rows in ascending or descending order based on the
values in one or more columns. The Sort property also honors outline structures. It will only sort data
rows, and will not scramble nodes.
496 · C1FlexGridClassic Reference
The range of rows to be sorted is specified by setting the Row and RowSel properties. If Row and RowSel
are the same, the control sorts all non-fixed rows.
They keys used for sorting are determined by the Col and ColSel properties, always from the left to the
right. For example, if Col = 3 and ColSel = 1, the sort would be done according to the contents of columns
1, then 2, then 3.
The sorting algorithm used by the FlexGrid control is "stable": this means that the sorting keeps the
relative order of records when the sorting key is the same. For example, if you sort a list of files by name,
then by extension, file names will still be sorted within each extension group.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (C1FlexGridClassic)
Gets the collection of cell styles in the grid.
Syntax
[VB]
Public Styles As CellStyleCollection
[C#]
public CellStyleCollection Styles {get;}
[Delphi]
property Styles: CellStyleCollection;
Remarks
The Styles property enables you to obtain a reference to the list of styles that are currently defined in the
grid. With this reference, you can add, remove, and count the styles. For more information on the tasks
that can be performed with this collection, see the CellStyleCollection class reference topics. For
information on cell formatting, see the CellStyle reference topics.
This property is read-only. The grid creates and manages the collection for you.
Upgrade Note: The VSFlexGrid ActiveX control had many properties that affected the way the grid was
displayed (e.g., BackColor, BackColorAlternate, BackColorBkg, BackColorFixed, BackColorFrozen,
BackColorSel, and so on). The C1FlexGrid control replaces all these properties with a
CellStyleCollection of CellStyle objects. This makes the object model simpler, more consistent, and more
powerful. You can change the stock styles or define your own, and assign them to rows, columns, or
arbitrary cell ranges.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
TabBehavior Property
Returns or sets whether the tab key will move focus between controls (VB default) or between grid cells.
TabBehavior Property · 497
Syntax
[VB]
Public TabBehavior As TabBehaviorSettings
[C#]
public TabBehaviorSettings TabBehavior {get; set;}
[Delphi]
property TabBehavior: TabBehaviorSettings;
Remarks
The settings for the TabBehavior property are described below:
Member Name
Description
flexTabControls
Tab key is used to move to the next or previous control on the form.
flexTabCells
Tab key is used to move to the next or previous cell on the control.
The example below sets the tab key to move to the next control when in the last cell of the grid:
•
Visual Basic
Private Sub fg_Focus(ByVal sender As Object, ByVal e As System.Event
Args)
fg.Select (fg.FixedRows, fg.FixedCols)
End Sub
Private Sub fg_EnterCell(ByVal sender As Object, ByVal e As
System.EventArgs)
If fg.Col = fg.Cols - 1 And fg.Row = fg.Rows - 1 Then
fg.TabBehavior = TabBehaviorSettings.flexTabControls
Else
fg.TabBehavior = TabBehaviorSettings.flexTabCells
End If
End Sub
•
C#
private void fg_Focus( object sender, System.event e Args) {
fg.Select (fg.FixedRows, fg.FixedCols);
}
private void fg_EnterCell( object sender, System.EventArgs e) {
if ( fg.Col = fg.Cols - 1 && fg.Row = fg.Rows - 1 ) {
fg.TabBehavior = TabBehaviorSettings.flexTabControls;
} else {
fg.TabBehavior = TabBehaviorSettings.flexTabCells;
}
}
•
Delphi
procedure fg_Focus(sender: System.Object; e: System.Event Args);
begin
fg.Select(fg.FixedRows, fg.FixedCols);
end;
procedure fg_EnterCell(sender: System.Object; e: System.EventArgs);
begin
498 · C1FlexGridClassic Reference
If (fg.Col = fg.Cols.Count – 1) And (fg.Row = fg.Rows.Count – 1) Then
fg.TabBehavior := TabBehaviorSettings.flexTabControls
Else
fg.TabBehavior := TabBehaviorSettings.flexTabCells;
end;
See Also
C1FlexGridClassic Class (page 429)
KeyActionEnter Property (page 139)
KeyActionTab Property (page 140)
Text Property
Returns or sets the contents of the selected cell or range.
Syntax
[VB]
Public Text As String
[C#]
public string Text {get; set;}
[Delphi]
property Text: string;
Remarks
The Text property retrieves the contents of the current cell, defined by the Row and Col properties. When
a string is assigned to the Text property, is applied either to the current cell or copied over the current
selection, depending on the settings of the FillStyle property.
The code below sets the contents of the fourth column of the fourth row to "Apple":
•
Visual Basic
fg.Select 3, 3
fg.Text = "Apple"
•
C#
fg.Select 3, 3;
fg.Text = "Apple";
•
Delphi
fg.Select(3, 3);
fg.Text := 'Apple';
See Also
C1FlexGridClassic Class (page 429)
GetData Method (page 178)
SetData Method (page 195)
TextStyle Property · 499
TextStyle Property
Returns or sets 3D effects for displaying text in non-fixed cells.
Syntax
[VB]
Public TextStyle As TextStyleSettings
[C#]
public TextStyleSettings TextStyle {get; set;}
[Delphi]
property TextStyle: TextStyleSettings;
Remarks
Valid settings for the TextStyle property are:
Member Name
Description
flexTextFlat
Draw text normally.
flexTextRaised
Draw text with a strong raised 3-D effect.
flexTextInset
Draw text with a strong inset 3-D effect.
flexTextRaisedLight
Draw text with a light raised 3-D effect.
flexTextInsetLight
Draw text with a light inset 3-D effect.
Constants flexTextRaised and flexTextInset work best for large and bold fonts. Constants
flexTextRaisedLight and flexTextInsetLight work best for small regular fonts.
The example below prints text with an inset 3-D effect in non-fixed cells:
•
Visual Basic
fg.TextStyle = TextStyleSettings.flexTextInset
•
C#
fg.TextStyle = TextStyleSettings.flexTextInset;
•
Delphi
fg.TextStyle := TextStyleSettings.flexTextInset;
See the CellTextStyle property for an enumeration listing.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
500 · C1FlexGridClassic Reference
TextStyleFixed Property
Returns or sets 3D effects for displaying text in fixed cells.
Syntax
[VB]
Public TextStyleFixed As TextStyleSettings
[C#]
public TextStyleSettings TextStyleFixed {get; set;}
[Delphi]
property TextStyleFixed: TextStyleSettings;
Remarks
Valid settings for the TextStyleFixed property are:
Member Name
Description
flexTextFlat
Draw text normally.
flexTextRaised
Draw text with a strong raised 3-D effect.
flexTextInset
Draw text with a strong inset 3-D effect.
flexTextRaisedLight
Draw text with a light raised 3-D effect.
flexTextInsetLight
Draw text with a light inset 3-D effect.
The example below prints text with a raised 3-D effect in fixed cells:
•
Visual Basic
fg.TextStyleFixed = TextStyleSettings.flexTextRaised
•
C#
fg.TextStyleFixed = TextStyleSettings.flexTextRaised;
•
Delphi
fg.TextStyleFixed := TextStyleSettings.flexTextRaised;
See the CellTextStyle property for an enumeration listing.
See Also
C1FlexGridClassic Class (page 429)
Styles Property (page 159)
TreeColor Property
Returns or sets the color used to draw the outline tree.
Value Property · 501
Syntax
[VB]
Public Property TreeColor As System.Drawing.Color
[C#]
public System.Drawing.Color TreeColor {get; set;}
[Delphi]
property TreeColor: System.Drawing.Color;
Remarks
The outline tree is drawn only when the OutlineBar property is set to a non-zero value and the control
contains subtotal rows. It allows users to collapse and expand the outline.
For details on outlines and an example, see the Outline method.
See Also
C1FlexGridClassic Class (page 429)
Value Property
Returns the numeric value of the current cell.
Syntax
[VB]
Public Value As Integer
[C#]
public int Value {get; set;}
[Delphi]
property Value: Integer;
Remarks
This property is similar to Visual Basic's Val function, except it interprets localized thousand separators,
currency signs, and parenthesized negative values. For example, if the current cell contains the string
"$(1,234.56)", the Value property will return the value -1234.56.
The following code outputs the value of the current cell to the debug window:
•
Visual Basic
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Debug. WriteLine (fg.Value)
End Sub
•
C#
private void Button1_Click( System.object sender,
Button1.Click {
Debug. WriteLine (fg.value);
}
System.EventArgs e)
502 · C1FlexGridClassic Reference
•
Delphi
procedure Button1_Click(sender: System.Object;
e: System.EventArgs);
begin
Debug. WriteLine(fg.Value);
end;
This property is not an expression evaluator. If the current cell contains the string "2+2", for example, the
Value property will return 2 instead of 4. The Visual Basic statement Val("2+2") also returns 2.
See Also
C1FlexGridClassic Class (page 429)
GetData Method (page 178)
SetData Method (page 195)
WallPaper Property
Returns or sets a picture to be used as a background for the control's scrollable area.
Syntax
[VB]
Public Property WallPaper As System.Drawing.Image
[C#]
public System.Drawing.Image WallPaper {get; set;}
[Delphi]
property WallPaper: System.Drawing.Image;
Remarks
This property is equivalent to the BackgroundImage property inherited from the base Control class.
See Also
C1FlexGridClassic Class (page 429)
WordWrap Property (C1FlexGridClassic)
Specifies whether long strings are allowed to wrap within the cell.
Syntax
[VB]
Public Property WordWrap As Boolean
[C#]
public bool WordWrap {get; set;}
[Delphi]
property WordWrap: Boolean;
AutoSize Method · 503
See Also
C1FlexGridClassic Class (page 429)
C1FlexGridClassic Methods
AutoSize Method
Resizes column widths or row heights to fit cell contents.
Syntax
[VB]
Public Sub AutoSize(col As Integer)
Public Sub AutoSize(col1 As Integer, col2 As Integer)
Public Sub AutoSize(col1 As Integer, col2 As Integer, equal As Boolean, extra As Integer)
[C#]
public void AutoSize ( int col )
public void AutoSize ( int col1 , int col2 )
public void AutoSize ( int col1 , int col2 , Boolean equal , int extra )
[Delphi]
procedure AutoSize(col: Integer);
procedure AutoSize(col1: Integer; col2: Integer);
procedure AutoSize(col1: Integer; col2: Integer; equal: Boolean; extra: Integer);
Parameter
Description
Col1, Col2
Specify the first and last columns to be resized so their widths fit the widest entry in
each column. The valid range for these parameters is between 0 and Cols -1. Col2 is
optional. If it is omitted, only Col1 is resized.
equal
If True, all columns between Col1 and Col2 are set to the same width. If False, then
each column is resized independently. This parameter is optional and defaults to False.
ExtraSpace
Allows you to specify extra spacing, in twips, to be added in addition to the minimum
required to fit the widest entry. This is often useful if you wish to leave extra room for
pictures or margins within cells. This parameter is optional and defaults to zero.
Remarks
The AutoSize method may also be used to resize row heights. This is useful when text is allowed to wrap
within cells (see the WordWrap property) or when cells have fonts of different sizes (see the Cell
property).
The AutoSizeMode property determines whether AutoSize will adjust column widths or row heights.
504 · C1FlexGridClassic Reference
See Also
C1FlexGridClassic Class (page 429)
AutoSizeCol Method (page 165)
AutoSizeRow Method (page 167)
Clear Method
Clears the contents of the control. Optional parameters specify what to clear and where.
Syntax
[VB]
Public Sub Clear()
Public Sub Clear(where As ClearWhereSettings)
Public Sub Clear(where As ClearWhereSettings, what As ClearWhatSettings)
[C#]
public void Clear ( )
public void Clear (ClearWhereSettings where )
public void Clear (ClearWhereSettings where , ClearWhatSettings what )
[Delphi]
procedure Clear;
procedure Clear(where: ClearWhereSettings);
procedure Clear(where: ClearWhereSettings; what: ClearWhatSettings);
Parameter
Description
where
ClearWhatSettings constant which describes where the clear will apply (see
below).
what
ClearWhereSettings constant which describes what the method will clear (see
below).
Remarks
The settings for the ClearWhatSettings constants are described below:
Member Name
Description
flexClearEverything
Everything will be cleared from area.
flexCleartext
Only text will be cleared from area.
flexClearFormatting
Only formatting will be cleared from area.
flexClearData
Only data in data area will be cleared from area.
Clear Method · 505
The settings for the ClearWhereSettings constants are described below:
Member Name
Description
flexClearEverywhere
Clear from entire grid.
flexClearScrollable
Clear from only scrollable portion of grid.
flexClearSelection
Clear from selected area.
The Clear method does not affect the number of rows and columns on the grid, and cannot be used to
clear data when the grid is bound data source.
You may clear the text or custom formatting in an arbitrary range using the Cell property. For example,
the following code clears all text and custom formatting in a range:
•
Visual Basic
Dim r1&, c1&, r2&, c2&
fg.set_Cell(CellPropertySettings.flexcpText, r1, C1, r2, c2, "")
fg.set_Cell(CellPropertySettings.flexcpCustomFormat, r1, C1, r2, c2,
False)
•
C#
r1&, c1&, r2&, c2&;
fg.set_Cell(CellPropertySettings.flexcpText, r1, C1, r2, c2, "");
fg.set_Cell(CellPropertySettings.flexcpCustomFormat, r1, C1, r2, c2,
false);
•
Delphi
var
r1, c1, r2, c2: Integer;
begin
fg.set_Cell(CellPropertySettings.flexcpText, r1, C1, r2, c2, '');
fg.set_Cell(CellPropertySettings.flexcpCustomFormat, r1, C1, r2, c2,
False);
end;
This example clears the text of the selected cell(s) while leaving the picture and cell data intact:
•
Visual Basic
fg.Clear(ClearWhereSettings.flexClearSelection,
ClearWhatSettings.flexClearText)
•
C#
fg.Clear(ClearWhereSettings.flexClearSelection,
ClearWhatSettings.flexClearText);
•
Delphi
fg.Clear(ClearWhereSettings.flexClearSelection,
ClearWhatSettings.flexClearText);
See Also
C1FlexGridClassic Class (page 429)
Clear Method (C1FlexGrid) (page 168)
506 · C1FlexGridClassic Reference
ComboItem Method
Returns the string associated with an item in the editor's combo list.
Syntax
[VB]
Public Function ComboItem(ByVal index As Integer) As String
[C#]
public String ComboItem (Integer Index)
[Delphi]
function ComboItem(index: Integer): String;
See Also
C1FlexGridClassic Class (page 429)
EditCell Method
Activates edit mode.
Syntax
[VB]
Public Sub EditCell()
[C#]
public void EditCell ( )
[Delphi]
procedure EditCell;
Remarks
If the Editable property is set to a non-zero value, the control goes into editing mode automatically when
the user presses the edit key (F2), the space bar, or any printable character. You may use the EditCell
method to force the control into cell-editing mode.
Note that EditCell will force the control into editing mode even if the Editable property is set to False.
You may even use it to allow editing of fixed cells.
See Also
C1FlexGridClassic Class (page 429)
FindRow Method (C1FlexGridClassic)
Finds a row that contains a given string or object.
get_Cell Method · 507
Syntax
[VB]
Public Function FindRow(objFind As Object, rowStart As Integer, col As Integer, wrap As Boolean) As
Integer
Public Function FindRow(strFind As String, rowStart As Integer, col As Integer, caseSensitive As
Boolean, fullMatch As Boolean, wrap As Boolean) As Integer
[C#]
public Integer FindRow (Object objFind , int rowStart , int col , Boolean wrap )
public Integer FindRow (String strFind , int rowStart , int col , Boolean caseSensitive , Boolean fullMatch ,
Boolean wrap )
[Delphi]
function FindRow(objFind: Object; rowStart: Integer; col: Integer; wrap: Boolean): Integer;
function FindRow(strFind: string; rowStart: Integer; col: Integer; caseSensitive: Boolean; fullMatch:
Boolean; wrap: Boolean): Integer;
Parameter
Description
strFind
String to look for.
objFind
Object to look for.
rowStart
Index of the row where the search should start.
col
Column that contains the data to be searched.
caseSensitive
Whether the search should be case-sensitive.
fullMatch
Whether a full match is required. If this parameter is set to False, searching for
"John" may return a row that contains "Johnson".
wrap
Whether the search should stop at the bottom of the grid or wrap around and
restart from the first scrollable row.
Return Value
The index of the row that contains the data, or –1 if the data is not found.
Remarks
To allow users to search for data as they type, use the AutoSearch property.
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
get_Cell Method
Returns cell properties for an arbitrary range.
508 · C1FlexGridClassic Reference
Syntax
[VB]
Public Function get_Cell(ByVal setting As C1.Win.C1FlexGrid.Classic.CellPropertySettings, ByVal row
As Integer, ByVal col As Integer) As Object
Public Function get_Cell(ByVal setting As C1.Win.C1FlexGrid.Classic.CellPropertySettings, ByVal row1
As Integer, ByVal col1 As Integer, ByVal row2 As Integer, ByVal col2 As Integer) As Object
[C#]
public System.Object get_Cell ( C1.Win.C1FlexGrid.Classic.CellPropertySettings setting , System.Int32
row , System.Int32 col )
public System.Object get_Cell ( C1.Win.C1FlexGrid.Classic.CellPropertySettings setting , System.Int32
row1 , System.Int32 col1 , System.Int32 row2 , System.Int32 col2 )
[Delphi]
function get_Cell(setting: C1.Win.C1FlexGrid.Classic.CellPropertySettings; row: Integer; col: Integer):
Object;
function get_Cell(setting: C1.Win.C1FlexGrid.Classic.CellPropertySettings; row1: Integer; col1: Integer;
row2: Integer; col2: Integer): Object;
Remarks
The get_Cell method allows you to read or set cell properties directly to individual cells or ranges
(without selecting them).
The parameters for the get_Cell method are described below:
Setting As CellPropertySettings
This parameter determines which property will be read or set. The settings available are listed below.
Row1, Col1, Row2, and Col2 As Integer (optional)
When reading cell properties, only cell (Row1, Col1) is used. When setting, the whole range is affected.
The default value for Row1 and Col1 is the current row and the current column. Thus, if they are not
supplied, the current cell is used. The default value for Row2 and Col2 is Row1 and Col1. Thus, if they are
not supplied, a single cell is used.
Valid settings for the setting parameter are:
Member Name
Description
flexChecked
The cell has a check box that is checked.
flexNoCheckbox
The cell has no check box. This is the default setting.
flexTSChecked
The cell has a Tri-state check box with a check mark in it.
flexTSGrayed
The cell has a Tri-state check box in grayed state.
flexTSUnchecked
The cell has a Tri-state empty check box.
flexUnchecked
The cell has a check box that is not checked.
get_ColAlignment Method · 509
See Also
C1FlexGridClassic Class (page 429)
get_ColAlignment Method
Returns the alignment of the given column.
Syntax
[VB]
Public Function get_ColAlignment(ByVal col As Integer) As
C1.Win.C1FlexGrid.Classic.AlignmentSettings
[C#]
public C1.Win.C1FlexGrid.Classic.AlignmentSettings get_ColAlignment ( System.Int32 col )
[Delphi]
function get_ColAlignment(col: Integer): C1.Win.C1FlexGrid.Classic.AlignmentSettings;
See Also
C1FlexGridClassic Class (page 429)
get_ColComboList Method
Returns the list to be used as a drop-down on the specified column.
Syntax
[VB]
Public Function get_ColComboList(ByVal col As Integer) As String
[C#]
public System.String get_ColComboList ( System.Int32 col )
[Delphi]
function get_ColComboList(col: Integer): String;
See Also
C1FlexGridClassic Class (page 429)
get_ColData Method
Returns a user-defined variant associated with the given column.
Syntax
[VB]
Public Function get_ColData(ByVal col As Integer) As Object
[C#]
public System.Object get_ColData ( System.Int32 col )
510 · C1FlexGridClassic Reference
[Delphi]
function get_ColData(col: Integer): Object;
See Also
C1FlexGridClassic Class (page 429)
get_ColDataType Method
Sets the data type for the column.
Syntax
[VB]
Public Function get_ColDataType(ByVal col As Integer) As System.Type
[C#]
public System.Type get_ColDataType ( System.Int32 col )
[Delphi]
function get_ColDataType(col: Integer): System.Type
See Also
C1FlexGridClassic Class (page 429)
get_ColEditMask Method
Returns the input mask used to edit cells on the specified column.
Syntax
[VB]
Public Function get_ColEditMask(ByVal col As Integer) As String
[C#]
public System.String get_ColEditMask ( System.Int32 col )
[Delphi]
function get_ColEditMask(col: Integer): String;
See Also
C1FlexGridClassic Class (page 429)
get_ColFormat Method
Returns the format used to display numeric values.
Syntax
[VB]
Public Function get_ColFormat(ByVal col As Integer) As String
get_ColHidden Method · 511
[C#]
public System.String get_ColFormat ( System.Int32 col )
[Delphi]
function get_ColFormat(col: Integer): String;
See Also
C1FlexGridClassic Class (page 429)
get_ColHidden Method
Returns whether a column is hidden.
Syntax
[VB]
Public Function get_ColHidden(ByVal col As Integer) As Boolean
[C#]
public System.Boolean get_ColHidden ( System.Int32 col )
[Delphi]
function get_ColHidden(col: Integer): Boolean;
See Also
C1FlexGridClassic Class (page 429)
get_ColIndent Method
Returns the indentation of the given column, in twips.
Syntax
[VB]
Public Function get_ColIndent(ByVal col As Integer) As Integer
[C#]
public System.Int32 get_ColIndent ( System.Int32 col )
[Delphi]
function get_ColIndent(col: Integer): Integer;
See Also
C1FlexGridClassic Class (page 429)
get_ColIndex Method
Returns the column index that matches the given key.
512 · C1FlexGridClassic Reference
Syntax
[VB]
Public Function get_ColIndex(ByVal colKey As String) As Integer
[C#]
public System.Int32 get_ColIndex ( System.String colKey )
[Delphi]
Function get_ColIndex(colKey: String): Integer;
See Also
C1FlexGridClassic Class (page 429)
get_ColIsVisible Method
Returns whether a given column is currently within view.
Syntax
[VB]
Public Function get_ColIsVisible(ByVal col As Integer) As Boolean
[C#]
public System.Boolean get_ColIsVisible ( System.Int32 col )
[Delphi]
function get_ColIsVisible(col: Integer): Boolean;
See Also
C1FlexGridClassic Class (page 429)
get_ColKey Method
Returns a key used to identify the given column.
Syntax
[VB]
Public Function get_ColKey(ByVal col As Integer) As String
[C#]
public System.String get_ColKey ( System.Int32 col )
[Delphi]
function get_ColKey(col: Integer): String;
See Also
C1FlexGridClassic Class (page 429)
get_ColPos Method · 513
get_ColPos Method
Returns the left (x) coordinate of a column relative to the edge of the control, in twips.
Syntax
[VB]
Public Function get_ColPos(ByVal col As Integer) As Integer
[C#]
public System.Int32 get_ColPos ( System.Int32 col )
[Delphi]
function get_ColPos(col: Integer): Integer;
See Also
C1FlexGridClassic Class (page 429)
get_ColSort Method
Returns the sorting order for each column (for use with the Sort property).
Syntax
[VB]
Public Function get_ColSort(ByVal col As Integer) As C1.Win.C1FlexGrid.Classic.SortSettings
[C#]
public C1.Win.C1FlexGrid.Classic.SortSettings get_ColSort ( System.Int32 col )
[Delphi]
function get_ColSort(col: Integer): C1.Win.C1FlexGrid.Classic.SortSettings;
See Also
C1FlexGridClassic Class (page 429)
get_ColWidth Method
Returns the width of the specified column, in twips.
Syntax
[VB]
Public Function get_ColWidth(ByVal col As Integer) As Integer
[C#]
public System.Int32 get_ColWidth ( System.Int32 col )
[Delphi]
function get_ColWidth(col: Integer): Integer;
514 · C1FlexGridClassic Reference
See Also
C1FlexGridClassic Class (page 429)
get_FixedAlignment Method
Returns the alignment for the fixed rows in a column.
Syntax
[VB]
Public Function get_FixedAlignment(ByVal col As Integer) As
C1.Win.C1FlexGrid.Classic.AlignmentSettings
[C#]
public C1.Win.C1FlexGrid.Classic.AlignmentSettings get_FixedAlignment ( System.Int32 col )
[Delphi]
function get_FixedAlignment(col: Integer): C1.Win.C1FlexGrid.Classic.AlignmentSettings;
See Also
C1FlexGridClassic Class (page 429)
get_IsCollapsed Method
Returns whether a row is collapsed.
Syntax
[VB]
Public Function get_IsCollapsed(ByVal row As Integer) As Boolean
[C#]
public bool get_IsCollapsed ( System.Int32 row )
[Delphi]
function get_IsCollapsed(row: Integer): Boolean;
See Also
C1FlexGridClassic Class (page 429)
get_IsSelected Method
Returns whether a row is selected (for listbox-type selections).
Syntax
[VB]
Public Function get_IsSelected(ByVal row As Integer) As Boolean
get_IsSubtotal Method · 515
[C#]
public bool get_IsSelected ( System.Int32 row )
[Delphi]
function get_IsSelected(row: Integer): Boolean;
See Also
C1FlexGridClassic Class (page 429)
get_IsSubtotal Method
Returns whether a row contains subtotals (as opposed to data).
Syntax
[VB]
Public Function get_IsSubtotal(ByVal row As Integer) As Boolean
[C#]
public System.Boolean get_IsSubtotal ( System.Int32 row )
[Delphi]
function get_IsSubtotal(row: Integer): Boolean;
Remarks
This property allows you to determine whether a given row is a regular row or a subtotal row, or to
create subtotal rows manually (as opposed to using the Subtotal method).
There are two differences between subtotal rows and regular rows:
1.
Subtotal rows may be added and removed automatically with the Subtotal method.
2.
When using the control as an outliner, subtotal rows behave as outline nodes, while regular rows
behave as branches.
You may use this property to build custom outlines. This requires three steps:
1.
Set the IsSubtotal property to True for all outline nodes.
2.
Set the set_RowOutlineLevel method for each outline node.
3.
Set the OutlineBar and OutlineCol properties if you want to display an outline tree, which the
user can use to collapse and expand the outline.
For more details, see the Outline Demo.
See Also
C1FlexGridClassic Class (page 429)
get_MergeCol Method
Returns whether a column will have its cells merged.
516 · C1FlexGridClassic Reference
Syntax
[VB]
Public Function get_MergeCol(ByVal col As Integer) As Boolean
[C#]
public System.Boolean get_MergeCol ( System.Int32 col )
[Delphi]
function get_MergeCol(col: Integer): Boolean;
See Also
C1FlexGridClassic Class (page 429)
MergeCells Property (page 484)
GetMergedRange Method
Returns the range of merged cells that includes a given cell.
Syntax
[VB]
Public Sub GetMergedRange(row As Integer, col As Integer, r1 As Integer, c1 As Integer, r2 As Integer,
c2 As Integer)
[C#]
public void GetMergedRange ( int row , int col , int r1 , int c1 , int r2 , int c2 )
[Delphi]
procedure GetMergedRange(row: Integer; col: Integer; r1: Integer; r2: integer; c2: Integer);
Parameter
Description
row, col
coordinates of cell that is included within merged range.
r1, r2, c1, c2
4 coordinates which designate the current merged range. r1 and r2 correspond to
the row upper and lower bound, while c1 and c2 correspond to the column upper
and lower bound.
Remarks
The C1FlexGridClassic control can merge cells based on their contents. This method allows you to
determine whether a cell is merged with its neighboring cells.
For example, the following code changes the contents of a merged cell preserving the merged range:
•
Visual Basic
' create a merged range
get_MergeRow Method · 517
fg.MergeCells = MergeSettings.flexMergeFree
fg.set_MergeRow(1, True)
fg.set_Cell(CellPropertySettings.flexcpText,
1, 1, 1, 4, "Merged Range")
' this changes only cell 1, 1
fg.set_Cell(CellPropertySettings.flexcpText,_
1, 1, "Merged Range Has Changed")
' this changes the whole merged range
Dim r1&, c1&, r2&, c2&
fg.GetMergedRange (1, 2, r1, r2, c1, c2)
fg.set_Cell(CellPropertySettings.flexcpText, _
1, 1, 1, 4, "Merged Range Has Changed")
•
C#
// create a merged range
fg.MergeCells = MergeSettings.flexMergeFree;
fg.set_MergeRow(1, true);
fg.set_Cell(CellPropertySettings.flexcpText,
1, 1, 1, 4, "Merged Range");
// this changes only cell 1, 1
fg.set_Cell(CellPropertySettings.flexcpText,
1, 1, "Merged Range Has Changed");
// this changes the whole merged range
r1&, c1&, r2&, c2&;
fg.GetMergedRange (1, 2, r1, r2, c1, c2);
fg.set_Cell(CellPropertySettings.flexcpText,
1, 1, 1, 4, "Merged Range Has Changed");
•
Delphi
var
r1, r2, c1, c2: Integer;
begin
// create a merged range
fg.MergeCells := MergeSettings.flexMergeFree;
fg.set_MergeRow(1, True);
fg.set_Cell(CellPropertySettings.flexcpText, 1, 1, 1, 4, 'Merged
Range');
// this changes only cell 1, 1
fg.set_Cell(CellPropertySettings.flexcpText, 1, 1, 'Merged Range Has
Changed');
// this changes the whole merged range
fg.GetMergedRange(1, 2, r1, r2, c1, c2);
fg.set_Cell(CellPropertySettings.flexcpText, 1, 1, 1, 4, 'Merged
Range Has Changed');
end;
For more details on cell merging, see the MergeCells property.
See Also
C1FlexGridClassic Class (page 429)
GetMergedRange Method (C1FlexGrid) (page 180)
get_MergeRow Method
Returns whether a row will have its cells merged.
518 · C1FlexGridClassic Reference
Syntax
[VB]
Public Function get_MergeRow(ByVal row As Integer) As Boolean
[C#]
public System.Boolean get_MergeRow ( System.Int32 row )
[Delphi]
function get_MergeRow(row: Integer): Boolean;
Remarks
The get_MergeRow method is used in conjunction with the MergeCells property and get_MergeCol
method to control whether and how cells are merged for display.
The MergeCells property is used to enable cell merging for the entire control. After setting it to an
appropriate value, the get_MergeRow and get_MergeCol methods are used to determine which rows
and columns should have their cells merged. By default, get_MergeRow and get_MergeCol are set to
False, so no merging takes place. If you set them to True for a specific row or column, then adjacent cells
in that row or column will be merged if their contents are equal.
The Row parameter should be set to a value between zero and Rows - 1 to set MergeRow for a single row,
or -1 to set all rows.
You don't need to set get_MergeRow to True when MergeCells is set to flexMergeSpill (6).
For more details and examples, see the MergeCells property.
See Also
C1FlexGridClassic Class (page 429)
AllowMerging Property (Row) (page 308)
MergeCells Property (page 484)
GetNode Method (C1FlexGridClassic)
Returns an outline node object for a given subtotal row.
Syntax
[VB]
Public Function GetNode() As C1.Win.C1FlexGrid.Node
Public Function GetNode(ByVal row As Integer) As C1.Win.C1FlexGrid.Node
[C#]
public C1.Win.C1FlexGrid.Node GetNode ( )
public C1.Win.C1FlexGrid.Node GetNode ( System.Int32 row )
[Delphi]
function GetNode: C1.Win.C1FlexGrid.Node;
function GetNode(row: Integer): C1.Win.C1FlexGrid.Node;
GetNodeRow Method · 519
See Also
C1FlexGridClassic Class (page 429)
GetNodeRow Method
Returns the number of a row's parent, first, or last child in an outline.
Syntax
[VB]
Public Function GetNodeRow(ByVal row As Integer, ByVal which As
C1.Win.C1FlexGrid.NodeTypeEnum) As Integer
[C#]
public System.Int32 GetNodeRow ( System.Int32 row , C1.Win.C1FlexGrid.NodeTypeEnum which )
[Delphi]
function GetNodeRow (row: Integer; which: C1.Win.C1FlexGrid.NodeTypeEnum): Integer;
Remarks
When the grid is used in outline mode, this method allows you to determine a node's parent, first, or last
child nodes.
The parameters for the GetNodeRow property are described below:
Row As Integer
The row number of the node whose parent or child nodes you want to determine.
Which As NodeTypeSettings
Which node to return. Valid settings for this parameter are:
Member Name
Description
Root
The node's top-level parent.
Parent
The node's immediate parent.
FirstChild
The node's first child.
LastChild
The node's last child.
FirstSibling
The node's first sibling (node with same level and same parent).
LastSibling
The node's last sibling.
NextSibling
The node's next sibling.
PreviousSibling
The node's previous sibling.
If the node requested cannot be found, GetNodeRow returns -1. For example, the root node has no
parent, and empty nodes have no children.
See Also
C1FlexGridClassic Class (page 429)
520 · C1FlexGridClassic Reference
get_RowData Method
Returns a user-defined variant associated with the given row.
Syntax
[VB]
Public Function get_RowData(ByVal row As Integer) As Object
[C#]
public System.Object get_RowData ( System.Int32 row )
[Delphi]
function get_RowData(row: Integer): Object;
See Also
C1FlexGridClassic Class (page 429)
get_RowHeight Method
Returns the height of the specified row, in twips.
Syntax
[VB]
Public Function get_RowHeight(ByVal row As Integer) As Integer
[C#]
public System.Int32 get_RowHeight ( System.Int32 row )
[Delphi]
function get_RowHeight(row: Integer): As Integer;
See Also
C1FlexGridClassic Class (page 429)
get_RowHidden Method
Returns whether a row is hidden.
Syntax
[VB]
Public Function get_RowHidden(ByVal row As Integer) As Boolean
[C#]
public bool get_RowHidden ( System.Int32 row )
[Delphi]
function get_RowHidden(row: Integer): Boolean;
get_RowIsVisible Method · 521
See Also
C1FlexGridClassic Class (page 429)
get_RowIsVisible Method
Returns whether a given row is currently within view.
Syntax
[VB]
Public Function get_RowIsVisible(ByVal row As Integer) As Boolean
[C#]
public System.Boolean get_RowIsVisible ( System.Int32 row )
[Delphi]
function get_RowIsVisible(row: Integer): Boolean;
See Also
C1FlexGridClassic Class (page 429)
get_RowOutlineLevel Method
Returns the outline level for a subtotal row.
Syntax
[VB]
Public Function get_RowOutlineLevel(ByVal row As Integer) As Integer
[C#]
public System.Int32 get_RowOutlineLevel ( System.Int32 row )
[Delphi]
function get_RowOutlineLevel(row: Integer): Integer;
Remarks
The get_RowOutlineLevel property is used for two closely related purposes.
1.
When using the grid in outline mode, get_RowOutlineLevel is used to set the hierarchical level
of a node. Nodes with high outline level are children of rows with low outline level. The root
node has the lowest outline level. You may change the relationship between nodes by modifying
the value of the get_RowOutlineLevel method. For more details on creating and using outlines,
see the Outline Demo.
2.
When using the Subtotal method to create subtotals automatically, get_RowOutlineLevel stores
the number of the column being used for grouping the data. For more details on creating and
using automatic subtotals, see the Subtotal method.
The get_RowOutlineLevel is only used by the control if the get_IsSubtotal property is set to True.
522 · C1FlexGridClassic Reference
See Also
C1FlexGridClassic Class (page 429)
get_RowPos Method
Returns the top (y) coordinate of a row relative to the edge of the control, in twips.
Syntax
[VB]
Public Function get_RowPos(ByVal row As Integer) As Integer
[C#]
public System.Int32 get_RowPos ( System.Int32 row )
[Delphi]
function get_RowPos(row: Integer): Integer;
See Also
C1FlexGridClassic Class (page 429)
GetSelection Method
Returns the current selection ordered so that Row1 <= Row2 and Col1 <= Col2.
Syntax
[VB]
Public Sub GetSelection(row1 As Integer, col1 As Integer, row2 As Integer, col2 As Integer)
[C#]
public void GetSelection ( int row1 , int col1 , int row2 , int col2 )
[Delphi]
procedure GetSelection(row1: Integer; col1: Integer; row2: Integer; col2: Integer);
Parameter
Description
row1, row2
Coordinates of the selections upper and lower row bounds.
col1, col2
Coordinates of the selections upper and lower column bounds.
Remarks
When programming the C1FlexGridClassic control, a common task is looping through the currently
selected range to perform some action on the selected cells, defined by the values of the Row, RowSel,
Col, and ColSel properties. When setting up such loops, you should take into account the fact that Row
may be greater than or smaller than RowSel, and Col may be greater than or smaller than ColSel. Instead
of comparing these values to set up the loop bounds, use the GetSelection to obtain the loop bounds in
the proper order.
get_TextMatrix Method · 523
For example, the code below prints the contents of the selected range:
•
Visual Basic
Dim r&, c&, r1&, c1, r2&, c2&
fg.GetSelection (r1, c1, r2, c2)
For r = r1 To r2
For c = c1 To c2
Debug.WriteLine (fg.get_TextMatrix (r,c))
Next
Next
•
C#
r&, c&, r1&, c1, r2&, c2&;
fg.GetSelection (r1, c1, r2, c2);
for ( r = r1; r <= r2
for ( c = c1; c <= c2
Console.WriteLine (fg.get_TextMatrix (r,c));
} //
}
•
Delphi
var
r, c, r1, r2, c1, c2: Integer;
begin
fg.GetSelection(r1, c1, r2, c2);
for r := r1 to r2 do
for c := c1 to c2 do
Console.WriteLine(fg.get_TextMatrix(r, c));
end;
See Also
C1FlexGridClassic Class (page 429)
Selection Property (page 155)
get_TextMatrix Method
Returns the contents of a cell identified by its row and column coordinates.
Syntax
[VB]
Public Function get_TextMatrix(ByVal r As Integer, ByVal c As Integer) As String
[C#]
public System.String get_TextMatrix ( System.Int32 r , System.Int32 c )
[Delphi]
function get_TextMatrix(r: Integer; c: Integer): String;
See Also
C1FlexGridClassic Class (page 429)
get_ValueMatrix Method
Returns the numeric value of a cell identified by its row and column coordinates.
524 · C1FlexGridClassic Reference
Syntax
[VB]
Public Function get_ValueMatrix(r As Integer, c As Integer) As Double
[C#]
public Double get_ValueMatrix ( int r , int c )
[Delphi]
function get_ValueMatrix(r: Integer; c: Integer): Double;
Parameter
Description
Row
Row index of the cell from which the value is to be retrieved.
Col
Column index of the cell from which the value is to be retrieved.
Remarks
This property is similar to the Value property, except it allows you to specify the cell whose value is to be
retrieved.
The following code outputs the value of an arbitrary cell to the debug window:
•
Visual Basic
Debug.WriteLine(fg.get_ValueMatrix(1, 1))
•
C#
Debug.WriteLine(fg.get_ValueMatrix(1, 1));
•
Delphi
Console.WriteLine(fg.get_ValueMatrix(1, 1));
See Also
C1FlexGridClassic Class (page 429)
GetData Method (page 178)
SetData Method (page 195)
Outline Method
Sets an outline level for displaying subtotals.
Syntax
[VB]
Public Sub Outline(ByVal level As Integer)
[C#]
public void Outline ( System.Int32 level )
PrintGrid Method (C1FlexGridClassic) · 525
[Delphi]
procedure Outline(level: Integer);
Remarks
The Outline method collapses or expands an outline to the level specified, collapsing or expanding
multiple nodes simultaneously.
The method shows all nodes that have RowOutlineLevel smaller than or equal to the Level parameter
specified. Thus, small Level values collapse the outline more, and large values expand it more. If Level is
set to zero, only the root node is visible. If Level is set to a very large value (say 100 or so), the outline is
totally expanded.
Setting Level to -1 causes the outline to be totally expanded.
When the nodes are collapsed or expanded, the control fires the BeforeCollapse and AfterCollapse
events. You may trap these events to cancel the action. See the BeforeCollapse event for an example.
To set up an outline structure using automatic subtotals, see the Subtotal method. To set up a custom
outline structure, see the set_IsSubtotal method. For more details on creating and using outlines, see the
Outline Demo.
See Also
C1FlexGridClassic Class (page 429)
PrintGrid Method (C1FlexGridClassic)
Prints the grid, optionally showing a print preview dialog.
Syntax
[VB]
Public Function PrintGrid(docName As String) As Boolean
Public Function PrintGrid(docName As String, flags As PrintGridFlags) As Boolean
Public Function PrintGrid(docName As String, flags As PrintGridFlags, header As String, footer As
String) As Boolean
[C#]
public Boolean PrintGrid(string docName)
public Boolean PrintGrid(string docName , PrintGridFlags flags)
public Boolean PrintGrid(string docName , PrintGridFlags flags , string header , string footer)
[Delphi]
function PrintGrid(docName: string): Boolean;
function PrintGrid(docName: string; flags: PrintGridFlags): Boolean;
function PrintGrid(docName: string; flags: PrintGridFlags; header: string; footer: string); Boolean;
Parameter
Description
docName
The document name, which appears on the progress dialogs and on the print job
windows.
526 · C1FlexGridClassic Reference
Parameter
Description
flags
A combination of values from the PrintGridFlags enumeration, which specify what
types of print and preview dialogs to display and how to scale the grid for printing.
header, footer
Strings to be printed at the top and bottom of each page.
Return Value
A boolean value that indicates whether the grid was printed or the user canceled any of the optional
setup dialogs.
Remarks
The header and footer strings may contain up to three tab-delimited sections, to be aligned at the left,
center, and right of the page. The strings may also contain placeholders that are replaced with the current
page number and total number of pages (“{0}” and “{1}”).
You can also control other aspects of the print job (such as page orientation and margins, header and
footer fonts, etc.) using the PrintParameters property.
Example
The following call prints the grid on the default printer, scaling it to fit the page width, with a “Page n of
m” footer centered on the bottom of each page.
•
Visual Basic
flex.PrintGrid("My Grid", PrintGridFlags.FitPageWidth, _
"", vbTab + "Page {0} of {1}")
•
C#
flex.PrintGrid("My Grid", PrintGridFlags.FitPageWidth,
"", "\tPage {0} of {1}");
•
Delphi
flex.PrintGrid('My Grid', PrintGridFlags.FitPageWidth, '', #9'Page
{0} of {1}');
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
RemoveItem Method (C1FlexGridClassic)
Removes a row from the control.
Syntax
[VB]
Object.RemoveItem ()
Object.RemoveItem (int Row)
[C#]
public void RemoveItem ( )
SelectedRow Method · 527
public void RemoveItem ( int Index )
[Delphi]
procedure RemoveItem;
procedure RemoveItem(index: Integer);
Parameter
Description
Row
An optional parameter which determines which row should be removed from the
control.
Remarks
The Row parameter determines which row should be removed from the control. If provided, it must be in
the range between 0 and Rows-1, or an Invalid Index error will occur. If omitted, the last row is deleted.
See Also
C1FlexGridClassic Class (page 429)
Remove Method (RowCollection) (page 296)
SelectedRow Method
Returns the position of a selected row when SelectionMode is set to flexSelectionListBox.
Syntax
[VB]
Public Function SelectedRow(ByVal index As Integer) As Integer
[C#]
public int SelectedRow (int index)
[Delphi]
function SelectedRow(index: Integer): Integer;
Remarks
This property works in conjunction with the SelectedRows property to enumerate all selected rows in the
control. These properties are especially useful when the SelectionMode property is set to
flexSelectionListBox (3), which allows the user to select multiple, non-adjacent rows.
See Also
C1FlexGridClassic Class (page 429)
Selection Property (page 155)
set_Cell Method
Sets cell properties for an arbitrary range.
528 · C1FlexGridClassic Reference
Syntax
[VB]
Public Sub set_Cell(ByVal setting As C1.Win.C1FlexGrid.Classic.CellPropertySettings, ByVal row1 As
Integer, ByVal col1 As Integer, ByVal row2 As Integer, ByVal col2 As Integer, ByVal newVal As Object)
Public Sub set_Cell(ByVal setting As C1.Win.C1FlexGrid.Classic.CellPropertySettings, ByVal row As
Integer, ByVal col As Integer, ByVal newVal As Object)
[C#]
public void set_Cell ( C1.Win.C1FlexGrid.Classic.CellPropertySettings setting , System.Int32 row ,
System.Int32 col , System.Object newVal )
public void set_Cell ( C1.Win.C1FlexGrid.Classic.CellPropertySettings setting , System.Int32 row1 ,
System.Int32 col1 , System.Int32 row2 , System.Int32 col2 , System.Object newVal )
[Delphi]
procedure set_Cell(setting: C1.Win.C1FlexGrid.Classic.CellPropertySettings; row1: Integer; col1: Integer;
row2: Integer; col2: Integer; newVal: Object);
procedure set_Cell(setting: C1.Win.C1FlexGrid.Classic.CellPropertySettings; row: Integer; col: Integer;
newVal: Object);
Remarks
The set_Cell method allows you to read or set cell properties directly to individual cells or ranges
(without selecting them).
The parameters for the set_Cell method are described below:
Setting As CellPropertySettings
This parameter determines which property will be read or set. The settings available are listed below.
Row1, Col1, Row2, and Col2 As Integer (optional)
When reading cell properties, only cell (Row1, Col1) is used. When setting, the whole range is affected.
The default value for Row1 and Col1 is the current row and the current column. Thus, if they are not
supplied, the current cell is used. The default value for Row2 and Col2 is Row1 and Col1. Thus, if they are
not supplied, a single cell is used.
Valid settings for the setting parameter are:
Member Name
Description
flexChecked
The cell has a check box that is checked.
flexNoCheckbox
The cell has no check box. This is the default setting.
flexTSChecked
The cell has a Tri-state check box with a check mark in it.
flexTSGrayed
The cell has a Tri-state check box in grayed state.
flexTSUnchecked
The cell has a Tri-state empty check box.
flexUnchecked
The cell has a check box that is not checked.
set_ColAlignment Method · 529
See Also
C1FlexGridClassic Class (page 429)
set_ColAlignment Method
Sets the alignment of the given column.
Syntax
[VB]
Public Sub set_ColAlignment(ByVal col As Integer, ByVal newVal As
C1.Win.C1FlexGrid.Classic.AlignmentSettings)
[C#]
public void set_ColAlignment ( System.Int32 col , C1.Win.C1FlexGrid.Classic.AlignmentSettings
newVal)
[Delphi]
procedure set_ColAlignment(col: Integer; newVal: C1.Win.C1FlexGrid.Classic.AlignmentSettings);
Remarks
The flexAlignGeneral setting aligns text to the left and numbers and dates to the right.
The set_ColAlignment method affects all cells in the specified column, including those in fixed rows.
You may override this setting for fixed cells using the set_FixedAlignment method. You may override it
for individual cells using the Cell(flexcpAlignment) property.
This example sets the alignment of the third column to the right and bottom.
•
Visual Basic
fg.set_ColAlignment(2, AlignmentSettings.flexAlignRightBottom)
•
C#
fg.set_ColAlignment(2, AlignmentSettings.flexAlignRightBottom);
•
Delphi
fg.set_ColAlignment(2, AlignmentSettings.flexAlignRightBottom);
You may set the alignment of pictures in cells using the CellPictureAlignment property.
When setting this property, the Col parameter should be set to a value between zero and Cols - 1 to set
the alignment of a given column, or to -1 to set the alignment of all columns.
See Also
C1FlexGridClassic Class (page 429)
StyleFixedDisplay Property (page 340)
set_ColComboList Method
Sets the list to be used as a drop-down on the specified column.
530 · C1FlexGridClassic Reference
Syntax
[VB]
Public Sub set_ColComboList(ByVal col As Integer, ByVal newVal As String)
[C#]
public void set_ColComboList ( System.Int32 col , System.String newVal )
[Delphi]
procedure set_ColComboList(col: Integer; newVal: String);
See Also
C1FlexGridClassic Class (page 429)
set_ColData Method
Sets a user-defined variant associated with the given column.
Syntax
[VB]
Public Sub set_ColData(ByVal col As Integer, ByVal newVal As Object)
[C#]
public void set_ColData ( System.Int32 col , System.Object newVal )
[Delphi]
procedure set_ColData(col: Integer; newVal: Object);
See Also
C1FlexGridClassic Class (page 429)
set_ColDataType Method
Sets the data type for the column.
Syntax
[VB]
Public Sub set_ColDataType(ByVal col As Integer, ByVal newVal As System.Type)
[C#]
public void set_ColDataType ( System.Int32 col , System.Type newVal )
[Delphi]
procedure set_ColDataType(col: Integer; newVal: System.Type);
See Also
C1FlexGridClassic Class (page 429)
set_ColEditMask Method · 531
set_ColEditMask Method
Sets the input mask used to edit cells on the specified column.
Syntax
[VB]
Public Sub set_ColEditMask(ByVal col As Integer, ByVal newVal As String)
[C#]
public void set_ColEditMask ( System.Int32 col , System.String newVal )
[Delphi]
procedure set_ColEditMask(col: Integer; newVal: String);
See Also
C1FlexGridClassic Class (page 429)
set_ColFormat Method
Sets the format used to display numeric values.
Syntax
[VB]
Public Sub set_ColFormat(ByVal col As Integer, ByVal newVal As String)
[C#]
public void set_ColFormat ( System.Int32 col , System.String newVal )
[Delphi]
procedure set_ColFormat(col: Integer; newVal: String);
See Also
C1FlexGridClassic Class (page 429)
set_ColHidden Method
Sets whether a column is hidden.
Syntax
[VB]
Public Sub set_ColHidden(ByVal col As Integer, ByVal newVal As Boolean)
[C#]
public void set_ColHidden ( System.Int32 col , System.Boolean newVal )
[Delphi]
Sub set_ColHidden(col: Integer; newVal: Boolean);
532 · C1FlexGridClassic Reference
See Also
C1FlexGridClassic Class (page 429)
set_ColImageList Method
Sets a handle to an ImageList to be used as a source of pictures for a given column.
Syntax
[VB]
Public Sub set_ColImageList(ByVal col As Integer, ByVal newVal As System.Windows.Forms.ImageList)
[C#]
public void set_ColImageList ( System.Int32 col , System.Windows.Forms.ImageList newVal )
[Delphi]
procedure set_ColImageList(col: Integer; newVal: System.Windows.Forms.ImageList);
See Also
C1FlexGridClassic Class (page 429)
set_ColIndent Method
Sets the indentation of the given column, in twips.
Syntax
[VB]
Public Sub set_ColIndent(ByVal col As Integer, ByVal newVal As Integer)
[C#]
public void set_ColIndent ( System.Int32 col , System.Int32 newVal )
[Delphi]
procedure set_ColIndent(col: Integer; newVal: Integer);
See Also
C1FlexGridClassic Class (page 429)
set_ColKey Method
Sets a key used to identify the given column.
Syntax
[VB]
Public Sub set_ColKey(ByVal col As Integer, ByVal newVal As String)
[C#]
public void set_ColKey ( System.Int32 col , System.String newVal )
set_ColPosition Method · 533
[Delphi]
procedure set_ColKey(col: Integer; newVal: String);
See Also
C1FlexGridClassic Class (page 429)
set_ColPosition Method
Moves a given column to a new position.
Syntax
[VB]
Public Sub set_ColPosition(ByVal col As Integer, ByVal newPosition As Integer)
[C#]
public void set_ColPosition ( System.Int32 col , System.Int32 newPosition )
[Delphi]
procedure set_ColPosition(col: Integer; newPosition: Integer);
See Also
C1FlexGridClassic Class (page 429)
set_ColSort Method
Sets the sorting order for each column (for use with the Sort property).
Syntax
[VB]
Public Sub set_ColSort(ByVal col As Integer, ByVal newVal As C1.Win.C1FlexGrid.Classic.SortSettings)
[C#]
public void set_ColSort ( System.Int32 col , C1.Win.C1FlexGrid.Classic.SortSettings newVal )
[Delphi]
procedure set_ColSort(col: Integer; newVal: C1.Win.C1FlexGrid.Classic.SortSettings);
See Also
C1FlexGridClassic Class (page 429)
set_ColWidth Method
Sets the width of the specified column, in twips.
Syntax
[VB]
Public Sub set_ColWidth(ByVal col As Integer, ByVal newVal As Integer)
534 · C1FlexGridClassic Reference
[C#]
public void set_ColWidth ( System.Int32 col , System.Int32 newVal )
[Delphi]
procedure set_ColWidth(col: Integer; newVal: Integer);
See Also
C1FlexGridClassic Class (page 429)
set_FixedAlignment Method
Sets the alignment for the fixed rows in a column.
Syntax
[VB]
Public Sub set_FixedAlignment(ByVal col As Integer, ByVal newVal As
C1.Win.C1FlexGrid.Classic.AlignmentSettings)
[C#]
public void set_FixedAlignment ( System.Int32 col , C1.Win.C1FlexGrid.Classic.AlignmentSettings
newVal )
[Delphi]
procedure set_FixedAlignment(col: Integer; newVal: C1.Win.C1FlexGrid.Classic.AlignmentSettings);
See Also
C1FlexGridClassic Class (page 429)
set_IsCollapsed Method
Sets whether a row is collapsed.
Syntax
[VB]
Public Sub set_IsCollapsed(ByVal row As Integer, ByVal newVal As Boolean)
[C#]
public void set_IsCollapsed ( System.Int32 row , System.Boolean newVal )
[Delphi]
procedure set_IsCollapsed(row: Integer; newVal: Boolean);
See Also
C1FlexGridClassic Class (page 429)
set_IsSelected Method
Sets whether a row is selected (for listbox-type selections).
set_IsSubtotal Method · 535
Syntax
[VB]
Public Sub set_IsSelected(ByVal row As Integer, ByVal newVal As Boolean)
[C#]
public void set_IsSelected ( System.Int32 row , System.Boolean newVal )
[Delphi]
procedure set_IsSelected(row: Integer; newVal: Boolean);
See Also
C1FlexGridClassic Class (page 429)
set_IsSubtotal Method
Sets whether a row contains subtotals (as opposed to data).
Syntax
[VB]
Public Sub set_IsSubtotal(ByVal row As Integer, ByVal newVal As Boolean)
[C#]
public void set_IsSubtotal ( System.Int32 row , System.Boolean newVal )
[Delphi]
procedure set_IsSubtotal(row: Integer; newVal: Boolean);
Remarks
This property allows you to determine whether a given row is a regular row or a subtotal row, or to
create subtotal rows manually (as opposed to using the Subtotal method).
There are two differences between subtotal rows and regular rows:
1.
Subtotal rows may be added and removed automatically with the Subtotal method.
2.
When using the control as an outliner, subtotal rows behave as outline nodes, while regular rows
behave as branches.
You may use this property to build custom outlines. This requires three steps:
1.
Set the IsSubtotal property to True for all outline nodes.
2.
Set the set_RowOutlineLevel method for each outline node.
3.
Set the OutlineBar and OutlineCol properties if you want to display an outline tree, which the
user can use to collapse and expand the outline.
For more details, see the Outline Demo.
See Also
C1FlexGridClassic Class (page 429)
536 · C1FlexGridClassic Reference
set_MergeCol Method
Sets whether a column will have its cells merged.
Syntax
[VB]
Public Sub set_MergeCol(ByVal col As Integer, ByVal newVal As Boolean)
[C#]
public void set_MergeCol ( System.Int32 col , System.Boolean newVal )
[Delphi]
procedure set_MergeCol(col: Integer; newVal: Boolean);
See Also
C1FlexGridClassic Class (page 429)
MergeCells Property (page 484)
set_MergeRow Method
Sets whether a row will have its cells merged.
Syntax
[VB]
Public Sub set_MergeRow(ByVal row As Integer, ByVal newVal As Boolean)
[C#]
public void set_MergeRow ( System.Int32 row , System.Boolean newVal )
[Delphi]
procedure set_MergeRow(row: Integer; newVal: Boolean);
Remarks
The set_MergeRow method is used in conjunction with the MergeCells property and set_MergeCol
method to control whether and how cells are merged for display.
The MergeCells property is used to enable cell merging for the entire control. After setting it to an
appropriate value, the set_MergeRow and set_MergeCol methods are used to determine which rows and
columns should have their cells merged. By default, set_MergeRow and set_MergeCol are set to False, so
no merging takes place. If you set them to True for a specific row or column, then adjacent cells in that
row or column will be merged if their contents are equal.
The Row parameter should be set to a value between zero and Rows - 1 to set MergeRow for a single row,
or -1 to set all rows.
You don't need to set set_MergeRow to True when MergeCells is set to flexMergeSpill (6).
For more details and examples, see the MergeCells property.
set_RowData Method · 537
See Also
C1FlexGridClassic Class (page 429)
MergeCells Property (page 484)
set_RowData Method
Sets a user-defined variant associated with the given row.
Syntax
[VB]
Public Sub set_RowData(ByVal row As Integer, ByVal newVal As Object)
[C#]
public void set_RowData ( System.Int32 row , System.Object newVal )
[Delphi]
procedure set_RowData(row: Integer; newVal: Object);
See Also
C1FlexGridClassic Class (page 429)
set_RowHeight Method
Sets the height of the specified row, in twips.
Syntax
[VB]
Public Sub set_RowHeight(ByVal row As Integer, ByVal newVal As Integer)
[C#]
public void set_RowHeight ( System.Int32 row , System.Int32 newVal )
[Delphi]
procedure set_RowHeight(row: Integer; newVal: Integer);
See Also
C1FlexGridClassic Class (page 429)
set_RowHidden Method
Sets whether a row is hidden.
Syntax
[VB]
Public Sub set_RowHidden(ByVal row As Integer, ByVal newVal As Boolean)
538 · C1FlexGridClassic Reference
[C#]
public void set_RowHidden ( System.Int32 row , System.Boolean newVal )
[Delphi]
procedure set_RowHidden(row: Integer, newVal: Boolean);
See Also
C1FlexGridClassic Class (page 429)
set_RowOutlineLevel Method
Sets the outline level for a subtotal row.
Syntax
[VB]
Public Sub set_RowOutlineLevel(ByVal row As Integer, ByVal newVal As Integer)
[C#]
public void set_RowOutlineLevel ( System.Int32 row , System.Int32 newVal )
[Delphi]
procedure set_RowOutlineLevel(row: Integer; newVal: Integer);
Remarks
The set_RowOutlineLevel property is used for two closely related purposes.
1.
When using the grid in outline mode, set_RowOutlineLevel is used to set the hierarchical level
of a node. Nodes with high outline level are children of rows with low outline level. The root
node has the lowest outline level. You may change the relationship between nodes by modifying
the value of the set_RowOutlineLevel method. For more details on creating and using outlines,
see the Outline Demo.
2.
When using the Subtotal method to create subtotals automatically, set_RowOutlineLevel stores
the number of the column being used for grouping the data. For more details on creating and
using automatic subtotals, see the Subtotal method.
The set_RowOutlineLevel is only used by the control if the set_IsSubtotal property is set to True.
See Also
C1FlexGridClassic Class (page 429)
set_RowPosition Method
Moves a given row to a new position.
Syntax
[VB]
Public Sub set_RowPosition(ByVal row As Integer, ByVal newPosition As Integer)
set_TextMatrix Method · 539
[C#]
public void set_RowPosition ( System.Int32 row , System.Int32 newPosition )
[Delphi]
procedure set_RowPosition(row: Integer; newPosition: Integer);
See Also
C1FlexGridClassic Class (page 429)
set_TextMatrix Method
Sets the contents of a cell identified by its row and column coordinates.
Syntax
[VB]
Public Sub set_TextMatrix(ByVal r As Integer, ByVal c As Integer, ByVal s As String)
[C#]
public void set_TextMatrix ( System.Int32 r , System.Int32 c , System.String s )
[Delphi]
procedure set_TextMatrix(r: Integer; c: Integer; s: String);
See Also
C1FlexGridClassic Class (page 429)
Cell Class
All Cell Members
Cell Properties
Item
Gets or sets the data in a grid cell.
Cell Properties
Item Property (Cell)
Gets or sets the data in a grid cell.
Syntax
[VB]
Default Public Property Item(ByVal setting As C1.Win.C1FlexGrid.Classic.CellPropertySettings, ByVal
row As Integer, ByVal col As Integer) As Object
Default Public Property Item(ByVal setting As C1.Win.C1FlexGrid.Classic.CellPropertySettings, ByVal
row1 As Integer, ByVal col1 As Integer, ByVal row2 As Integer, ByVal col2 As Integer) As Object
540 · C1FlexGridClassic Reference
[C#]
public object this [CellPropertySettings setting, int row, int col]
public object this [CellPropertySettings setting, int row1, int col1, int row2, int col2]
[Delphi]
property Item(setting: CellPropertySettings; row: Integer, col: Integer): Object;
property Item(setting: CellPropertySettings; row1: Integer, col1: Integer, row2: Integer, col2: Integer):
Object;
See Also
C1FlexGrid Class (page 101)
C1FlexGridClassic Class (page 429)
Column Class (page 320)
Row Class (page 306)
C1FlexGridClassic Enumerations
AlignmentSettings Enumeration
Specifies an alignment type.
Syntax
[VB]
Public enum AlignmentSettings
[C#]
public sealed enum AlignmentSettings : System.Enum
[Delphi]
type AlignmentSettings = (flexAlignLeftTop, flexAlignLeftCenter, flexAlignLeftBottom,
flexAlignCenterTop, flexAlignCenterCenter, flexAlignCenterBottom, flexAlignRightTop,
flexAlignRightCenter, flexAlignRightBottom, flexAlignGeneral);
Remarks
Use the members of this enumeration to set the value of CellAlignment, get_ColAlignment, and
get_FixedAlignment in the C1FlexGridClassic control.
Member Name
Description
flexAlignLeftTop
Aligns to the left top.
flexAlignLeftCenter
Aligns to the left center.
flexAlignLeftBottom
Aligns to the left bottom.
flexAlignCenterTop
Aligns to the center top.
flexAlignCenterCenter
Aligns to the center.
AllowUserResizeSettings Enumeration · 541
Member Name
Description
flexAlignCenterBottom
Aligns to the center bottom.
flexAlignRightTop
Aligns to the right top.
flexAlignRightCenter
Aligns to the right center.
flexAlignRightBottom
Aligns to the right bottom.
flexAlignGeneral
Aligns text to the left and numbers and dates to the right.
AllowUserResizeSettings Enumeration
Specifies which areas of the grid can be resized.
Syntax
[VB]
Public enum AllowUserResizeSettings
[C#]
public sealed enum AllowUserResizeSettings : System.Enum
[Delphi]
type AllowUserResizeSettings = (flexResizeNone, flexResizeColumns, flexResizeRows, flexResizeBoth,
flexResizeBothUniform, flexResizeRowsUniform);
Remarks
Use the members of this enumeration to set the value of the AllowUserResizing property in the
C1FlexGridClassic control.
Member Name
Description
flexResizeNone
The user may not resize rows or columns.
flexResizeColumns
The user may resize column widths.
flexResizeRows
The user may resize row heights.
flexResizeBoth
The user may resize column widths and row heights.
flexResizeBothUniform
The user may resize column widths and row heights.
flexResizeRowsUniform
When a row height is resized, the new height is applied to all
rows.
AutoSizeSettings Enumeration
Specifies whether AutoSizeMode will adjust column widths or row heights to fit cell contents.
Syntax
[VB]
Public enum AutoSizeSettings
542 · C1FlexGridClassic Reference
[C#]
public sealed enum AutoSizeSettings : System.Enum
[Delphi]
type AutoSizeSettings = (flexAutoSizeColWidth, flexAutoSizeRowHeight);
Remarks
Use the members of this enumeration to set the value of the AutoSizeMode property in the
C1FlexGridClassic control.
Member Name
Description
flexAutoSizeColWidth
The user may not resize rows or columns.
flexAutoSizeRowHeight
The user may resize column widths.
CellCheckedSettings Enumeration
Specifies the current status of the checkbox in a cell or selection.
Syntax
[VB]
Public enum CellCheckedSettings
[C#]
public sealed enum CellCheckedSettings : System.Enum
[Delphi]
type CellCheckedSettings = (flexNoCheckbox, flexChecked, flexUnchecked);
Remarks
Use the members of this enumeration to set the value of the CellChecked property in the
C1FlexGridClassic control.
Member Name
Description
flexNoCheckbox
The cell has no check box. This is the default setting.
flexChecked
The cell has a check box that is checked.
flexUnchecked
The cell has a check box that is not checked.
CellPropertySettings Enumeration
Specifies how a check box within the cell appears.
Syntax
[VB]
Public enum CellPropertySettings
ClearWhatSettings Enumeration · 543
[C#]
public sealed enum CellPropertySettings: System.Enum
[Delphi]
type CellPropertySettings = (flexChecked, flexNoCheckbox, flexTSChecked, flexTSGrayed,
flexTSUnchecked, flexUnchecked);
Remarks
Use the members of this enumeration to set the value of the get_Cell and set_Cell methods and the Item
property in the C1FlexGridClassic control.
Member Name
Description
flexChecked
The cell has a check box that is checked.
flexNoCheckbox
The cell has no check box. This is the default setting.
flexTSChecked
The cell has a Tri-state check box with a check mark in it.
flexTSGrayed
The cell has a Tri-state check box in grayed state.
flexTSUnchecked
The cell has a Tri-state empty check box.
flexUnchecked
The cell has a check box that is not checked.
ClearWhatSettings Enumeration
Specifies what the Clear method will delete.
Syntax
[VB]
Public enum ClearWhatSettings
[C#]
public sealed enum ClearWhatSettings : System.Enum
[Delphi]
type ClearWhatSettings = (flexClearEverything, flexCleartext, flexClearFormatting; flexClearData);
Remarks
Use the members of this enumeration to set the value of an argument of the Clear method in the
C1FlexGridClassic control.
Member Name
Description
flexClearEverything
Everything will be cleared from area.
flexCleartext
Only text will be cleared from area.
flexClearFormatting
Only formatting will be cleared from area.
flexClearData
Only data in data area will be cleared from area.
544 · C1FlexGridClassic Reference
ClearWhereSettings Enumeration
Specifies where the Clear method will delete items.
Syntax
[VB]
Public enum ClearWhereSettings
[C#]
public sealed enum ClearWhereSettings : System.Enum
[Delphi]
type ClearWhereSettings = (flexClearEverywhere, flexClearScrollable, flexClearSelection);
Remarks
Use the members of this enumeration to set the value of an argument of the Clear method in the
C1FlexGridClassic control.
Member Name
Description
flexClearEverywhere
Clear from entire grid.
flexClearScrollable
Clear from only scrollable portion of grid.
flexClearSelection
Clear from selected area.
EditableSettings Enumeration
Specifies the state of editing in the grid.
Syntax
[VB]
Public enum EditableSettings
[C#]
public sealed enum EditableSettings : System.Enum
[Delphi]
type EditableSettings = (flexEDNone, flexEDKbd, flexEDKbdMouse);
Remarks
Use the members of this enumeration to set the value of the Editable property in the C1FlexGridClassic
control.
Member Name
Description
flexEDNone
The grid contents cannot be edited by the user.
flexEDKbd
The user may initiate edit mode by typing into the current cell.
flexEDKbdMouse
The user may initiate edit mode by typing into the current cell
or by double-clicking it with the mouse.
EllipsisSettings Enumeration · 545
EllipsisSettings Enumeration
Specifies how long strings are displayed in a cell.
Syntax
[VB]
Public enum EllipsisSettings
[C#]
public sealed enum EllipsisSettings : System.Enum
[Delphi]
type EllipsisSettings = (flexNoEllipsis, flexEllipsisEnd, flexEllipsisPath);
Remarks
Use the members of this enumeration to set the value of the Ellipsis property in the C1FlexGridClassic
control.
Member Name
Description
flexNoEllipsis
Long strings are truncated, no ellipsis characters are
displayed.
flexEllipsisEnd
Ellipsis characters are displayed at the end of long strings.
flexEllipsisPath
Ellipsis characters are displayed in the middle of long strings.
ExplorerBarSettings Enumeration
Specifies the properties of the column headers.
Syntax
[VB]
Public enum ExplorerBarSettings
[C#]
public sealed enum ExplorerBarSettings : System.Enum
[Delphi]
type ExplorerBarSettings = (flexExNone, flexExSort, flexExMove, flexExSortAndMove, flexExSortShow,
flexExSortShowAndMove, flexExMoveRows);
Remarks
Use the members of this enumeration to set the value of the ExplorerBar property in the
C1FlexGridClassic control.
546 · C1FlexGridClassic Reference
Member Name
Description
flexExNone
Long strings are truncated, no ellipsis characters are
displayed.
flexExSort
Ellipsis characters are displayed at the end of long strings.
flexExMove
Ellipsis characters are displayed in the middle of long strings.
flexExSortAndMove
Users may sort and move columns.
flexExSortShow
Users may sort columns by clicking on their headings. The
control will show the current sorting order by drawing an
arrow on the heading.
flexExSortShowAndMove
Users may sort and move columns. The control will show the
current sorting order by drawing an arrow on the heading.
flexExMoveRows*
Allows movement of rows by dragging them by the fixed cells
on the row.
*The setting flexExMoveRows is a flag, and may be combined with other setting using the "Or" operator.
FillStyleSettings Enumeration
Specifies whether properties are applied to the current cell or entire selection.
Syntax
[VB]
Public enum FillStyleSettings
[C#]
public sealed enum FillStyleSettings : System.Enum
[Delphi]
type FillStyleSettings = (flexFillSingle, flexFillRepeat);
Remarks
Use the members of this enumeration to set the value of the FillStyle property in the C1FlexGridClassic
control.
Member Name
Description
flexFillSingle
Setting the Text property or any of the cell formatting
properties affects the current cell only.
flexFillRepeat
Setting the Text property or any of the cell formatting
properties affects the entire selected range.
GridStyleSettings Enumeration
Specifies the style of the grid’s lines.
MergeSettings Enumeration · 547
Syntax
[VB]
Public enum GridStyleSettings
[C#]
public sealed enum GridStyleSettings : System.Enum
[Delphi]
type GridStyleSettings = (flexGridNone, flexGridFlat, flexGridInset, flexGridRaised, flexGridFlatHorz,
flexGridInsetHorz, flexGridRaisedHorz, flexGridSkipHorz, flexGridFlatVert, flexGridInsetVert,
flexGridRaisedVert, flexGridSkipVert, flexGridExplorer, flexGridExcel);
Remarks
Use the members of this enumeration to set the value of the GridLines and GridLinesFixed properties in
the C1FlexGridClassic control.
Member Name
Description
flexGridNone
Do not draw grid lines between cells.
flexGridFlat
Draw flat lines with color and width determined by the GridColor
and GridLineWidth properties.
flexGridInset
Draw inset lines between cells.
flexGridRaised
Draw raised lines between cells.
flexGridFlatHorz
Draw flat lines between rows, no lines between columns.
flexGridInsetHorz
Draw inset lines between rows, no lines between columns.
flexGridRaisedHorz
Draw raised lines between rows, no lines between columns.
flexGridSkipHorz
Draw an inset effect around every other row.
flexGridFlatVert
Draw flat lines between columns, no lines between rows.
flexGridInsetVert
Draw inset lines between columns, no lines between rows.
flexGridRaisedVert
Draw raised lines between columns, no lines between rows.
flexGridSkipVert
Draw an inset effect around every other column.
flexGridExplorer
Draw button-like frames around each cell.
flexGridExcel
Draw button-like frames around each cell, highlighting the
headings for the current selection. This setting should only be
applied to the GridLinesFixed property.
MergeSettings Enumeration
Specifies how cells are merged.
Syntax
[VB]
Public enum MergeSettings
548 · C1FlexGridClassic Reference
[C#]
public sealed enum MergeSettings : System.Enum
[Delphi]
type MergeSettings = (flexMergeNever, flexMergeFree, flexMergeRestrictRows,
flexMergeRestrictColumns, flexMergeRestrictAll, flexMergeFixedOnly, flexMergeSpill,
flexMergeOutline);
Remarks
Use the members of this enumeration to set the value of the MergeCells property in the
C1FlexGridClassic control.
Member Name
Description
flexMergeNever
Do not merge cells.
flexMergeFree
Merge any adjacent cells with same contents (if they are on a
row with RowMerge set to True or a column with MergeCol
set to True).
flexMergeRestrictRows
Merge rows only if cells above are also merged.
flexMergeRestrictColumns
Merge columns only if cells to the left are also merged.
flexMergeRestrictAll
Merge cells only if cells above or to the left are also merged.
flexMergeFixedOnly
Merge only fixed cells. This setting is useful for setting up
complex headers for the data and preventing the data itself
from being merged.
flexMergeSpill
Allow long entries to spill into empty adjacent cells.
flexMergeOutline
Makes entries in subtotal rows spill to fill adjacent empty
cells. This setting is useful when you want to display only a
node name on the outline nodes and data on the regular
(non-node) rows.
OutlineBarSettings Enumeration
Specifies the appearance of the outline bar defined with the OutlineBar property.
Syntax
[VB]
Public enum OutlineBarSettings
[C#]
public sealed enum OutlineBarSettings: System.Enum
[Delphi]
type OutlineBarSettings = (flexOutlineBarComplete, flexOutlineBarCompleteLeaf, flexOutlineBarNone,
flexOutlineBarSimple, flexOutlineBarSimpleLeaf, flexOutlineBarSymbols, flexOutlineBarSymbolsLeaf);
PictureAlignmentSettings Enumeration · 549
Remarks
Use the members of this enumeration to set the value of the OutlineBar property in the
C1FlexGridClassic control.
Member Name
Description
flexOutlineBarComplete
Complete outline tree plus button row on top. (Buttons are
only displayed if the OutlineBar is on a fixed column).
flexOutlineBarCompleteLeaf
Similar to flexOutlineBarComplete, but empty nodes are
displayed without symbols.
flexOutlineBarNone
Do not show the outline bar
flexOutlineBarSimple
Complete outline tree, no buttons across the top.
flexOutlineBarSimpleLeaf
Similar to flexOutlineBarSimple, but empty nodes are
displayed without symbols.
flexOutlineBarSymbols
Outline symbols but no connecting lines.
flexOutlineBarSymbolsLeaf
Similar to flexOutlineBarSymbols, but empty nodes are
displayed without symbols.
PictureAlignmentSettings Enumeration
Specifies how pictures are aligned within a cell.
Syntax
[VB]
Public enum PictureAlignmentSettings
[C#]
public sealed enum PictureAlignmentSettings : System.Enum
[Delphi]
type PictureAlignmentSettings = (flexPicAlignLeftTop, flexPicAlignLeftCenter, flexPicAlignLeftBottom,
flexPicAlignCenterTop, flexPicAlignCenterCenter, flexPicAlignCenterBottom, flexPicAlignRightTop,
flexPicAlignRightCenter, flexPicAlignRightBottom, flexPicAlignStretch, flexPicAlignTile);
Remarks
Use the members of this enumeration to set the value of the CellPictureAlignment property in the
C1FlexGridClassic control.
Member Name
Description
flexPicAlignLeftTop
Aligns to the left top.
flexPicAlignLeftCenter
Aligns to the left center.
flexPicAlignLeftBottom
Aligns to the left bottom.
flexPicAlignCenterTop
Aligns to the center top.
flexPicAlignCenterCenter
Aligns to the center.
550 · C1FlexGridClassic Reference
Member Name
Description
flexPicAlignCenterBottom
Aligns to the center bottom.
flexPicAlignRightTop
Aligns to the right top.
flexPicAlignRightCenter
Aligns to the right center.
flexPicAlignRightBottom
Aligns to the right bottom.
flexPicAlignStretch
Stretches the picture to fit the cell.
flexPicAlignTile
Tiles the picture within the cell.
RedrawSettings Enumeration
Specifies how the grid paints its contents.
Syntax
[VB]
Public enum RedrawSettings
[C#]
public sealed enum RedrawSettings : System.Enum
[Delphi]
type RedrawSettings = (flexRDBuffered, flexRDDirect, flexRDNone);
Remarks
Use the members of this enumeration to set the value of the Redraw property in the C1FlexGridClassic
control.
Member Name
Description
flexRDBuffered
The grid paints its contents on an off-screen buffer, then
transfers the complete image to the screen. This mode is
slightly slower than flexRDDirect, but it eliminates flicker.
flexRDDirect
The grid paints its contents directly on the screen.
This is the fastest repaint mode, but there occasionally it may
cause a little flicker.
flexRDNone
The grid does not repaint itself.
SelModeSettings Enumeration
Specifies how selections can be made.
Syntax
[VB]
Public enum SelModeSettings
SortSettings Enumeration · 551
[C#]
public sealed enum SelModeSettings: System.Enum
[Delphi]
type SelModeSettings = (flexSelectionByColumn, flexSelectionByRow, flexSelectionFree,
flexSelectionListBox);
Remarks
Use the members of this enumeration to set the value of the SelectionMode property in the
C1FlexGridClassic control.
Member Name
Description
flexSelectionByColumn
Forces selections to span entire columns. Useful for selecting ranges for
a chart or fields for sorting.
flexSelectionByRow
Forces selections to span entire rows. Useful for implementing recordbased displays.
flexSelectionFree
Allows selections to be made as usual, spreadsheet-style.
flexSelectionListBox
Similar to flexSelectionByRow, but allows non-continuous selections.
CTRL-clicking with the mouse toggles the selection for an individual row.
Dragging the mouse over a group of rows toggles their selected state.
SortSettings Enumeration
Specifies how a column is sorted.
Syntax
[VB]
Public enum SortSettings
[C#]
public sealed enum SortSettings : System.Enum
[Delphi]
type SortSettings = (flexSortNone, flexSortGenericAscending, flexSortGenericDescending,
flexSortNumericAscending, flexSortNumericDescending, flexSortStringNoCaseAscending,
flexSortStringNoCaseDescending, flexSortStringAscending, flexSortStringDescending, flexSortCustom,
flexSortUseColSort);
Remarks
Use the members of this enumeration to set the value of the Sort property in the C1FlexGridClassic
control.
Member Name
Description
flexSortNone
Ignore this column when sorting. This setting is useful when you
assign it to a column's Cols property, then set Sort to
flexSortUseColSort.
552 · C1FlexGridClassic Reference
Member Name
Description
flexSortGenericAscending
Sort strings and numbers in ascending order.
flexSortGenericDescending
Sort strings and numbers in descending order.
flexSortNumericAscending
Sort numbers in ascending order.
flexSortNumericDescending
Sort numbers in descending order.
flexSortStringNoCaseAscending
Sort strings in ascending order, ignoring capitalization.
flexSortStringNoCaseDescending
Sort strings in descending order, ignoring capitalization.
flexSortStringAscending
Sort strings in ascending order.
flexSortStringDescending
Sort strings in descending order.
flexSortCustom
Fire a Compare event and use the return value to sort the
columns.
flexSortUseColSort
This setting allows you to use different settings for each column,
as determined by the ColSort property. Using this setting, you may
sort some columns in ascending and others in descending order.
TabBehaviorSettings Enumeration
Specifies the flow of control when the Tab key is pressed.
Syntax
[VB]
Public enum TabBehaviorSettings
[C#]
public sealed enum TabBehaviorSettings : System.Enum
[Delphi]
type TabBehaviorSettings = (flexTabControls, flexTabCells);
Remarks
Use the members of this enumeration to set the value of the TabBehavior property in the
C1FlexGridClassic control.
Member Name
Description
flexTabControls
Tab key is used to move to the next or previous control on the form.
flexTabCells
Tab key is used to move to the next or previous cell on the control.
TextStyleSettings Enumeration
Specifies the text style.
TextStyleSettings Enumeration · 553
Syntax
[VB]
Public enum TextStyleSettings
[C#]
public sealed enum TextStyleSettings : System.Enum
[Delphi]
type TextStyleSettings = (flexTextFlat, flexTextRaised, flexTextInset, flexTextRaisedLight,
flexTextInsetLight);
Remarks
Use the members of this enumeration to set the value of the CellTextStyle, TextStyle, and
TextStyleFixed properties in the C1FlexGridClassic control.
Member Name
Description
flexTextFlat
Draw text normally.
flexTextRaised
Draw text with a strong raised 3-D effect.
flexTextInset
Draw text with a strong inset 3-D effect.
flexTextRaisedLight
Draw text with a light raised 3-D effect.
flexTextInsetLight
Draw text with a light inset 3-D effect.
Index · 555
Index
A
Add method 292, 301, 352
of CellStyleCollection 352
of ColumnCollection 301
of RowCollection 292
AddItem method 161
AddNode method 380
AfterAddRow event 206
AfterCollapse event 206
AfterDataRefresh event 207
AfterDeleteRow event 207
AfterDragColumn event 208
AfterDragRow event 208
AfterEdit event 209
AfterFreezeColumn event 210
AfterFreezeRow event 210
AfterResizeColumn event 211
AfterResizeRow event 212
AfterRowColChange event 212
AfterScroll event 213
AfterSelChange event 215
AfterSort event 215
Aggregate method 163
AlignmentSettings enumeration 540
AllowAddNew property 108
AllowBigSelection property 435
AllowDelete property 109
AllowDragging property 110, 307, 322, 435
of C1FlexGridClassic 435
of Column 322
of Row 307
AllowEditing property 111, 307, 323, 436
of C1FlexGrid 111
of C1FlexGridClassic 436
of Column 323
of Row 307
AllowFreezing property 111
AllowMerging property 112, 308, 323, 437
of C1FlexGridClassic 437
of Column 323
of Row 308
AllowResizing property 113, 308, 324, 438
of C1FlexGridClassic 438
of Column 324
of Row 308
AllowSelection property 439
AllowSorting property 114, 324, 440
of C1FlexGrid 114
of C1FlexGridClassic 440
of Column 324
AllowUserResizeSettings enumeration 541
AllowUserResizing property 441
Alternate property 347
AutoClipboard property 115
AutoResize property 116
AutoSearch property 116
AutoSearchDelay property 117
AutoSize method 503
AutoSizeCol method 165
AutoSizeCols method 166
AutoSizeMode property 442
AutoSizeRow method 167
AutoSizeRows method 167
AutoSizeSettings enumeration 541
B
BackColor property 358
BackColorAlternate property 443
BackColorBkg property 443
BackColorFixed property 444
BackColorSel property 444
BackgroundImage property 445
BeforeAddRow event 216
BeforeAutoSizeColumn event 217
BeforeAutoSizeRow event 217
BeforeCollapse event 218
BeforeDeleteRow event 221
BeforeDragColumn event 221
BeforeDragRow event 222
BeforeEdit event 223
BeforeFreezeColumn event 224
BeforeFreezeRow event 225
BeforeMouseDown event 225
BeforeMouseDownEventArgs class 268
BeforeMouseDownEventHandler delegate 261
BeforePageBreak event 227
BeforeResizeColumn event 228
BeforeResizeRow event 229
BeforeRowColChange event 229
BeforeScroll event 230
BeforeScrollTip event 231
BeforeSelChange event 232
BeforeSort event 233
556 · Index
BeginPrint event 233
Border property 358
BorderStyle property 118
Bottom property 309
BottomRow property 117, 276
of CellRange 276
BuildString method 353, 368
of CellStyle 368
C
CancelAddRow event 234
Caption property 309, 324
of Row 309
Cell property 445
CellAlignment property 445
CellBackColor property 447
CellButtonClick event 234
CellButtonImage property 118, 448
of C1FlexGridClassic 448
CellButtonPicture property 449
CellChanged event 235
CellChecked property 449
CellCheckedSettings enumeration 542
CellFont property 451
CellFontBold property 452
CellFontItalic property 452
CellFontName property 453
CellFontSize property 453
CellFontStrikeThru property 454
CellFontUnderline property 454
CellForeColor property 455
CellHeight property 455
CellLeft property 456
CellPicture property 456
CellPictureAlignment property 457
CellPropertySettings enumeration 542
CellTextStyle property 458
CellTop property 458
CellWidth property 459
ChangeEdit event 236
CheckBox property 277
Children property 375
Class
C1FlexGrid Class 101
CellBorder Class 372
CellStyle Class 356
CellStyleCollection Class 345
Column Class 320
ColumnCollection Class 297
DragRowColEventArgs Class 269
GridChangedEventArgs Class 269
GridErrorEventArgs Class 270
GridGlyphs Class 384
GridPrinter Class 391
GridTree Class 385
HitTestInfo Class 285
KeyEditEventArgs Class 270
KeyPressEditEventArgs Class 271
OwnerDrawCellEventArgs Class 271
RangeEventArgs Class 272
Row Class 306
RowColEventArgs Class 273
RowCollection Class 287
SortColEventArgs Class 273
ValidateEditEventArgs Class 274
Clear method 168, 319, 344, 354, 369, 504
of C1FlexGrid 168
of CellStyle 369
of CellStyleCollection 354
of Column 344
of Row 319
ClearUnused method 354
ClearWhatSettings enumeration 543
ClearWhereSettings enumeration 544
Clip property 119, 277
of CellRange 277
ClipSeparators property 120
Col property 121
Collapsed property 375
Color property 373
Cols property 121, 459
of C1FlexGridClassic 459
ColSel property 122
Column property 285, 385
of HitTestInfo 285
ColumnCollection property 460
ColWidthMax property 460
ColWidthMin property 461
ComboCloseUp event 238
ComboCount property 462
ComboDropDown event 239
ComboIndex property 462
ComboItem method 506
ComboList property 123, 325, 359
of CellStyle 359
of Column 325
Contains method 283, 292, 302, 355
of CellRange 283
of CellStyleCollection 355
of ColumnCollection 302
of RowCollection 292
ContainsCol method 283
ContainsRow method 284
Index · 557
Count property 288, 298, 347
of CellStyleCollection 347
of ColumnCollection 298
of RowCollection 288
CreateImage method 169
CursorCell property 125
CustomComparer property 126
D
Data property 278, 376
of CellRange 278
of Node 376
DataDisplay property 278
DataIndex property 310, 325
of Column 325
of Row 310
DataMap property 326, 360
of CellStyle 360
of Column 326
DataMember property 126
DataSource property 127, 310
of C1FlexGrid 127
of Row 310
DataType property 327
DefaultSize property 288, 298
of ColumnCollection 298
of RowCollection 288
DefinedElements property 360
Direction property 372
Display property 360
DoubleBuffer property 129
DragMode property 130
DragRowColEventArgs class 269
DragRowColEventHandler delegate 261
DrawCell method 171
DrawMode property 131
DropMode property 131
E
Editable property 463
EditableSettings enumeration 544
EditCell method 506
EditMask property 132, 329, 361
of C1FlexGrid 132
of Column 329
EditOptions property 135
Editor property 133, 311, 330, 348, 361
of C1FlexGrid 133
of CellStyle 361
of CellStyleCollection 348
of Column 330
of Row 311
EditSelLength property 464
EditSelStart property 465
EditSelText property 466
EditText property 467
EditWindow property 469
Ellipsis property 469
EllipsisSettings enumeration 545
EmptyArea property 348
EndPrint event 239
EnsureVisible method 380
EnterCell event 240
Expanded property 377
ExplorerBar property 470
ExplorerBarSettings enumeration 545
ExtendLastCol property 135
F
FillStyle property 472
FillStyleSettings enumeration 546
FindRow method 172, 506
of C1FlexGridClassic 506
FinishEditing method 173
Fixed property 289, 298, 349
of CellStyleCollection 349
of ColumnCollection 298
of RowCollection 289
FixedCols property 472
FixedRows property 473
Focus property 349
FocusRect property 136
Font property 362
of CellStyle 362
FontBold property 474
FontItalic property 474
FontName property 475
FontSize property 475
FontStrikeThru property 475
FontUnderline property 476
Footer property 391
FooterFont property 392
ForeColor property 363
ForeColorFixed property 476
ForeColorSel property 477
Format property 330, 363
of CellStyle 363
Frozen property 289, 299, 349
of ColumnCollection 299
of RowCollection 289
FrozenCols property 477
FrozenRows property 477
558 · Index
G
get_Cell method 507
get_ColAlignment method 509
get_ColComboList method 509
get_ColData method 509
get_ColDataType method 510
get_ColEditMask method 510
get_ColFormat method 510
get_ColHidden method 511
get_ColIndent method 511
get_ColIndex method 511
get_ColIsVisible method 512
get_ColKey method 512
get_ColPos method 513
get_ColSort method 513
get_ColWidth method 513
get_FixedAlignment method 514
get_IsCollapsed method 514
get_IsSelected method 514
get_IsSubtotal method 515
get_MergeCol method 515
get_MergeRow method 517
get_RowData method 520
get_RowHeight method 520
get_RowHidden method 520
get_RowIsVisible method 521
get_RowOutlineLevel method 521
get_RowPos method 522
get_TextMatrix method 523
Get_ValueMatrix method 523
GetCellCheck method 173
GetCellCheck property 136
GetCellImage method 175
GetCellRange method 175, 381
of Node 381
GetCellRect method 176
GetCellStyle method 177
GetCellStyleDisplay method 178
GetData method 178
GetDataDisplay method 179
GetMergedRange method 180, 516
of C1FlexGrid 180
GetNode method 381, 518
of C1FlexGridClassic 518
GetNodeRow method 519
GetSelection method 522
GetUnboundValue event 240
Glyphs property 137
GridChanged event 243
GridChangedEventArgs class 269
GridChangedEventHandler delegate 262
GridColor property 478
GridColorFixed property 478
GridError event 244
GridErrorEventArgs class 270
GridErrorEventHandler delegate 262
GridLines property 479
GridLinesFixed property 480
GridLineWidth property 481
GridStyleSettings enumeration 546
H
Header property 393
HeaderFont property 394
Height property 311
HeightDisplay property 312
HighLight property 137, 350
of CellStyleCollection 350
HitTest method 181
I
Image property 279, 377
of Node 377
ImageAlign property 312, 332, 364
of CellStyle 364
of Column 332
of Row 312
ImageAlignFixed property 313, 333
of Column 333
of Row 313
ImageAndText property 334
ImageMap property 334, 364
of Column 334
ImageSpacing property 365
Indent property 386
Index property 313, 336
of Column 336
of Row 313
Insert method 293, 303
of ColumnCollection 303
of RowCollection 293
InsertNode method 293
InsertRange method 294, 303
of ColumnCollection 303
of RowCollection 294
Invalidate method 183
IsNew property 314
IsNode property 314
IsSingleCell property 279
IsValid property 279
Item property 138, 290, 299, 350, 384, 539
of Cell 539
Index · 559
of CellStyleCollection 350
of ColumnCollection 299
of GridGlyphs 384
of RowCollection 290
K
Key property 378
KeyActionEnter property 139, 481
of C1FlexGridClassic 481
KeyActionTab property 140, 482
of C1FlexGridClassic 482
KeyDownEdit event 245
KeyEditEventArgs class 270
KeyEditEventHandler delegate 263
KeyPressEdit event 246
KeyPressEditEventArgs class 271
KeyPressEditEventHandler delegate 263
KeyUpEdit event 247
L
LeaveCell event 248
Left property 336
LeftCol property 142, 280
of CellRange 280
Level property 379
LineColor property 386
LineStyle property 387
LoadExcel method 184
LoadExcelSheetNames method 185
LoadGrid method 185
M
Margins property 365
MaxSize property 290, 300
of ColumnCollection 300
of RowCollection 290
MergeCells property 484
MergeSettings enumeration 547
MergeWith method 369
MinSize property 291, 301
of ColumnCollection 301
of RowCollection 291
MouseCol property 142
MouseRow property 144
Move method 294, 304, 320, 345, 382
of Column 345
of ColumnCollection 304
of Row 320
of RowCollection 294
MoveRange method 295, 304
of ColumnCollection 304
of RowCollection 295
N
Name property 336, 365
of CellStyle 365
of Column 336
NewRow property 351
Node property 315
NodeClosedPicture property 487
NodeImageCollapsed property 387
NodeImageExpanded property 387
NodeOpenPicture property 488
Normal property 351
Normalize method 285
O
Outline method 524
OutlineBar property 488
OutlineBarSettings enumeration 548
OutlineCol property 489
OwnerDrawCell event 249
OwnerDrawCellEventArgs class 271
OwnerDrawCellEventHandler delegate 264
P
PageCount property 395
PageNumber property 395
ParseString method 355, 370
of CellStyle 370
of CellStyleCollection 355
Picture property 490
PictureAlignmentSettings enumeration 549
PrintDocument property 395
PrintEventHandler delegate 264
PrintGrid method 186, 525
of C1FlexGridClassic 525
PrintPage event 252
PrintPageEventHandler delegate 265
PrintParameters property 144
PrintPreviewDialog property 396
R
r1,c1,r2,c2 property 280
RangeEventArgs class 272
RangeEventHandler delegate 265
Redraw property 144, 490
of C1FlexGridClassic 490
RedrawSettings enumeration 550
560 · Index
Remove method 296, 305, 356
of CellStyleCollection 356
of ColumnCollection 305
of RowCollection 296
RemoveItem method 188, 526
of C1FlexGrid 188
of C1FlexGridClassic 526
RemoveNode method 382
RemoveRange method 296, 305
of ColumnCollection 305
of RowCollection 296
Render method 371
Right property 337
RightCol property 146, 280
of CellRange 280
Row property 146, 286, 379
of HitTestInfo 286
of Node 379
RowColChange event 253
RowColEventArgs class 273
RowColEventHandler delegate 266
RowHeightMax property 491
RowHeightMin property 491
Rows property 147, 492
of C1FlexGridClassic 492
RowSel property 147
S
SafeIndex property 315, 337
of Column 337
of Row 315
SaveExcel method 188
SaveGrid method 190
ScrollBars property 148
ScrollPosition property 150
ScrollTips property 152
ScrollTipText property 154
ScrollTrack property 152
Search property 352
SelChange event 254
Select method 191, 383
of Node 383
Selected property 291, 301, 315, 338
of Column 338
of Row 315
of RowCollection 291
SelectedRow method 527
SelectedRows property 492
Selection property 155
SelectionMode property 156, 493
of C1FlexGridClassic 493
SelModeSettings enumeration 550
set_Cell method 527
set_ColAlignment method 529
set_ColComboList method 529
set_ColData method 530
set_ColDataType method 530
set_ColEditMask method 531
set_ColFormat method 531
set_ColHidden method 531
set_ColImageList method 532
set_ColIndent method 532
set_ColKey method 532
set_ColPosition method 533
set_ColSort method 533
set_ColWidth method 533
set_FixedAlignment method 534
set_IsCollapsed method 534
set_IsSelected method 534
set_IsSubtotal method 535
set_MergeCol method 536
set_MergeRow method 536
set_RowData method 537
set_RowHeight method 537
set_RowHidden method 537
set_RowOutlineLevel method 538
set_RowPosition method 538
set_TextMatrix method 539
SetCellCheck method 193
SetCellCheck property 157
SetCellImage method 192
SetCellStyle method 192
SetData method 195
SetDataBinding method 196
SetUnboundValue event 254
SetupEditor event 255
SheetBorder property 494
Show method 388
ShowButtons property 157
ShowCell method 197
ShowCursor property 158
ShowErrors property 158
ShowSortAt method 197
Sort method 198, 383, 389
of GridTree 389
of Node 383
Sort property 338, 495
of C1FlexGridClassic 495
of Column 338
SortColEventArgs class 273
SortColEventHandler delegate 267
SortSettings enumeration 551
StartEdit event 258
Index · 561
StartEditing method 200
Style property 281, 316, 339, 373, 388
of CellRange 281
of Column 339
of GridTree 388
of Row 316
StyleDisplay property 281, 316, 339
of CellRange 281
of Column 339
of Row 316
StyleFixed property 340
StyleFixedDisplay property 340
StyleFixedNew property 340
StyleNew property 282, 317, 341
of CellRange 282
of Column 341
of Row 317
Styles property 159, 496
of C1FlexGridClassic 496
Subtotal method 202
SubTotalPosition property 159
T
TabBehavior property 496
TabBehaviorSettings enumeration 552
Text property 498
TextAlign property 341, 366
of CellStyle 366
of Column 341
TextAlignFixed property 342
TextDirection property 366
TextEffect property 366
TextStyle property 499
TextStyleFixed property 500
TextStyleSettings enumeration 552
Top property 317
TopRow property 160, 282
of CellRange 282
Tree property 161
TreeColor property 500
Trimming property 367
Type property 286
of HitTestInfo 286
U
UserData property 282, 318, 343, 367
of CellRange 282
of CellStyle 367
of Column 343
of Row 318
V
ValidateEdit event 259
ValidateEditEventArgs class 274
ValidateEditEventHandler delegate 267
Value property 501
Visible property 319, 343
of Column 343
of Row 319
W
Wallpaper property 502
Width property 343, 373
of CellBorder 373
of Column 343
WidthDisplay property 344
WordWrap property 368, 502
of C1FlexGridClassic 502
X
X property 286
of HitTestInfo 286
Y
Y property 287
of HitTestInfo 287