Welcome to ComponentOne FlexGrid for .NET

ComponentOne FlexGrid for .NET

Welcome to ComponentOne FlexGrid for .NET

Previous Next

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

Installation

Adding the C1FlexGrid Component to the Toolbox

End-User License Agreement

Redistributable Files

Technical Support

Namespaces


Overview

Overview

The ComponentOne FlexGrid For .NET package consists of two controls:


C1FlexGrid Control

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.


C1FlexGridClassic Control

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.


Installation

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

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

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

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.

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

End-User License Agreement

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

I. THIS EULA.

1.

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

2.

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

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

“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 a single install of the SOFTWARE for use in designing, testing and creating Developed Software by a single Developer on a single computer with a single set of input devices, so long as such computer is used only by one Developer. Conversely, you may not install or use the SOFTWARE on a computer that is a network server or a computer at which the SOFTWARE is used by more than one Developer. You may not network the SOFTWARE or any component part of it, where it is or may be used by more than one Developer unless you purchase an additional Development License for each Developer. You must purchase another separate license to the SOFTWARE in order to add additional developer seats, whether the additional developers are accessing the SOFTWARE in a stand-alone environment or on a computer network. If the SOFTWARE is used to create Developed Web Server Software, then you may perform a single install of the SOFTWARE for use in designing, testing and creating Developed Web Server Software by a single Developer on a single computer or Network Server, either with a single CPU only. An additional Network Server CPU License is required for each additional CPU on the single computer or Network Server, as the case may be, upon which the SOFTWARE and/or the Developed Web Server Software is installed and a separate license for each separate computer. That is, for Developed Web Server Software, if the computer or Network Server operating the SOFTWARE has 2 CPU's, then you would need to purchase one additional Network Server CPU License (beyond the one Developer Seat License granted in this EULA).

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.

a. License to Distribute Developed Legacy Software. Subject to the terms and conditions in this EULA, you are granted the license to use and to distribute Developed Legacy Software on a royalty-free basis, provided that the Developed Legacy 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 Legacy Software only.

b. License to Distribute Developed Web Server Software. Subject to the terms and conditions in this EULA, you are granted the license to use and to distribute Developed Web Server Software, provided that you must purchase one Network CPU License for each CPU operating the Developed Web Server Software (and/or Redistributable Files called or otherwise used directly by the Developed Web Server Software). You may purchase an additional Network CPU License by purchasing an additional separate End User License for the SOFTWARE; one Network CPU License is included in this EULA. Notwithstanding the foregoing, however, you may distribute or transfer, free of royalties, the Redistributable Files (and/or any Developed Legacy Software) to the extent that they are used separately on a single CPU on the client/workstation side of the network served by the Web Server.

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. C1 ReportDesigner. C1ReportDesigner includes at least: 1) one dynamic link library (c1.win.c1reportdesigner.dll) file known as C1ReportDesigner Component, 2) one executable (ReportDesigner.exe) file known as C1ReportDesigner Application and, 3) the Source Code of the C1ReportDesigner Application. The C1ReportDesigner Component is subject to the general terms and restrictions set forth in this EULA. The C1ReportDesigner Application is an executable file used to design and prepare reports; the C1ReportDesigner Application may be distributed, free of royalties, only in conjunction with the Developed Software.

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

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

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

b. VS View Reporting Edition. VS View Reporting Edition includes at least one executable file listed as “VSRpt7.exe”, known as “Designer.” The file "VSRpt7.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. VSForum. VSForum 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 discussion forum (the database hereinafter referred to as the "Forum"). You may use the SOFTWARE to create one Forum on one Network Server only, which server may be connected at any point to an unlimited number of workstations or computers operating on one or more networks. You are specifically NOT LICENSED to create or operate multiple Forums. To create or to operate more than one FORUM, you must purchase one additional SOFTWARE license for each additional Forum.

d. Doc-to-Help. 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.

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

5.

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

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

6.

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

7.

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

III. INTELLECTUAL PROPERTY.

1.

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

2.

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

3.

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

4.

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

5.

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

6.

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

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

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

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

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

7.

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

IV. WARRANTIES AND REMEDIES.

1.

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

2.

Limited Remedy. C1's entire liability and your exclusive remedy under this EULA shall be, at C1's sole option, either (a) return of the price paid for the SOFTWARE; (b) repair the SOFTWARE through updates distributed online or otherwise in C1's discretion; or (c) replace the SOFTWARE with its reasonable, 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, that arise or result from this EULA.

3.

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


Redistributable Files

Redistributable Files

ComponentOne FlexGrid for .NET is developed and published by ComponentOne LLC. You may use it for development with Microsoft Visual Studio or any other programming environment. You may also distribute the following control files, royalty free, with any application you develop:

•

C1.Common.dll

•

C1.Win.C1Flexgrid.Classic.dll

•

C1.Win.C1Flexgrid.dll

Groups of multiple developers may be interested in acquiring ComponentOne product site licenses. Please contact ComponentOne for details.


Technical Support

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:


ComponentOne Web site

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

Internet e-mail

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

Support.FlexGrid.NET@componentone.com

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

•

Your ComponentOne product serial number.

•

The version and name of your operating system.

•

Your development environment and its version.

For more information on technical support, go to:

www.componentone.com/support


Peer-to-Peer newsgroup

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

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:

Dim flex As C1.Win.C1FlexGrid.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:

' 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

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:

Imports C1Column = C1.Win.C1FlexGrid.Column

Imports MyColumn = MyProject.Column

Dim c1 As C1Column

Dim c2 As MyColumn

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

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

Selection

Data Binding

Storing and Retrieving Data

Cell Ranges

Cell Images

Formatting Cells

Editing Cells

Outlining and Summarizing

Merging Cells

Saving, Loading, and Printing

FlexGrid Property Groups


Layout

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:

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:

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

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 right-click 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.

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

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

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:

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)


Data Binding

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.

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.

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

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:

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:

Dim r As Integer

For r = fg.Rows.Fixed To fg.Rows.Count – 1

fg(r, 0) = r

Next

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

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:

Dim rg As CellRange = fg.GetCellRange(3, 3, 10, 10)

rg.Data = Nothing

rg.Style = fg.Styles("MyRangeStyle")

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

Dim rg As CellRange = fg.GetCellRange(3, 3, 10, 10)

rg.StyleNew.BackColor = Color.Red


Cell Images

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

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

Cell appearance

Conditional formatting

Owner-draw cells


Cell content

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:

fg.Cols(1).Format = "d" ' << short date

fg.Cols(2).Format = "c" ' << currency

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:

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


Cell appearance

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:

Dim cs As CellStyle = fg.Styles.Highlight

cs.Font = New Font(fg.Font, FontStyle.Bold)

cs.ForeColor = Color.Green

cs.BackColor = Color.Red

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:

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

Here's a C# example that shows how you can create custom styles and assign them to columns, rows, and cell ranges:

// create a new custom style

CellStyle s = _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

_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"];

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


Conditional formatting

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:

' 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


Owner-draw cells

Owner-draw 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 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.

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:

' 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

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:

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


Editing Cells

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. These features are described below.

Editing with Lists and Combos

Checkboxes

Value-Mapped Lists

Cell Buttons

Masks

Validation

Controlling Edit Mode


Editing with Lists and Combos

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 drop-down 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:

fg.Cols(1).ComboList = "Red|Green|Blue|Red|White" ' drop-down list

fg.Cols(2).ComboList = "|Red|Green|Blue|Red|White" ' drop-down combo

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.


Checkboxes

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:

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.


Value-Mapped Lists

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.

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:

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

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.

The example below shows the difference:

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 = new Hashtable(); // << arbitrary order

ht.Add(0, "Zero");

ht.Add(1, "One");

ht.Add(2, "Two");

ht.Add(3, "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";

}

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:

Private Enum Countries

NewYork

Chicago

NewOrleans

London

Paris

End Enum

fg.Cols(1).DataType = GetType(Countries)


Cell Buttons

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.

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:

' set up date column

Dim c As Col = fg.Cols(1)

c.DataType = GetType(Color)

c.ComboList = "..." ' << show cell button

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:

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


Masks

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

' set up phone number edit mask

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

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

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:

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


Controlling Edit Mode

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.


Outlining and Summarizing

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

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:

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

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:

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

cs.BackColor = Color.DarkBlue

cs.ForeColor = Color.White

After executing this code, the grid would look like this:

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

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:

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

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:

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

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

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

This code creates a grid that looks like this:


Merging Cells

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

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:

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

' 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

This is the result:


Merged data views

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

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

This is the result:

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

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:

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.


Saving, Loading, and Printing

Saving, Loading, and Printing

The C1FlexGrid control has methods that allow you to save, load, and print grids.


Saving and Loading Grids

Saving and Loading Grids

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.

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:

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();

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();

}


Printing Grids

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 control also exposes a PrintParameters property that 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:

' 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}")


FlexGrid Property Groups

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

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, ClipSeparators, PrintGrid

10) OLE Drag Drop

DragMode, DropMode, BeforeMouseDown


FlexGrid Tutorials

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

Edit Tutorial

This tutorial starts with a basic data-entry grid, then adds the following features:

•

Formatting

•

Check boxes

•

Drop-down lists

•

Complex data validation

•

Clipboard support

Here is what the final application will look like:

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

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:

Imports 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:

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

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:

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

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.

To add the combolists, add the following code to the Form_Load event:

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

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:

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 " & _

"the sale of " & prd & " in region " & rgn & ". " & _

"Please verify input.")

e.Cancel = True

End If

End Sub

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. All it takes is the following code:

Private Sub fg_KeyDown(ByVal sender As Object, _

ByVal e As KeyEventArgs) Handles fg.KeyDown

Dim copy As Boolean, paste As Boolean

' ** copy: ctrl-C, ctrl-X, ctrl-ins

If e.Control Then

If e.KeyCode = Keys.C Or e.KeyCode = Keys.X Or _

e.KeyCode = Keys.Insert Then

copy = True

End If

End If

' ** paste: ctrl-V, shift-ins

If (e.Control = True And e.KeyCode = Keys.V) Or _

(e.Shift And e.KeyCode = Keys.Insert) Then

paste = True

End If

' ** copy selection to clipboard

If copy Then

Clipboard.SetDataObject(fg.Clip)

End If

' ** paste from clipboard

If paste Then

' see of there's text in the clipboard

Dim data As IDataObject = Clipboard.GetDataObject()

If data.GetDataPresent(DataFormats.Text) Then

' there is, so paste it

fg.Select(fg.Row, fg.Col, fg.Rows.Count-1, fg.Cols.Count-1, False)

fg.Clip = CType(data.GetData(DataFormats.Text), String)

fg.Select(fg.Row, fg.Col)

End If

End If

End Sub

This routine handles all standard keyboard commands related to the clipboard: CTRL-X, CTRL-C, or CTRL-INS to copy, and CTRL-V or SHIFT-INS to paste. The real work is done by the Clip property, which takes care of copying and pasting the clipboard text over the current range.

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.


Outline Tutorial

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:

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 Visual Basic 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:

Imports 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:

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

Dim cs As CellStyle = fg.Styles.Add("Data")

cs.BackColor = SystemColors.Control

End Sub

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.

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:

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

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:

Private Sub GetXMLData(ByVal node As Xml.XmlNode, ByVal level As Integer)

' 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

Dim ndName As Xml.XmlNode = node.SelectSingleNode("Name")

If Not (ndName Is Nothing) Then

fg.Rows(row).UserData = ndName.InnerText

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

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:

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

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:

Private Sub fg_BeforeEdit(ByVal sender As Object, _

ByVal e As RowColEventArgs) Handles fg.BeforeEdit

' 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

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:

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

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

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.

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:

Imports System.Data.OleDb

Imports C1.Win.C1FlexGrid

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:

Private Sub Form1_Load(ByVal sender As System.Object, _

ByVal e As EventArgs) Handles MyBase.Load

' set up grid layout/behavior

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

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:

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

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.

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:

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

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.

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:

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

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 Reference

C1FlexGrid Reference

The C1FlexGrid component provides the following properties, events, and methods:

C1FlexGrid Class

CellRange Struct

HitTestInfo class

RowCollection class

ColumnCollection class

Row Class

Column Class

CellStyleCollection class

CellStyle class

CellBorder class

Node class

GridGlyphs Class

GridTree class

GridPrinter Class


C1FlexGrid Class

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 Properties

C1FlexGrid Methods

C1FlexGrid Events

C1FlexGrid Event Handlers

C1FlexGrid Event Arguments


All C1FlexGrid Members

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.
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.
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 drop-down editor.
CursorCell Supported by the .NET Compact Framework. | Gets a CellRange object that contains the anchor cell in the current selection.
DataMember Supported by the .NET Compact Framework. | 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.
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.
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.
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.
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.
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 Supported by the .NET Compact Framework. | 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.
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.
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.
LoadGrid | Loads a grid from a text file.
PrintGrid Supported by the .NET Compact Framework. | Prints the grid, optionally showing a print preview dialog.
RemoveItem | Removes a row from the control.
SaveGrid | Saves a grid to a text 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.
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.
Subtotal | Groups and totals rows based on their contents.

C1FlexGrid Public Events

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.
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 | Fired 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.
BeforeAutoSizeColumn | Fired before a column is automatically resized in response to a double click.
BeforeAutoSizeRow | Fired before a row is automatically resized in response to a double click.
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.
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 | Fired 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.
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.
EnterCell Supported by the .NET Compact Framework. | Fires when a cell becomes active.
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.
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

C1FlexGrid Properties

AllowAddNew Property

AllowDelete Property

AllowDragging Property

AllowEditing Property (C1FlexGrid)

AllowFreezing Property

AllowMerging Property

AllowResizing Property

AllowSorting Property (C1FlexGrid)

AutoResize Property

AutoSearch Property

AutoSearchDelay Property

BottomRow Property

BorderStyle Property

CellButtonImage Property

Clip Property

ClipSeparators Property

Col Property

Cols Property

ColSel Property

ComboList Property

CursorCell Property

DataMember Property

DataSource Property

DragMode Property

DrawMode Property

DropMode Property

DoubleBuffer Property

EditMask Property (C1FlexGrid)

Editor Property

EditOptions Property

ExtendLastCol Property

FocusRect Property

GetCellCheck Property

Glyphs Property

HighLight Property

Item Property

KeyActionEnter Property

KeyActionTab Property

LeftCol Property

MouseCol Property

MouseRow Property

PrintParameters Property

Redraw Property

RightCol Property

Row Property

Rows Property

RowSel Property

ScrollBars Property

ScrollPosition Property

ScrollTrack Property

ScrollTips Property

ScrollTipText Property

Selection Property

SelectionMode Property

SetCellCheck Property

ShowButtons Property

ShowCursor Property

ShowErrors Property

Styles Property

SubTotalPosition Property

TopRow Property

Tree Property


AllowAddNew Property

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

[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:

flex.AllowAddNew = true;

flex.Rows.Count = 10;

Console.WriteLine(_flex.Rows.Count);

This will print out "11" (10 data rows plus the new row template).

See Also

C1FlexGrid Class


AllowDelete Property

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.

See Also

C1FlexGrid Class


AllowDragging Property

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.

Remarks

You can prevent specific rows and columns from being dragged by setting their AllowDragging property to false. For example:

flex.AllowDragging = AllowDraggingEnum.Columns;

flex.Cols[2].AllowDragging = false;

See Also

C1FlexGrid Class

C1FlexGridClassic Class


AllowEditing Property (C1FlexGrid)

AllowEditing Property (C1FlexGrid)

Previous Next

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:

flex.AllowEditing = true;

flex.Cols[2].AllowEditing = false; // prevent editing column 2

For more details and examples on cell editing, see Editing Cells.

See Also

C1FlexGrid Class

C1FlexGridClassic Class


AllowFreezing Property

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

[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


AllowMerging Property

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.

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:

flex.AllowMerging = AllowMergingEnum.Free;

flex.Cols[1].AllowMerging = true; // merge values in column 1

See Also

C1FlexGrid Class

C1FlexGridClassic Class


AllowResizing Property

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.

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

C1FlexGridClassic Class


AllowSorting Property (C1FlexGrid)

AllowSorting Property (C1FlexGrid)

Previous Next

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.

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

C1FlexGridClassic Class


AutoResize Property

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


AutoSearch Property

AutoSearch Property

Specifies whether the grid should move the cursor searching for entries as the user types.

Syntax

[VB]

Public AutoSearch As AutoSearchEnum

[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


AutoSearchDelay Property

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


BottomRow Property

BottomRow Property

Returns the last row visible on the grid.

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


BorderStyle Property

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 one-pixel wide.

See Also

C1FlexGrid Class


CellButtonImage Property

CellButtonImage Property

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.

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

C1FlexGridClassic Class


Clip Property

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.

The example below puts text into a selected area two rows high and two columns wide.

// build clip string

string s = "1st" + "\t" + "a" + "\n" + "2nd" + "\t" + "b";

// paste it over current selection

flex.Clip = s;

You may also retrieve or set a clip string for an arbitrary (not necessarily selected) range using CellRange objects. For example:

// build clip string

CellRange rg = flex.GetCellRange(1,1,10,10);

MessageBox.Show(rg.Text);

See Also

C1FlexGrid Class


ClipSeparators Property

ClipSeparators Property

Gets or sets the characters used as row and column separators in clip strings.

Syntax

[VB]

Public ClipSeparators As String

[C#]

public string ClipSeparators {get; set;}

[Delphi]

property ClipSeparators: string;

Remarks

See the Clip property.

See Also

C1FlexGrid Class


Col Property

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


Cols Property

Cols Property

Gets the collection of columns in the grid.

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


ColSel Property

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 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:

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]);

See Also

C1FlexGrid Class


ComboList Property

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.

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:

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:

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:

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:

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 BeforeEditevent and assigns a value to the ComboList property so that the grid displays buttons on every other row.

private void _flex_BeforeEdit(object sender, RowColEventArgs e)

{

_flex.ComboList = (e.Row % 2 == 0)? "..." : "";

}

For more details and examples on cell editing, see Editing Cells.

See Also

C1FlexGrid Class


CursorCell Property

CursorCell Property

Gets a CellRange object that contains the cell at coordinates Row, Col.

Syntax

[VB]

Public CursorCell As CellRange

[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


DataMember Property

DataMember Property

Gets or sets the specific list in a DataSource object that the grid should display.

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


DataSource Property

DataSource Property

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.

Example

This code binds the grid to an ADO.NET data source:

// replace with actual connection string

string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";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];

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

// 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);

}

}

See Also

C1FlexGrid Class


DragMode Property

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.

See Also

DropMode Property

C1FlexGrid Class


DrawMode Property

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


DropMode Property

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.

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


DoubleBuffer Property

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

[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

C1FlexGridBase


EditMask Property (C1FlexGrid)

EditMask Property (C1FlexGrid)

Previous Next

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.

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:

' 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;*";

For more details and examples on cell editing, see Editing Cells.

See Also

C1FlexGrid Class


Editor Property

Editor Property

Gets the cell editor that is currently active.

Syntax

[VB]

Public Editor As Control

[C#]

public Control Editor {get;}

[Delphi]

property Editor: Control;

Remarks

The Editor property returns a reference to the cell editor that is currently active. This may be one a TextBox, a ComboBox, 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.

Example

This code prevents the user from scrolling the grid while a cell is being edited:

private void flex_ BeforeScroll(object sender, RangeEventArgs e)

{

if (flex.Editor != null)

e.Cancel = true;

}

See Also

C1FlexGrid Class


EditOptions Property

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;

See Also

C1FlexGrid Class


ExtendLastCol Property

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.

See Also

C1FlexGrid Class


FocusRect Property

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


GetCellCheck Property

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


Glyphs Property

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

_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


HighLight Property

HighLight Property

Specifies when to highlight the selected cells.

Syntax

[VB]

Public HighLight As HighLightEnum

[C#]

public HighLightEnum HighLight {get; set;}

[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


Item Property

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.

Example

// 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());

See Also

C1FlexGrid Class

Column Class

Row Class


KeyActionEnter Property

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.

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

C1FlexGridClassic Class


KeyActionTab Property

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.

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.

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;

}

See Also

C1FlexGrid Class

C1FlexGridClassic Class


LeftCol Property

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


MouseCol Property

MouseCol Property

Gets the index of the column under the mouse.

Syntax

[VB]

Public MouseCol As Integer

[C#]

public int MouseCol {get;}

[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:

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

}

See Also

C1FlexGrid Class


MouseRow Property

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


PrintParameters Property

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


Redraw Property

Redraw Property

Specifies whether the grid should paint its contents.

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.

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

}

See Also

C1FlexGrid Class

C1FlexGridClassic Class


RightCol Property

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


Row Property

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.

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


Rows Property

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

C1FlexGridClassic Class


RowSel Property

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

[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


ScrollBars Property

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.

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:

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;

}

See Also

C1FlexGrid Class


ScrollPosition Property

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

// 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);

}

}

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


ScrollTrack Property

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


ScrollTips Property

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

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

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;

}

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:

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

}

See Also

C1FlexGrid Class


ScrollTipText Property

ScrollTipText Property

Gets or sets the tooltip text displayed as the user scrolls vertically.

Syntax

[VB]

Public ScrollTipText As String

[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


Selection Property

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.

Example

// 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


SelectionMode Property

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


SetCellCheck Property

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


ShowButtons Property

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


ShowCursor Property

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


ShowErrors Property

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:

this._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


Styles Property

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


SubTotalPosition Property

SubTotalPosition Property

Specifies whether the Subtotal method should add node rows above or below the data being summarized.

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


TopRow Property

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.

See Also

C1FlexGrid Class


Tree Property

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


C1FlexGrid Methods

C1FlexGrid Methods

AddItem Method

Aggregate Method

AutoSizeCol Method

AutoSizeCols Method

AutoSizeRow Method

AutoSizeRows Method

Clear Method (C1FlexGrid)

CreateImage Method

DrawCell Method

FindRow Method

FinishEditing Method

GetCellCheck Method

GetCellImage Method

GetCellRange Method

GetCellRect Method

GetCellStyle Method

GetCellStyleDisplay Method

GetData Method

GetDataDisplay Method

GetMergedRange Method (C1FlexGrid)

HitTest Method

Invalidate Method

LoadGrid Method

PrintGrid Method

RemoveItem Method (C1FlexGrid)

SaveGrid Method

Select Method

SetCellImage Method

SetCellStyle Method

SetCellCheck Method

SetData Method

ShowCell Method

ShowSortAt Method

Sort Method

StartEditing Method

Subtotal Method


AddItem Method

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 )

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

// 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);

For more examples, see the Redraw property and the Saving and Loading Grids topic.

See Also

C1FlexGrid Class


Aggregate Method

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)

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

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

}

See Also

C1FlexGrid Class


AutoSizeCol Method

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


AutoSizeCols Method

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.

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


AutoSizeRow Method

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


AutoSizeRows Method

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)

[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


Clear Method (C1FlexGrid)

Clear Method (C1FlexGrid)

Previous Next

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 )

[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


CreateImage Method

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

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:

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

}

See Also

C1FlexGrid Class


DrawCell Method

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.

See Also

OwnerDrawCellEventArgs Class


FindRow Method

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

C1FlexGridClassic Class


FinishEditing Method

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


GetCellCheck Method

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 )

[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:

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

fg.SetCellCheck(3, 3, CheckEnum.Unchecked) ' boolean

fg.SetCellCheck(4, 3, CheckEnum.TSUnchecked) ' tri-state

See Also

C1FlexGrid Class


GetCellImage Method

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


GetCellRange Method

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 tCellRange GetCellRange ( int row , int col )

[Delphi]

function GetCellRange(row: integer; col: Integer): CellRange;

function GetCellRange(row1: Integer; col1: Integer; row2: Integer; col2: Integer): CellRange;

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:

CellRange rg = flex.GetCellRange(5, 5, 20, 8);

rg.Style = flex.Styles["MyStyle"];

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:

// this does not compile!!!

flex.GetCellRange(5, 5, 20, 8).Style = flex.Styles["MyStyle"];

See Also

C1FlexGrid Class


GetCellRect Method

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

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


GetCellStyle Method

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.

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


GetCellStyleDisplay Method

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


GetData Method

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

[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:

Dim foo As Object

foo = fg.GetData(row, col) ' is equivalent to

foo = fg(row, col)

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


GetDataDisplay Method

GetDataDisplay Method

Returns the data in a grid cell, formatted as a string.

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


GetMergedRange Method (C1FlexGrid)

GetMergedRange Method (C1FlexGrid)

Previous Next

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;

functiong 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


HitTest Method

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 HitTestInfoHitTest ( 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.

For example, the code below shows hit test information whenever the user clicks the mouse:

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

}

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:

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

}

See Also

C1FlexGrid Class


Invalidate Method

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.

Remarks

This method is rarely used by the programmer, since the grid automatically performs invalidation as needed.

See Also

C1FlexGrid Class

Column Class

Row Class


LoadGrid Method

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, fixedCells As Boolean)

Public Sub LoadGrid(fileName As String, format As FileFormatEnum, fixedCells As Boolean, encoding As Encoding)

[C#]

public void LoadGrid (String fileName , FileFormatEnum format )

public void LoadGrid (String fileName , FileFormatEnum format , Boolean fixedCells )

public void LoadGrid (String fileName , FileFormatEnum format , Boolean fixedCells , Encoding encoding )

[Delphi]

procedure LoadGrid(fileName: string; format: FileFormatEnum);

procedure LoadGrid(fileName: string; format: FileFormatEnum; fixedCells: Boolean);

procedure LoadGrid(fileName: string; format: FileFormatEnum; fixedCells: Boolean; 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, etc.).

fixedCells

If this parameter is set to false (the default), then the values read from the file are stored in the scrollable area of the grid (fixed cells are not modified).

If this parameter is set to true, then the values read from the file are stored in the entire grid (fixed and scrollable cells).

encoding

A System.Text.Encoding object that determines how to decode the text in the file (e.g. ASCII, Unicode, UTF-7, UTF-8).

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.

When loading text files, rows and columns are added to the grid if needed to accommodate the file contents.

See Also

C1FlexGrid Class


PrintGrid Method

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 )

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.

flex.PrintGrid("My Grid", PrintGridFlags.FitPageWidth,

"", "\tPage {0} of {1}");

See Also

C1FlexGrid Class

C1FlexGridClassic Class


RemoveItem Method (C1FlexGrid)

RemoveItem Method (C1FlexGrid)

Previous Next

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


SaveGrid Method

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, fixedCells As Boolean)

Public Sub SaveGrid(fileName As String, format As FileFormatEnum, fixedCells As Boolean, encoding As Encoding)

[C#]

public void SaveGrid (String fileName , FileFormatEnum format )

public void SaveGrid (String fileName , FileFormatEnum format , Boolean fixedCells )

public void SaveGrid (String fileName , FileFormatEnum format ,Boolean fixedCells , Encoding encoding )

[Delphi]

procedure SaveGrid(fileName: string; format: FileFormatEnum);

procedure SaveGrid(fileName: string; format: FileFormatEnum; fixedCells: Boolean);

procedure SaveGrid(fileName: string; format: FileFormatEnum; fixedCells: Boolean; 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, etc).

fixedCells

If this parameter is set to false (the default), then only the scrollable cells are saved to the file (fixed cells are not saved).

If this parameter is set to true, then the entire grid is saved to the file (fixed and scrollable cells).

encoding

A System.Text.Encoding object that determines how to decode the text in the file (e.g. ASCII, Unicode, UTF-7, UTF-8). The default value is Encoding.ASCII.

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.

See Also

C1FlexGrid Class


Select Method

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.

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


SetCellImage Method

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


SetCellStyle Method

SetCellStyle Method

Assigns a custom CellStyle to a cell.

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:

Dim rg As CellRange = fg.GetCellRange(3, 3, 10, 10)

rg.Data = Nothing

rg.Style = fg.Styles("MyRangeStyle")

See Also

C1FlexGrid Class


SetCellCheck Method

SetCellCheck Method

Sets the type and state of the checkbox that is displayed in a cell.

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:

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

fg.SetCellCheck(3, 3, CheckEnum.Unchecked) ' boolean

fg.SetCellCheck(4, 3, CheckEnum.TSUnchecked) ' tri-state

See Also

C1FlexGrid Class


SetData Method

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

fg.SetData(row, col, 12) ' is equivalent to

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


ShowCell Method

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


ShowSortAt Method

ShowSortAt Method

Shows a sorting glyph at a specific column.

Syntax

[VB]

Public Sub ShowSortAt(order As SortFlags, col As Integer)

[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


Sort Method

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

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.

See Also

C1FlexGrid Class


StartEditing Method

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

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)

}

See Also

C1FlexGrid Class


Subtotal Method

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

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;

}

Note that you can display several aggregates in each subtotal row (one per column). The Subtotalmethod 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:

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

See Also

C1FlexGrid Class


C1FlexGrid Events

C1FlexGrid Events

AfterCollapse Event

AfterDataRefresh Event

AfterDragColumn Event

AfterDragRow Event

AfterEdit Event

AfterFreezeColumn Event

AfterFreezeRow Event

AfterResizeColumn Event

AfterResizeRow Event

AfterRowColChange Event

AfterScroll Event

AfterSelChange Event

AfterSort Event

BeforeAutoSizeColumn Event

BeforeAutoSizeRow Event

BeforeCollapse Event

BeforeDragColumn Event

BeforeDragRow Event

BeforeEdit Event

BeforeFreezeColumn Event

BeforeFreezeRow Event

BeforeMouseDown Event

BeforePageBreak Event

BeforeResizeColumn Event

BeforeResizeRow Event

BeforeRowColChange Event

BeforeScroll Event

BeforeScrollTip Event

BeforeSelChange Event

BeforeSort Event

BeginPrint Event

CellButtonClick Event

CellChanged Event

ChangeEdit Event

ComboCloseUp Event

ComboDropDown Event

EndPrint Event

EnterCell Event

GridChanged Event

GridError Event

KeyDownEdit Event

KeyPressEdit Event

KeyUpEdit Event

LeaveCell Event

OwnerDrawCell Event

PrintPage Event

RowColChange Event

SelChange Event

SetupEditor Event

StartEdit Event

ValidateEdit Event


AfterCollapse Event

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.

See Also

C1FlexGrid Class


AfterDataRefresh Event

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 data-dependent 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


AfterDragColumn Event

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


AfterDragRow Event

AfterDragRow Event

Fires after the user drags a row using the mouse.

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


AfterEdit Event

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.

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


AfterFreezeColumn Event

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


AfterFreezeRow Event

AfterFreezeRow Event

Fired after the user freezes rows with the mouse.

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


AfterResizeColumn Event

AfterResizeColumn Event

Fired after a column is resized by the user.

Syntax

[VB]

Public Event AfterResizeColumn(sender As Object, e As RowColEventArgs) As RowColEventHandler

Public Event AfterResizeColumn 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.

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


AfterResizeRow Event

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


AfterRowColChange Event

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

[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


AfterScroll Event

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

// 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);

}

}

See Also

C1FlexGrid Class


AfterSelChange Event

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


AfterSort Event

AfterSort Event

Fired after a column is sorted when the user clicks on a column header.

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


BeforeAutoSizeColumn Event

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


BeforeAutoSizeRow Event

BeforeAutoSizeRow Event

Fired before a row is resized in response to a double click.

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


BeforeCollapse Event

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

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;

}

}

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:

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

See Also

C1FlexGrid Class


BeforeDragColumn Event

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;

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


BeforeDragRow Event

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.

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


BeforeEdit Event

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

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;

}

See Also

C1FlexGrid Class


BeforeFreezeColumn Event

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.

Remarks

See the AllowFreezing Property.

See Also

C1FlexGrid Class


BeforeFreezeRow Event

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.

See Also

C1FlexGrid Class


BeforeMouseDown Event

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

[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:

private void flex_BeforeMouseDown(object sender, BeforeMouseDownEventArgs e)

{
if (flex.Editor != null)
e.Cancel = true;
}

See Also

C1FlexGrid Class


BeforePageBreak Event

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.

private void flex_BeforePageBreak(object sender, RowColEventArgs e)

{

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

}

See Also

C1FlexGrid Class


BeforeResizeColumn Event

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.

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


BeforeResizeRow Event

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


BeforeRowColChange Event

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

[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


BeforeScroll Event

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.

See Also

C1FlexGrid Class


BeforeScrollTip Event

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:

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;

}

See Also

C1FlexGrid Class


BeforeSelChange Event

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


BeforeSort Event

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


BeginPrint Event

BeginPrint Event

Fires when the grid starts printing.

Syntax

[VB]

Public Event BeginPrint(sender As Object, e As PrintEventArgs) As PrintEventHandler

[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


CellButtonClick Event

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

[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


CellChanged Event

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

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


ChangeEdit Event

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:

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

}

}

See Also

C1FlexGrid Class


ComboCloseUp Event

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.

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


ComboDropDown Event

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


EndPrint Event

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

[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


EnterCell Event

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


GridChanged Event

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.

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


GridError Event

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


KeyDownEdit Event

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:

string selText = "";

Control ctl = flex.Editor

if (ctl is TextBox) selText = ((TextBox)ctl).SelectedText;

if (ctl is ComboBox) selText = ((ComboBox)ctl).SelectedText;

See Also

C1FlexGrid Class


KeyPressEdit Event

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:

string selText = "";

Control ctl = flex.Editor

if (ctl is TextBox) selText = ((TextBox)ctl).SelectedText;

if (ctl is ComboBox) selText = ((ComboBox)ctl).SelectedText;


KeyUpEdit Event

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

string selText = "";

Control ctl = flex.Editor

if (ctl is TextBox) selText = ((TextBox)ctl).SelectedText;

if (ctl is ComboBox) selText = ((ComboBox)ctl).SelectedText;

See Also

C1FlexGrid Class


LeaveCell Event

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

[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


OwnerDrawCell Event

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.
bool Handled | Gets or sets whether the event has finished drawing the cell.

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

You can 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:

' 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

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:

private void _flex_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)

{

// 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);

}

See Also

C1FlexGrid Class


PrintPage Event

PrintPage Event

Fires when the grid finishes printing a page.

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


RowColChange Event

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


SelChange Event

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.


SetupEditor Event

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:

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;

}

And here's a more sophisticated example that uses the SetupEditor event to install event handlers for the editor:

// ** 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);

}

See Also

C1FlexGrid Class


StartEdit Event

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.

See Also

C1FlexGrid Class


ValidateEdit Event

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:

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

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


C1FlexGrid Event Handlers

C1FlexGrid Event Handlers

BeforeMouseDownEventHandler Delegate

DragRowColEventHandler Delegate

GridChangedEventHandler Delegate

GridErrorEventHandler Delegate

KeyEditEventHandler Delegate

KeyPressEditEventHandler Delegate

OwnerDrawCellEventHandler Delegate

PrintEventHandler Delegate

PrintPageEventHandler Delegate

RangeEventHandler Delegate

RowColEventHandler Delegate

SortColEventHandler Delegate

ValidateEditEventHandler Delegate


BeforeMouseDownEventHandler Delegate

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


DragRowColEventHandler Delegate

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.

See Also

AfterDragColumn Event

AfterDragRow Event

BeforeDragColumn Event

BeforeDragRow Event


GridChangedEventHandler Delegate

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


GridErrorEventHandler Delegate

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;

Arguments

Argument | Description
sender | The source of the event.
e | A GridErrorEventArgs object that contains the event data.

See Also

GridError Event


KeyEditEventHandler Delegate

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

KeyUpEdit Event


KeyPressEditEventHandler Delegate

KeyPressEditEventHandler Delegate

Syntax

[VB]

Public Delegate Sub KeyPressEditEventHandler (object sender, KeyPressEditEventArgs e)

[C#]

public sealed delegate KeyPressEditEventHandler : System.MulticastDelegate

[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


OwnerDrawCellEventHandler Delegate

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


PrintEventHandler Delegate

PrintEventHandler Delegate

Syntax

[VB]

Public Delegate Sub PrintEventHandler (object sender, PrintEventArgs e)

[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

EndPrint Event


PrintPageEventHandler Delegate

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


RangeEventHandler Delegate

RangeEventHandler Delegate

Syntax

[VB]

Public Delegate Sub RangeEventHandler (object sender, RangeEventArgs e)

[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

AfterScroll Event

AfterSelChange Event

BeforeRowColChange Event

BeforeScroll Event

BeforeSelChange Event


RowColEventHandler Delegate

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

AfterResizeColumn Event

AfterResizeRow Event

BeforeEdit Event

BeforePageBreak Event

BeforeResizeColumn Event

BeforeResizeRow Event

BeforeScrollTip Event

CellButtonClick Event

ComboCloseUp Event

ComboDropDown Event

SetupEditor Event

StartEdit Event


SortColEventHandler Delegate

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

BeforeSort Event


ValidateEditEventHandler Delegate

ValidateEditEventHandler Delegate

Syntax

[VB]

Public Delegate Sub ValidateEditEventHandler (object sender, ValidateEditEventArgs e)

[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


C1FlexGrid Event Arguments

C1FlexGrid Event Arguments

BeforeMouseDownEventArgs Class

DragRowColEventArgs Class

GridChangedEventArgs Class

GridErrorEventArgs Class

KeyEditEventArgs Class

KeyPressEditEventArgs Class

OwnerDrawCellEventArgs Class

RangeEventArgs Class

RowColEventArgs Class

SortColEventArgs Class

ValidateEditEventArgs Class


BeforeMouseDownEventArgs Class

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


DragRowColEventArgs Class

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


GridChangedEventArgs Class

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.

See Also

GridChangedEventHandler Delegate


GridErrorEventArgs Class

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


KeyEditEventArgs Class

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


KeyPressEditEventArgs Class

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


OwnerDrawCellEventArgs Class

OwnerDrawCellEventArgs Class

Syntax

[VB]

Public Class OwnerDrawCellEventArgs

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

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


RangeEventArgs Class

RangeEventArgs Class

Syntax

[VB]

Public Class RangeEventArgs

[C#]

public class RangeEventArgs : EventArgs

[Delphi]

type RangeEventArgs: class(EventArgs);

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


RowColEventArgs Class

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


SortColEventArgs Class

SortColEventArgs Class

Syntax

[VB]

Public Class SortColEventArgs

[C#]

public class SortColEventArgs : EventArgs

[Delphi]

type SortColEventArgs: class(EventArgs);

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


ValidateEditEventArgs Class

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


CellRange Struct

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.

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

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

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

CellRange Properties

BottomRow Property (CellRange)

CheckBox Property

Clip Property (CellRange)

Data Property (CellRange)

DataDisplay Property

Image Property

IsSingleCell Property

IsValid Property

LeftCol Property (CellRange)

r1,c1,r2,c2 Property

RightCol Property (CellRange)

Style Property (CellRange)

StyleDisplay Property (CellRange)

StyleNew Property (CellRange)

TopRow Property (CellRange)

UserData Property (CellRange)


BottomRow Property (CellRange)

BottomRow Property (CellRange)

Previous Next

Returns the index of the bottom row in this range (greater of r1 and r2).

Syntax

[VB]

Public BottomRow As Integer

[C#]

public int BottomRow {get;}

[Delphi]

property BottomRow: Integer;

See Also

CellRange Struct


CheckBox Property

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


Clip Property (CellRange)

Clip Property (CellRange)

Previous Next

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;

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


Data Property (CellRange)

Data Property (CellRange)

Previous Next

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


DataDisplay Property

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


Image Property

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


IsSingleCell Property

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


IsValid Property

IsValid Property

Determines whether this CellRange object describes a valid range.

Syntax

[VB]

Public IsValid As Boolean

[C#]

public bool IsValid {get; }

[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


LeftCol Property (CellRange)

LeftCol Property (CellRange)

Previous Next

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


r1,c1,r2,c2 Property

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


RightCol Property (CellRange)

RightCol Property (CellRange)

Previous Next

Returns the index of the right column in the range (greater of c1 and c2).

Syntax

[VB]

Public RightCol As Integer

[C#]

public int RightCol {get;}

[Delphi]

property RightCol: Integer;

See Also

CellRange Struct


Style Property (CellRange)

Style Property (CellRange)

Previous Next

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


StyleDisplay Property (CellRange)

StyleDisplay Property (CellRange)

Previous Next

Gets the cell style used to display the range.

Syntax

[VB]

Public StyleDisplay As CellStyle

[C#]

public CellStyle StyleDisplay {get;}

[Delphi]

property StyleDisplay: CellStyle;

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


StyleNew Property (CellRange)

StyleNew Property (CellRange)

Previous Next

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


TopRow Property (CellRange)

TopRow Property (CellRange)

Previous Next

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


UserData Property (CellRange)

UserData Property (CellRange)

Previous Next

Gets or sets user data associated with cells in the range.

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


CellRange Methods

CellRange Methods

Contains Method (CellRange)

ContainsCol Method

ContainsRow Method

Normalize Method


Contains Method (CellRange)

Contains Method (CellRange)

Previous Next

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


ContainsCol Method

ContainsCol Method

Determines if the specified column is contained in this CellRange.

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


ContainsRow Method

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


Normalize Method

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


HitTestInfo class

HitTestInfo class


All HitTestInfo Members

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

HitTestInfo Properties

Column Property (HitTestInfo)

Row Property (HitTestInfo)

Type Property (HitTestInfo)

X Property (HitTestInfo)

Y Property (HitTestInfo)


Column Property (HitTestInfo)

Column Property (HitTestInfo)

Previous Next

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


Row Property (HitTestInfo)

Row Property (HitTestInfo)

Previous Next

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


Type Property (HitTestInfo)

Type Property (HitTestInfo)

Previous Next

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


X Property (HitTestInfo)

X Property (HitTestInfo)

Previous Next

Gets the x coordinate of the point being tested.

Syntax

[VB]

Public X As Integer

[C#]

public int X {get;}

[Delphi]

property X: Integer;

See Also

HitTestInfo class


Y Property (HitTestInfo)

Y Property (HitTestInfo)

Previous Next

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


RowCollection class

RowCollection class

All RowCollection Members

RowCollection Properties

RowCollection Methods


All RowCollection Members

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.

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

RowCollection Properties

Count Property (RowCollection)

DefaultSize Property (RowCollection)

Fixed Property (RowCollection)

Frozen Property (RowCollection)

Item Property (RowCollection)

MaxSize Property (RowCollection)

MinSize Property (RowCollection)

Selected Property (RowCollection)


Count Property (RowCollection)

Count Property (RowCollection)

Previous Next

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


DefaultSize Property (RowCollection)

DefaultSize Property (RowCollection)

Previous Next

Gets or sets the default height for the rows 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 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


Fixed Property (RowCollection)

Fixed Property (RowCollection)

Previous Next

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


Frozen Property (RowCollection)

Frozen Property (RowCollection)

Previous Next

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;

Remarks

Use the AllowFreezing property to determine whether the user can freeze rows with the mouse.

See Also

RowCollection class


Item Property (RowCollection)

Item Property (RowCollection)

Previous Next

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


MaxSize Property (RowCollection)

MaxSize Property (RowCollection)

Previous Next

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


MinSize Property (RowCollection)

MinSize Property (RowCollection)

Previous Next

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


Selected Property (RowCollection)

Selected Property (RowCollection)

Previous Next

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:

fg.SelectionMode = SelectionModeEnum.ListBox;

For Each (Row row in fg.Rows.Selection)

Console.WriteLine(row.Index);

See Also

RowCollection class


RowCollection Methods

RowCollection Methods

Add Method (RowCollection)

Contains Method (RowCollection)

Insert Method (RowCollection)

InsertNode Method

InsertRange Method (RowCollection)

Move Method (RowCollection)

MoveRange Method (RowCollection)

Remove Method (RowCollection)

RemoveRange Method (RowCollection)


Add Method (RowCollection)

Add Method (RowCollection)

Previous Next

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


Contains Method (RowCollection)

Contains Method (RowCollection)

Previous Next

Determines whether the collection contains a given row.

Syntax

[VB]

Public Function Contains(item As RowCol) As Boolean

[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


Insert Method (RowCollection)

Insert Method (RowCollection)

Previous Next

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


InsertNode Method

InsertNode Method

Inserts a new node row in the row collection.

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


InsertRange Method (RowCollection)

InsertRange Method (RowCollection)

Previous Next

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


Move Method (RowCollection)

Move Method (RowCollection)

Previous Next

Moves a row 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 row that will be moved.
newindex | The new index for the row.

See Also

RowCollection class


MoveRange Method (RowCollection)

MoveRange Method (RowCollection)

Previous Next

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


Remove Method (RowCollection)

Remove Method (RowCollection)

Previous Next

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


RemoveRange Method (RowCollection)

RemoveRange Method (RowCollection)

Previous Next

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


ColumnCollection class

ColumnCollection class

All ColumnCollection Members

ColumnCollection Properties

ColumnCollection Methods


All ColumnCollection Members

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.


ColumnCollection Properties

ColumnCollection Properties

Count Property (ColumnCollection)

DefaultSize Property (ColumnCollection)

Fixed Property (ColumnCollection)

Frozen Property (ColumnCollection)

Item Property (ColumnCollection)

MaxSize Property (ColumnCollection)

MinSize Property (ColumnCollection)

Selected Property


Count Property (ColumnCollection)

Count Property (ColumnCollection)

Previous Next

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


DefaultSize Property (ColumnCollection)

DefaultSize Property (ColumnCollection)

Previous Next

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


Fixed Property (ColumnCollection)

Fixed Property (ColumnCollection)

Previous Next

Gets or sets the number of fixed columns in the collection.

Syntax

[VB]

Public Fixed As Integer

[C#]

public int Fixed {get; set;}

[Delphi]

property Fixed: Integer;

See Also

ColumnCollection class


Frozen Property (ColumnCollection)

Frozen Property (ColumnCollection)

Previous Next

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


Item Property (ColumnCollection)

Item Property (ColumnCollection)

Previous Next

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;

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:

// 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";

See Also

ColumnCollection class


MaxSize Property (ColumnCollection)

MaxSize Property (ColumnCollection)

Previous Next

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.

See Also

ColumnCollection class


MinSize Property (ColumnCollection)

MinSize Property (ColumnCollection)

Previous Next

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


Selected Property

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


ColumnCollection Methods

ColumnCollection Methods

Add Method (ColumnCollection)

Contains Method (ColumnCollection)

Insert Method (ColumnCollection)

InsertRange Method (ColumnCollection)

Move Method (ColumnCollection)

MoveRange Method (ColumnCollection)

Remove Method (ColumnCollection)

RemoveRange Method (ColumnCollection)


Add Method (ColumnCollection)

Add Method (ColumnCollection)

Previous Next

Adds a column to the collection.

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


Contains Method (ColumnCollection)

Contains Method (ColumnCollection)

Previous Next

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


Insert Method (ColumnCollection)

Insert Method (ColumnCollection)

Previous Next

Adds a column to the collection at a specified position.

Syntax

[VB]

ublic Function Insert(index As Integer) As Column

[C#]

public Column Insert ( int index )

[Delphi]

function Contains(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


InsertRange Method (ColumnCollection)

InsertRange Method (ColumnCollection)

Previous Next

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


Move Method (ColumnCollection)

Move Method (ColumnCollection)

Previous Next

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


MoveRange Method (ColumnCollection)

MoveRange Method (ColumnCollection)

Previous Next

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


Remove Method (ColumnCollection)

Remove Method (ColumnCollection)

Previous Next

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


RemoveRange Method (ColumnCollection)

RemoveRange Method (ColumnCollection)

Previous Next

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


Row Class

Row Class

All Row Members

Row Properties

Row Methods


All Row Members

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.
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.
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.
Index | Gets the index of this row in the Rows collection.
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.
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

Row Properties

AllowDragging Property (Row)

AllowEditing Property (Row)

AllowMerging Property (Row)

AllowResizing Property (Row)

Bottom Property

Caption Property (Row)

DataIndex Property (Row)

Height Property

HeightDisplay Property

IsNew Property

IsNode Property

Index Property (Row)

Node Property

SafeIndex Property (Row)

Selected Property (Row)

Style Property (Row)

StyleDisplay Property (Row)

StyleNew Property (Row)

Top Property

UserData Property (Row)

Visible Property (Row)


AllowDragging Property (Row)

AllowDragging Property (Row)

Previous Next

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


AllowEditing Property (Row)

AllowEditing Property (Row)

Previous Next

Gets or sets whether cells on this row 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

Row Class


AllowMerging Property (Row)

AllowMerging Property (Row)

Previous Next

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


AllowResizing Property (Row)

AllowResizing Property (Row)

Previous Next

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;

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


Bottom Property

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


Caption Property (Row)

Caption Property (Row)

Previous Next

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


DataIndex Property (Row)

DataIndex Property (Row)

Previous Next

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

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.

Example

The code below uses the DataIndex property to retrieve the DataRowView object used as a data source for the currently selected grid row:

// get current row's DataIndex

//(skip nodes and fixed rows)

int index = (_flex.Row > 0)

? _flex.Rows[_flex.Row].DataIndex

: -1;

// if positive, get underlying DataRow

// (assumes DataSource is a DataTable object)

if (index > -1)

{

CurrencyManager cm =

BindingContext[_flex.DataSource, _flex.DataMember]

as CurrencyManager;

DataRowView drv = cm.List[index] as DataRowView;

Console.WriteLine("Row {0}, State {1}",

index, drv.Row.RowState);

}

This code causes the grid to display the following:

Row | Display | DataIndex
0 | (none) | -1
1 | aaa | 0
2 | bbbb | 1
3 | cccc | 2

If you then apply a filter to the DataTable's default view, the grid will reflect the change:

private void button1_Click(object sender, System.EventArgs e)

{

dt.DefaultView.RowFilter = "string > 'b'";

}

Row | Display | DataIndex
0 | (none) | -1
1 | bbbb | 0
2 | cccc | 1

The DataIndex:Row of the row that contains the string "bbbb" changed from 1 to 0. Although the DataRow object in table dt still has the same index as before, the grid is getting its data from the DataView object, which provides a list of sorted and filtered row objects. In this case, you could write:

int dataIndex = grid.Rows[1].DataIndex;

// get the DataRowView object supplying the data

DataRowView drv = dt.DefaultView[dataIndex];

// get the underlying DataRow object supplying the data

DataRow dr = drv.Row;

// get the wrong row if the data is sorted or filtered

DataRow drWRONG = dt.Rows[dataIndex];

NOTE:

Returns –1 for fixed and node rows.

See Also

Row Class

Index Property (Row)

SafeIndex Property (Row)


Height Property

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

[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


HeightDisplay Property

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


IsNew Property

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


IsNode Property

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.

See Also

Row Class


Index Property (Row)

Index Property (Row)

Previous Next

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.

Example

Row row = _flex.Rows[12];

Console.WriteLine("*** Row index is {0}", row.Index);

*** Row index is 12

See Also

Row Class


Node Property

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


SafeIndex Property (Row)

SafeIndex Property (Row)

Previous Next

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


Selected Property (Row)

Selected Property (Row)

Previous Next

Gets or sets whether this row is selected.

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


Style Property (Row)

Style Property (Row)

Previous Next

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


StyleDisplay Property (Row)

StyleDisplay Property (Row)

Previous Next

Gets the style used to display this row.

Syntax

[VB]

Public StyleDisplay As CellStyle

[C#]

public CellStyle StyleDisplay {get;}

[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


StyleNew Property (Row)

StyleNew Property (Row)

Previous Next

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


Top Property

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.

To retrieve the size and position of a cell, use the GetCellRect method.

See Also

Row Class


UserData Property (Row)

UserData Property (Row)

Previous Next

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:

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;

}

Remarks

The UserData value is not used internally by the grid. It is reserved for data additional that you may want to associate with a row.

See Also

Row Class


Visible Property (Row)

Visible Property (Row)

Previous Next

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


Row Methods

Row Methods


Clear Method (Row)

Clear Method (Row)

Previous Next

Clears this row.

Syntax

[VB]

Public Sub Clear(clearFlags As ClearFlags)

[C#]

public void Clear (ClearFlags clearFlags )

[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 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


Move Method (Row)

Move Method (Row)

Previous Next

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


Column Class

Column Class

All Column Members

Column Properties

Column Methods


All Column Members

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.
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 drop-down 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.
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. | Determines how images are aligned within cells on 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.
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

Column Properties

AllowDragging Property (Column)

AllowEditing Property (Column)

AllowMerging Property (Column)

AllowResizing Property (Column)

AllowSorting Property (Column)

Caption Property

ComboList Property (Column)

DataIndex Property (Column)

DataMap Property

DataType Property

EditMask Property (Column)

Format Property

ImageAlign Property (Column)

ImageAndText Property

ImageMap Property (Column)

Index Property (Column)

Left Property

Name Property (Column)

Right Property

SafeIndex Property (Column)

Selected Property (Column)

Sort Property (Column)

Style Property (Column)

StyleDisplay Property (Column)

StyleFixed Property

StyleFixedDisplay Property

StyleFixedNew Property

StyleNew Property (Column)

TextAlign Property (Column)

TextAlignFixed Property

UserData Property (Column)

Visible Property (Column)

Width Property (Column)

WidthDisplay Property


AllowDragging Property (Column)

AllowDragging Property (Column)

Previous Next

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.

See Also

Column Class


AllowEditing Property (Column)

AllowEditing Property (Column)

Previous Next

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


AllowMerging Property (Column)

AllowMerging Property (Column)

Previous Next

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


AllowResizing Property (Column)

AllowResizing Property (Column)

Previous Next

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


AllowSorting Property (Column)

AllowSorting Property (Column)

Previous Next

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


Caption Property

Caption Property

Gets or sets the text of the first fixed cell in the column.

Syntax

[VB]

Public Caption As String

[C#]

public string Caption {get; set;}

[Delphi]

property Caption: string;

See Also

Column Class


ComboList Property (Column)

ComboList Property (Column)

Previous Next

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

See Also

Column Class


DataIndex Property (Column)

DataIndex Property (Column)

Previous Next

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;

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


DataMap Property

DataMap Property

Gets or sets the data map used to translate data values into display values for this column.

Syntax

[VB]

Public DataMap As IDictionary

[C#]

public IDictionary DataMap {get; set;}

[Delphi]

property DataMap: IDictionary;

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:

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;

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


DataType Property

DataType Property

Gets or sets the data type for this column.

Syntax

[VB]

Public DataType As Type

[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:

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

if (ctl != null)

ctl.ShowUpDown = true;

}

}

See Also

Column Class


EditMask Property (Column)

EditMask Property (Column)

Previous Next

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

See Also

Column Class


Format Property

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.

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.

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


ImageAlign Property (Column)

ImageAlign Property (Column)

Previous Next

Determines how images are aligned within cells on this column.

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:

flex.Cols[1].ImageAlign = ImageAlignEnum.RightTop;

Console.WriteLine(flex.Cols[1].Style.ImageAlign);

ImageAlignEnum.RightTop

See Also

Column Class


ImageAndText Property

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

ImageMap Property (Column)


ImageMap Property (Column)

ImageMap Property (Column)

Previous Next

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:

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;

See Also

Column Class


Index Property (Column)

Index Property (Column)

Previous Next

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

SafeIndex Property (Column)


Left Property

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


Name Property (Column)

Name Property (Column)

Previous Next

Gets or sets the name of this column. The name can be used as an index in the Cols property indexer.

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


Right Property

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


SafeIndex Property (Column)

SafeIndex Property (Column)

Previous Next

Gets the index of this column in the Column 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

Column Class


Selected Property (Column)

Selected Property (Column)

Previous Next

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


Sort Property (Column)

Sort Property (Column)

Previous Next

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.

See Also

Column Class

Sort Property (C1FlexGridClassic)


Style Property (Column)

Style Property (Column)

Previous Next

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


StyleDisplay Property (Column)

StyleDisplay Property (Column)

Previous Next

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


StyleFixed Property

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;

Remarks

See the Styles property

See Also

Column Class


StyleFixedDisplay Property

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


StyleFixedNew Property

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

[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


StyleNew Property (Column)

StyleNew Property (Column)

Previous Next

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


TextAlign Property (Column)

TextAlign Property (Column)

Previous Next

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;

Remarks

This property maps to the CellStyle associated with the column. For example:

flex.Cols[1].TextAlign = TextAlignEnum.RightTop;

Console.WriteLine(flex.Cols[1].Style.TextAlign);

TextAlignEnum.RightTop

See Also

Column Class


TextAlignFixed Property

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:

flex.Cols[1].TextAlign = TextAlignEnum.RightTop;

Console.WriteLine(flex.Cols[1].StyleFixed.TextAlign);

TextAlignEnum.RightTop

See Also

Column Class


UserData Property (Column)

UserData Property (Column)

Previous Next

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 data additional that you may want to associate with a column.

See Also

Column Class


Visible Property (Column)

Visible Property (Column)

Previous Next

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


Width Property (Column)

Width Property (Column)

Previous Next

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

[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


WidthDisplay Property

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


Column Methods

Column Methods


Clear Method (Column)

Clear Method (Column)

Previous Next

Clears this column.

Syntax

[VB]

Public Sub Clear(clearFlags As ClearFlags)

[C#]

public void Clear (ClearFlags clearFlags )

[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


Move Method (Column)

Move Method (Column)

Previous Next

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


CellStyleCollection class

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

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.
Fixed Supported by the .NET Compact Framework. | Gets the CellStyle used to paint fixed (non-scrollable) 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

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

CellStyleCollection Properties

Alternate Property

Count Property (CellStyleCollection)

EmptyArea Property

Frozen Property

Fixed Property (CellStyleCollection)

Focus Property

Highlight Property (CellStyleCollection)

Item Property (CellStyleCollection)

NewRow Property

Normal Property

Search Property


Alternate Property

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


Count Property (CellStyleCollection)

Count Property (CellStyleCollection)

Previous Next

Gets the number of styles in the collection.

Syntax

[VB]

Public Count As Integer

[C#]

public int Count {get;}

[Delphi]

property Count: Integer;

See Also

CellStyleCollection class


EmptyArea Property

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.

See Also

CellStyleCollection class


Frozen Property

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

AllowFreezing Property


Fixed Property (CellStyleCollection)

Fixed Property (CellStyleCollection)

Previous Next

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


Focus Property

Focus Property

Gets the stock CellStyle used to paint the active cell when the grid has the focus.

Syntax

[VB]

Public Focus As CellStyle

[C#]

public CellStyle Focus {get;}

[Delphi]

property Focus: CellStyle;

See Also

CellStyleCollection class


Highlight Property (CellStyleCollection)

Highlight Property (CellStyleCollection)

Previous Next

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


Item Property (CellStyleCollection)

Item Property (CellStyleCollection)

Previous Next

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;

See Also

CellStyleCollection class


NewRow Property

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:

_flex.Styles.NewRow.BackColor = Color.Yellow

See Also

CellStyleCollection class


Normal Property

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.

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:

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

See Also

CellStyleCollection class


Search Property

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


CellStyleCollection Methods

CellStyleCollection Methods

Add Method (CellStyleCollection)

BuildString Method

Clear Method (CellStyleCollection)

ClearUnused Method

Contains Method (CellStyleCollection)

ParseString Method (CellStyleCollection)

Remove Method (CellStyleCollection)


Add Method (CellStyleCollection)

Add Method (CellStyleCollection)

Previous Next

Adds a custom style to the collection.

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.

See Also

CellStyleCollection class


BuildString Method

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;

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


Clear Method (CellStyleCollection)

Clear Method (CellStyleCollection)

Previous Next

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


ClearUnused Method

ClearUnused Method

This deletes styles that are unnamed and unused

Syntax

[VB]

Public Sub ClearUnused()

[C#]

public void ClearUnused ( )

[Delphi]

procedure ClearUnused;

Remarks

It is created with StyleNew and no longer assigned to any rows, columns, or cell ranges

See Also

CellStyleCollection class


Contains Method (CellStyleCollection)

Contains Method (CellStyleCollection)

Previous Next

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


ParseString Method (CellStyleCollection)

ParseString Method (CellStyleCollection)

Previous Next

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


Remove Method (CellStyleCollection)

Remove Method (CellStyleCollection)

Previous Next

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


CellStyle class

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.


All CellStyle Members

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 for individual cells and ranges.
DataMap | Gets or sets the DataMap for individual cells and ranges (as opposed to the whole grid, or by row or column only, which are still available).
DefinedElements Supported by the .NET Compact Framework. | Gets or sets which elements are defined in this CellStyle
Display | Gets or sets whether the grid should show text, images, or both in a cell, and also whether text should be placed next to the images (Stack, the default setting) or below the text (Overlay).
EditMask | Gets or sets the edit mask for individual cells and ranges.
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 font used to paint text in the cell.
Format | Gets or sets the format for individual cells and ranges (as opposed to by row or column only, which are still available).
ImageAlign Supported by the .NET Compact Framework. | Gets or sets the image alignment for the cell.
ImageMap | Gets or sets the ImageMap for individual cells and ranges (as opposed to the whole grid, or by row or column only, which are still available).
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.
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 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.
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 this style.
Clear Supported by the .NET Compact Framework. | Clears selected elements from this style.
MergeWith | Copies all elements defined in sourceStyle into the current style, leaving existing elements unchanged.
ParseString Supported by the .NET Compact Framework. | Rebuilds style based on the description contained in a string.


CellStyle Properties

CellStyle Properties

BackColor Property

Border Property

ComboList Property

DataMap Property

DefinedElements Property

Display Property

EditMask Property

Font Property (CellStyle)

ForeColor Property

Format Property (CellStyle)

ImageAlign Property (CellStyle)

ImageMap Property

ImageSpacing Property

Margins Property

Name Property (CellStyle)

TextAlign Property (CellStyle)

TextDirection Property

TextEffect Property

Trimming Property

WordWrap Property


BackColor Property

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


Border Property

Border Property

Gets the CellBorder object used to paint the cell borders.

Syntax

[VB]

Public Border As CellBorder

[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


ComboList Property

ComboList Property

Gets or sets the ComboList for individual cells and ranges (as opposed to by row or column only, which are still available).

Syntax

[VB]

Public ComboList As String

[C#]

public string ComboList {get; set}

[Delphi]

property ComboList: string;

Remarks

For example:

CellStyle s = _flex.Styles.Add("TheList");

s.ComboList = "Fiat|Mercedes|Porsche|Pontiac";

CellRange r = _flex.GetCellRange(10,10);

rg.Style = s;

See Also

CellStyle class


DataMap Property

DataMap Property

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


DefinedElements Property

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


Display Property

Display Property

Gets or sets whether the grid should show text, images, or both in a cell, and also whether text should be placed next to the images (Stack, the default setting) or below the text (Overlay).

Syntax

[VB]

Public Display As DisplayEnum

[C#]

public DisplayEnum Display {get; set;}

[Delphi]

property Display: DisplayEnum;

See Also

CellStyle class


EditMask Property

EditMask Property

Gets or sets the edit mask for individual cells and ranges (as opposed to by row or column only, which are still available).

Syntax

[VB]

Public EditMask As String

[C#]

public string EditMask {get; set}

[Delphi]

property EditMask: string;

Remarks

For example:

CellStyle s = _flex.Styles.Add("TheMask");

s.EditMask = "##-##-####";

CellRange r = _flex.GetCellRange(10,10);

rg.Style = s;

See Also

CellStyle class


Font Property (CellStyle)

Font Property (CellStyle)

Previous Next

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


ForeColor Property

ForeColor Property

Gets or sets the font used to paint 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


Format Property (CellStyle)

Format Property (CellStyle)

Previous Next

Gets or sets the format for individual cells and ranges (as opposed to by row or column only, which are still available).

Syntax

[VB]

Public Format As String

[C#]

public string Format {get; set}

[Delphi]

property Format: string;

Remarks

For example:

CellStyle s = _flex.Styles.Add("BigNumber");

s.Format = "#,##0.##";

CellRange r = _flex.GetCellRange(10,10);

rg.Style = s;

See Also

CellStyle class


ImageAlign Property (CellStyle)

ImageAlign Property (CellStyle)

Previous Next

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


ImageMap Property

ImageMap Property

Gets or sets the ImageMap for individual cells and ranges (as opposed to the whole grid, or by row/column, which are still available).

Syntax

[VB]

Public ImageMap As Idictionary

[C#]

public.Idictionary ImageMap {get; set;}

[Delphi]

property ImageMap: Idictionary;

See Also

CellStyle class

ImageMap Property (Column)


ImageSpacing Property

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


Margins Property

Margins Property

Gets or sets the margins between the edges of the cell and its contents.

Syntax

[VB]

Public Margins As Margins

[C#]

public Margins Margins {get; set;}

[Delphi]

property Margins: Margins;

See Also

CellStyle class


Name Property (CellStyle)

Name Property (CellStyle)

Previous Next

Gets or sets the name for this CellStyle.

Syntax

[VB]

Public Name As String

[C#]

public string Name {get; set}

[Delphi]

property Name: string;

Remarks

The style name must be unique and must not contain curly brackets.

See Also

CellStyle class


TextAlign Property (CellStyle)

TextAlign Property (CellStyle)

Previous Next

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


TextDirection Property

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


TextEffect Property

TextEffect Property

Gets or sets the effect used for drawing text in the cell.

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


Trimming Property

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


WordWrap Property

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


CellStyle Methods

CellStyle Methods

BuildString Method (CellStyle)

Clear Method (CellStyle)

MergeWith Method

ParseString Method (CellStyle)


BuildString Method (CellStyle)

BuildString Method (CellStyle)

Previous Next

Returns a compact string representation of this styles.

Syntax

[VB]

Public Function BuildString() As String

[C#]

public String BuildString ( )

[Delphi]

function BuildString: string;

Remarks

The string representation includes only elements defined in this style. It can be applies to a style using the CellStyle’s ParseString method.

See Also

CellStyle class


Clear Method (CellStyle)

Clear Method (CellStyle)

Previous Next

Clears selected elements from this style.

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


MergeWith Method

MergeWith Method

Copies all elements defined in sourceStyle into the current style, leaving existing elements unchanged.

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.

For example:

' 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


ParseString Method (CellStyle)

ParseString Method (CellStyle)

Previous Next

Rebuilds style 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.

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


CellBorder class

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

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

CellBorder Properties

Direction Property

Color Property

Style Property

Width Property (CellBorder)


Direction Property

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


Color Property

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


Style Property

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


Width Property (CellBorder)

Width Property (CellBorder)

Previous Next

Specifies the width of the border, in pixels.

Syntax

[VB]

Public Width As Integer

[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


Node class

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

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

Node Properties

Children Property

Collapsed Property

Data Property (Node)

Expanded Property

Image Property (Node)

Key Property

Level Property

Row Property (Node)


Children Property

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 topic and the Outline Tutorial for examples that shows how to use Node objects.

See Also

Node class


Collapsed Property

Collapsed Property

Gets or sets whether this node is collapsed.

Syntax

[VB]

Public Collapsed As Boolean

[C#]

public bool Collapsed {get; set;}

[Delphi]

property Collapsed: Boolean;

Remarks

See the Creating Custom Trees topic and the Outline Tutorial for examples that shows how to use Node objects.

See Also

Node class


Data Property (Node)

Data Property (Node)

Previous Next

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:

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

See Also

Node class


Expanded Property

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 topic and the Outline Tutorial for examples that shows how to use Node objects.

See Also

Node class


Image Property (Node)

Image Property (Node)

Previous Next

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:

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

See Also

Node class


Key Property

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:

object o1 = node.Key;

object o2 = nd.Row.UserData;

Debug.Assert(o1.Equals(o2), "o1 and o2 refer to the same object");

See Also

Node class


Level Property

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 topic and the Outline Tutorial for examples that shows how to use Node objects.

See Also

Node class


Row Property (Node)

Row Property (Node)

Previous Next

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;

See Also

Node class


Node Methods

Node Methods

AddNode Method

EnsureVisible Method

GetCellRange Method (Node)

GetNode Method

Move Method

RemoveNode Method

Select Method (Node)

Sort Method (Node)


AddNode Method

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


EnsureVisible Method

EnsureVisible Method

Ensures that this node is visible, expanding its parent nodes and scrolling it into view if necessary.

Syntax

[VB]

Public Sub EnsureVisible()

[C#]

public void EnsureVisible ( )

[Delphi]

procedure EnsureVisible;

See Also

Node class


GetCellRange Method (Node)

GetCellRange Method (Node)

Previous Next

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


GetNode Method

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

See Also

C1FlexGridClassic Class

Node class


Move Method

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


RemoveNode Method

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

[Delphi]

procedure RemoveNode;

See Also

Node class


Select Method (Node)

Select Method (Node)

Previous Next

Selects the current node.

Syntax

[VB]

Public Sub Select()

[C#]

public void Select ( )

[Delphi]

procedure Select;

See Also

Node class


Sort Method (Node)

Sort Method (Node)

Previous Next

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

Remarks

This method does not affect the order of rows that are not nodes.

See Also

Node class


GridGlyphs Class

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

All GridGlyphs Members

GridGlyphs Class Public Properties

Item

Gets or sets the glyph for a particular GlyphEnum.


GridGlyphs Properties

GridGlyphs Properties


Item Property (GridGlyphs)

Item Property (GridGlyphs)

Previous Next

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:

_flex.Glyphs[GlyphEnum.Ascending] = imgAscending;

_flex.Glyphs[GlyphEnum.Descending] = imgDescending;

See Also

GridGlyphs class


GridTree class

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

All GridTree Members

GridTree Class Public Properties

Column | Gets or sets the image displayed next to collapsed nodes.
Indent | Gets or sets the image displayed next to expanded nodes.
LineColor | Gets or sets the index of the column whether the outline tree is displayed.
LineStyle | Determines the style used to draw the outline tree.
NodeImageCollapsed | Gets or sets the indentation, in pixels, of each tree level.
NodeImageExpanded | Gets or sets the color of the lines in the outline tree.
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

GridTree Properties

NodeImageCollapsed Property

NodeImageExpanded Property

Column Property

Indent Property

LineColor Property

LineStyle Property

Style Property (GridTree)


NodeImageCollapsed Property

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


NodeImageExpanded Property

NodeImageExpanded Property

Gets or sets the image displayed next to expanded nodes.

Syntax

[VB]

Public NodeImageExpanded As Image

[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


Column Property

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

[Delphi]

property Column: Integer;

Remarks

By default, this property is set to -1, which causes the tree to be hidden.

See Also

GridTree class


Indent Property

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


LineColor Property

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


LineStyle Property

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


Style Property (GridTree)

Style Property (GridTree)

Previous Next

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


GridTree Methods

GridTree Methods


Show Method

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 )

[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


Sort Method (GridTree)

Sort Method (GridTree)

Previous Next

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:

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

}

The pictures below show the effect of the code:

Tree sorted in ascending order, by Sales.

Tree sorted in descending order, by Sales.

See Also

GridTree class


GridPrinter Class

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

AllMembers

GridPrinter Class Public Properties

Footer Supported by the .NET Compact Framework. | Allows you to customize the footer of the grid's PrintDocument.
FooterFont Supported by the .NET Compact Framework. | Specifies the font to use for footers when the grid is printed with the PrintGrid method.
Header Supported by the .NET Compact Framework. | Allows you to customize the header of the grid's PrintDocument.
HeaderFont Supported by the .NET Compact Framework. | Specifies the font to use for headers when the grid is printed with the PrintGrid method.
PageNumber Supported by the .NET Compact Framework. | Gets the number of the page being printed.
PageCount Supported by the .NET Compact Framework. | Gets the total number of the pages in a print document.
PrintDocument Supported by the .NET Compact Framework. | 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

GridPrinter Properties

Footer Property

FooterFont Property

Header Property

HeaderFont Property

PageNumber Property

PageCount Property

PrintDocument Property

PrintPreviewDialog Property

AggregateEnum Enumeration

AggregateFlags Enumeration

AllowFreezingEnum Enumeration

AllowMergingEnum Enumeration

AllowResizingEnum Enumeration

AllowDraggingEnum Enumeration

AllowSortingEnum Enumeration

AutoSearchEnum Enumeration

AutoSizeFlags Enumeration

BorderDirEnum Enumeration

BorderStyleEnum Enumeration

CellStyleEnum Enumeration

CheckEnum Enumeration

ClearFlags Enumeration

DisplayEnum Enumeration

DragModeEnum Enumeration

DrawCellFlags Enumeration

DrawModeEnum Enumeration

DropModeEnum Enumeration

FileFormatEnum Enumeration

FocusRectEnum Enumeration

GlyphEnum Enumeration

GridChangedTypeEnum Enumeration

HighLightEnum Enumeration

HitTestTypeEnum Enumeration

ImageAlignEnum Enumeration

KeyActionEnum Enumeration

NodeMoveEnum Enumeration

NodeTypeEnum Enumeration

PrintGridFlags Enumeration

SelectionModeEnum Enumeration

ShowButtonsEnum Enumeration

SortFlags Enumeration

StyleElementFlags Enumeration

SubTotalPositionEnum Enumeration

TextAlignEnum Enumeration

TextEffectEnum Enumeration

TreeStyleFlags Enumeration


Footer Property

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 code below customizes the footer of the grid’s PrintDocument.

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();

See Also

GridPrinter Class


FooterFont Property

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.

GridPrinter gp = flex.PrinterSettings;

gp.FooterFont = new Font("Arial", 16, FontStyle.Bold);

flex.PrintGrid("my grid", PrintGridFlags.ActualSize, "Header\t\t{0}", "Footer");

See Also

GridPrinter Class


Header Property

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.

GridPrinter gp = _flex.PrintParameters;

gp.Header = "Hello\tWorld\tHeader";

gp.PrintGridFlags = C1.Win.C1FlexGrid.PrintGridFlags.FitToPageWidth;

PrintPreviewDialog dlg = new PrintPreviewDialog();

dlg.Document = gp.PrintDocument;

dlg.ShowDialog();

See Also

GridPrinter Class


HeaderFont Property

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.

GridPrinter gp = flex.PrinterSettings;

gp.HeaderFont = new Font("Arial", 16, FontStyle.Bold);

flex.PrintGrid("my grid", PrintGridFlags.ActualSize, "Header\t\t{0}", "Footer");

See Also

GridPrinter Class


PageNumber Property

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


PageCount Property

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


PrintDocument Property

PrintDocument Property

Gets the PrintDocument object that specifies the page and printer settings.

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:

GridPrinter gp = flex.PrinterSettings;

gp.DefaultPageSettings.Landscape = true;

flex.PrintGrid("my grid");

See Also

GridPrinter Class


PrintPreviewDialog Property

PrintPreviewDialog Property

Allows you to specify properties for the built-in PrintPreview dialog.

Syntax

[VB]

Public PrintPreviewDialog As PrintDocument

[C#]

public PrintDocument PrintPreviewDialog {get;}

[Delphi]

property PrintPreviewDialog: PrintDocument;

Remarks

For example, the code below sets the caption and size of the built-in PrintPreview dialog:

PrintPreviewDialog dlg = _flex.PrintParameters.PrintPreviewDialog;

dlg.Text = "Custom Caption in Preview Dialog";

dlg.ClientSize = new Size(500,500);

See Also

GridPrinter Class


C1FlexGrid Enumerations

C1FlexGrid Enumerations

AggregateEnum Enumeration

AggregateFlags Enumeration

AllowFreezingEnum Enumeration

AllowMergingEnum Enumeration

AllowResizingEnum Enumeration

AllowDraggingEnum Enumeration

AllowSortingEnum Enumeration

AutoSearchEnum Enumeration

AutoSizeFlags Enumeration

BorderDirEnum Enumeration

BorderStyleEnum Enumeration

CellStyleEnum Enumeration

CheckEnum Enumeration

ClearFlags Enumeration

DisplayEnum Enumeration

DragModeEnum Enumeration

DrawCellFlags Enumeration

DrawModeEnum Enumeration

DropModeEnum Enumeration

FileFormatEnum Enumeration

FocusRectEnum Enumeration

GlyphEnum Enumeration

GridChangedTypeEnum Enumeration

HighLightEnum Enumeration

HitTestTypeEnum Enumeration

ImageAlignEnum Enumeration

KeyActionEnum Enumeration

NodeMoveEnum Enumeration

NodeTypeEnum Enumeration

PrintGridFlags Enumeration

SelectionModeEnum Enumeration

ShowButtonsEnum Enumeration

SortFlags Enumeration

StyleElementFlags Enumeration

SubTotalPositionEnum Enumeration

TextAlignEnum Enumeration

TextEffectEnum Enumeration

TreeStyleFlags Enumeration


C1FlexGrid Classic Reference

C1FlexGrid Classic Reference


C1FlexGridClassic Class

C1FlexGridClassic Class

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.

All C1FlexGridClassic Members

C1FlexGridClassic Properties

C1FlexGrid Classic Methods

C1FlexGrid Classic Enumeration Reference


All C1FlexGridClassic Members

All C1FlexGridClassic Members

C1FlexGridClassic Properties

AllowBigSelection | Returns or sets whether clicking on the fixed area will select entire columns and rows.
AllowSelection | Returns or sets whether the user can select ranges of cells with the mouse and keyboard.
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.
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.
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.
ColAlignment | Returns or sets the alignment of the given column.
ColComboList | Returns or sets the list to be used as a drop-down on the specified column.
ColData | Returns or sets a user-defined variant associated with the given column.
ColDataType | Returns or sets the data type for the column.
ColEditMask | Returns or sets the input mask used to edit cells on the specified column.
ColFormat | Returns or sets the format used to display numeric values.
ColHidden | Returns or sets whether a column is hidden.
ColImageList | Sets or returns a handle to an ImageList to be used as a source of pictures for a given column.
ColIndex | Returns the column index that matches the given key.
ColIsVisible | Returns whether a given column is currently within view.
ColKey | Returns or sets a key used to identify the given column.
ColPos | Returns the left (x) coordinate of a column relative to the edge of the control, in twips.
ColPosition | Moves a given column to a new position.
ColSort | Returns or sets the sorting order for each column (for use with the Sort property).
ColWidth | Returns or sets the width of the specified column in twips.
ColWidthMax | Returns or sets the maximum column width, in twips.
ColWidthMin | Returns or sets the minimum column width, in twips.
Editable | Returns or sets whether the control allows in-cell editing.
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.
FixedAlignment | Returns or sets the alignment for the fixed rows in a column.
FixedCols | Returns or sets the number of fixed (non-scrollable) columns.
FixedRows | Returns or sets the number of fixed (non-scrollable) rows.
ForeColorFixed | Returns or sets the foreground color of the fixed rows and columns.
ForeColorSel | Returns or sets the foreground color of the selected cells.
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.
GridLineWidth | Returns or sets the width of the grid lines, in pixels.
IsSelected | Returns or sets whether a row is selected (for listbox-type selections).
MergeCells | Returns or sets whether cells with the same contents will be merged into a single cell.
MergeCol | Returns or sets whether a column will have its cells merged (see also the MergeCells property).
MergeRow | Returns or sets whether a row will have its cells merged (see also the MergeCells property).
RowData | Returns or sets a user-defined variant associated with the given row.
RowHeight | Returns or sets the height of the specified row in twips.
RowHeightMax | Returns or sets the maximum row height, in twips.
RowHeightMin | Returns or sets the minimum row height, in twips.
RowHidden | Returns or sets whether a row is hidden.
RowIsVisible | Returns whether a given row is currently within view.
RowPos | Returns the top (y) coordinate of a row relative to the edge of the control, in twips.
RowPosition | Moves a given row to a new position.
SelectedRow | Returns the position of a selected row when SelectionMode is set to flexSelectionListBox.
SelectedRows | Returns the number of selected rows when SelectionMode is set to flexSelectionListBox.
SheetBorder | Returns or sets the color used to draw the border around the sheet.
Sort | Specifies a sorting order.
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.
TextMatrix | Returns or sets the contents of a cell identified by its row and column coordinates.
TextStyle | Returns or sets 3D effects for displaying text in non-fixed cells.
TextStyleFixed | Returns or sets 3D effects for displaying text in fixed cells.
Value | Returns the numeric value of the current cell.

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.
GetMergedRange | Returns the range of merged cells that includes a given cell.
GetSelection | Returns the current selection ordered so that Row1 <= Row2 and Col1 <= Col2.
get_ValueMatrix | Returns the numeric value of a cell identified by its row and column coordinates.
RemoveItem | Removes a row from the control.


C1FlexGridClassic Properties

C1FlexGridClassic Properties

AllowBigSelection Property

AllowSelection Property

AllowUserResizing Property

AutoSizeMode Property

BackColorAlternate Property

BackColorBkg Property

BackColorFixed Property

BackColorSel Property

BackgroundImage Property

CellAlignment Property

CellBackColor Property

CellChecked Property

CellFont Property

CellFontBold Property

CellFontItalic Property

CellFontName Property

CellFontSize Property

CellFontStrikeThru Property

CellFontUnderline Property

CellForeColor Property

CellHeight Property

CellLeft Property

CellPicture Property

CellPictureAlignment Property

CellTextStyle Property

CellTop Property

CellWidth Property

ColAlignment Property

ColComboList Property

ColData Property

ColDataType Property

ColEditMask Property

ColFormat Property

ColHidden Property

ColImageList Property

ColIndex Property

ColIsVisible Property

ColKey Property

ColPos Property

ColPosition Property

ColSort Property

ColWidth Property

ColWidthMax Property

ColWidthMin Property

Editable Property

EditSelLength Property

EditSelStart Property

EditSelText Property

EditText Property

EditWindow Property

Ellipsis Property

ExplorerBar Property

FillStyle Property

FixedAlignment Property

FixedCols Property

FixedRows Property

ForeColorFixed Property

ForeColorSel Property

GridColor Property

GridColorFixed Property

GridLines Property

GridLinesFixed Property

GridLineWidth Property

IsSelected Property

MergeCells Property

MergeCol Property

MergeRow Property

RowData Property

RowHeight Property

RowHeightMax Property

RowHeightMin Property

RowHidden Property

RowIsVisible Property

RowPos Property

RowPosition Property

SelectedRow Property

SelectedRows Property

SheetBorder Property

Sort Property (C1FlexGridClassic)

TabBehavior Property

Text Property

TextMatrix Property

TextStyle Property

TextStyleFixed Property

Value Property


AllowBigSelection Property

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

SelectionMode Property


AllowSelection Property

AllowSelection Property

Returns or sets whether the user can select ranges of cells with the mouse and keyboard.

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 C1FlexGrid Classic control to implement certain user interface elements such as menus, property sheets, or explorer-style trees.

See Also

C1FlexGridClassic Class

SelectionMode Property


AllowUserResizing Property

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 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:

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

AllowResizing Property


AutoSizeMode Property

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.

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

AutoSizeCol Method


BackColorAlternate Property

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

CellStyle class


BackColorBkg Property

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;

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

CellStyle class


BackColorFixed Property

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

CellStyle class


BackColorSel Property

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.

See Also

C1FlexGridClassic Class

CellStyle class


BackgroundImage Property

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


CellAlignment Property

CellAlignment Property

Returns or sets the alignment of text in the selected cell or range.

Syntax

[VB]

Public CellAlignment As AlignmentSettings

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

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

See Also

C1FlexGridClassic Class

CellStyle class


CellBackColor Property

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:

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:

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

See Also

C1FlexGridClassic Class

CellStyle class


CellChecked Property

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

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

See Also

C1FlexGridClassic Class

Checkbox Property


CellFont Property

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;

See Also

C1FlexGridClassic Class

CellStyle class


CellFontBold Property

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

CellStyle class


CellFontItalic Property

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.

See Also

C1FlexGridClassic Class

CellStyle class


CellFontName Property

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

CellStyle class


CellFontSize Property

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.

See Also

C1FlexGridClassic Class

CellStyle class


CellFontStrikeThru Property

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

CellStyle class


CellFontUnderline Property

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.

See Also

C1FlexGridClassic Class

CellStyle class


CellForeColor Property

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

CellStyle class


CellHeight Property

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.

See Also

C1FlexGridClassic Class

GetCellRect Method


CellLeft Property

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

GetCellRect Method


CellPicture Property

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

CellStyle class


CellPictureAlignment Property

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

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.

See Also

C1FlexGridClassic Class

CellStyle class


CellTextStyle Property

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

CellStyle class


CellTop Property

CellTop Property

The top of the cell.

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

GetCellRect Method


CellWidth Property

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

GetCellRect Method


ColAlignment Property

ColAlignment Property

Returns or sets the alignment of the given column.

Syntax

[VB]

Public ColAlignment As AlignmentSettings

[C#]

public AlignmentSettings ColAlignment {get; set}

[Delphi]

property ColAlignment: AlignmentSettings;

Remarks

The flexAlignGeneral setting aligns text to the left and numbers and dates to the right.The ColAlignment property affects all cells in the specified column, including those in fixed rows. You may override this setting for fixed cells using the FixedAlignment property. 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.

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

StyleFixedDisplay Property


ColComboList Property

ColComboList Property

Returns or sets the list to be used as a drop-down on the specified column.

Syntax

[VB]

Public ColComboList As String

[C#]

public string ColComboList {get; set}

[Delphi]

property ColComboList: string;

Remarks

This property applies to entire columns. You must set the ColComboList property once for each column, whereas the ComboList property normally needs to be set in the BeforeEdit event.

Note that in the ActiveX version of the Flex control, the ColComboList property can be configured to acts as a data dictionary. This is not the case in the .NET version. To associate data dictionaries with columns in the .NET version of the control, use the DataMap property instead.

See Also

C1FlexGridClassic Class

ComboList Property (Column)


ColData Property

ColData Property

Returns or sets a user-defined variant associated with the given column.

Syntax

[VB]

Public ColData As Object

[C#]

public Object ColData {get; set}

[Delphi]

property ColData: Object;

Remarks

The RowData and ColData properties allow you to associate values with each row or column on the control.

A typical use for these properties is to keep indices into an array of data structures associated with each row, or pointers to objects represented by the data in the row or column. The values assigned will remain current even if you sort the control or move its columns.Because these properties hold Variants, you have extreme flexibility in the types of information you may associate with each row, column or cell.

See Also

C1FlexGridClassic Class

Data Property (Node)


ColDataType Property

ColDataType Property

Returns or sets the data type for the column.

Syntax

[VB]

Public ColDataType As Type

[C#]

public Type ColDataType {get; set}

[Delphi]

property ColDataType: Type;

Remarks

This property is automatically set for each column when the control is bound to a data source, so you can determine the data type of each field. When setting this property, the Col parameter should be set to a value between zero and Cols - 1 to set the data type of a given column, or to -1 to set the data type of all columns.

See Also

C1FlexGridClassic Class

DataType Property


ColEditMask Property

ColEditMask Property

Returns or sets the input mask used to edit cells on the specified column.

Syntax

[VB]

Public ColEditMask As String

[C#]

public string ColEditMask {get; set}

[Delphi]

property ColEditMask: string;

Remarks

This property is similar to the EditMask property, except it applies to entire columns. This is often more convenient than using the EditMask property because you may set the ColEditMask property once for each column, whereas the EditMask property normally needs to be set in the BeforeEdit event.

See Also

C1FlexGridClassic Class

Editmask Property (Column)


ColFormat Property

ColFormat Property

Returns or sets the format used to display numeric values.

Syntax

[VB]

Public ColFormat As String

[C#]

public string ColFormat {get; set}

[Delphi]

property ColFormat: string;

Remarks

This property allows you to define a format to be used for displaying numerical, boolean, or date/time values. The syntax for the format string is similar but not identical to the syntax used with Visual Basic's Format command. The syntax is described below:

Formatting Numbers:The characters used to format numerical values are as follows:

Char | Description
$ | A locale-dependent currency sign is appended to the output.
, | Locale-dependent thousand separators are added to the output.
( | Negative values are displayed enclosed in parentheses.
. | The number of decimals is determined by the number of "0" or "#" characters after the decimal point.
% | The value is multiplied by 100 and followed by a percent sign.
,. | The value is divided by 1000 and displayed with thousand separators.

The string "Currency" is also recognized by the control. It formats numbers using the system's currency settings (specified with the Control Panel.)Formatting Dates and Times:The characters used to format date/time values is the same as the one used with Visual Basic's Format command (including predefined strings such as "Short Date").The ColFormat property does not modify the underlying data, only the way it is displayed. You may retrieve the data using the Cell(flexcpText), Text, or TextMatrix properties. You may retrieve the display text using the Cell(flexcpTextDisplay) property. The example below shows several types of format and their effect:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

' format numbers
fg.set_ColFormat(1, "#,###.##") ' number with thousand separators
fg.set_ColFormat(2, "#.###%") ' percentage
fg.set_ColFormat(3, "#,.##") ' thousands
fg.set_ColFormat(4, "Currency") ' thousands

' format booleans
fg.set_ColDataType(5, GetType(Boolean))
fg.set_ColFormat(5, "Probably;Hardly") 'Boolean

' format dates
fg.set_ColFormat(6, "ddd, mmmm d, yyyy")
fg.set_ColFormat(7, "Medium Date")
fg.set_ColFormat(8, "Medium Time")

' set some cells
fg.set_TextMatrix(1, 1, 1234.56)
fg.set_TextMatrix(1, 2, 0.5432)
fg.set_TextMatrix(1, 3, 125250)
fg.set_TextMatrix(1, 4, -1234.5)
fg.set_TextMatrix(1, 5, True)
ffg.set_TextMatrix(1, 6, #7/4/1969#)
fg.set_TextMatrix(1, 7, #7/4/1969#)
fg.set_TextMatrix(1, 8, #7/4/1969#)

' display results:
Dim i%
Debug.WriteLine("Format"; Tab(20); "Content"; Tab(40); "Display")
Debug.WriteLine("-----------"; Tab(20); "-----------"; Tab(40); "-------------")
For i = 1 To 8
Debug.WriteLine(fg.get_ColFormat(i); Tab(20);
fg.Cell(flexcpText, 1, i); Tab(40); _
fg.Cell(flexcpTextDisplay, 1, i))
Next
End Sub

This code produces the following output:

Format Content Display

----------- ----------- -------------

#,###.## 1234.56 1,234.56

#.###% 0.5432 54.320%

#,.## 125250 125.25

Currency -1234.5 ($1,234.50)

Probably;Hardly True Probably

ddd, mmmm d, yyyy 04/07/1969 Fri, July 4, 1969

Medium Date 04/07/1969 04-Jul-69

Medium Time 04/07/1969 12:00 AM
When setting this property, the Col parameter should be set to a value between zero and Cols - 1 to set the format for a given column, or to -1 to set the format for all columns.

See Also

C1FlexGridClassic Class

.Net formatting strings


ColHidden Property

ColHidden Property

Returns or sets whether a column is hidden.

Syntax

[VB]

Public ColHidden As Boolean

[C#]

public bool ColHidden {get; set}

[Delphi]

property ColHidden: Boolean;

Remarks

Use the ColHidden property to hide and display columns. This is a better approach than setting the column's ColWidth property to zero, because it allows you to display the column later with its original width.Hidden columns are ignored by the AutoSize method.When setting this property, the Col parameter should be set to a value between zero and Cols - 1 to hide or show a given column, or to -1 to hide or show all columns.This example hides the second column:

fg.set_ColHidden(1, True)

See Also

C1FlexGridClassic Class

Visible Property (Column)


ColImageList Property

ColImageList Property

Sets or returns a handle to an ImageList to be used as a source of pictures for a given column.

Syntax

[VB]

Public ColImageList As Integer

[C#]

public int ColImageList {get; set}

[Delphi]

property ColImageList: Integer;

Remarks

This property is useful if you want to display numeric data contained in a grid column as pictures rather than as numbers.For example, the "Products" table in the NorthWind database contains a "CategoryID" entry. Instead of displaying the categories as numbers or names, you could create an image list with icons representing each product category, and then bind the "CategoryID" column to the image list. This is easier and more efficient than traversing the recordset and setting the CellPicture property for each cell on the column, especially if the number of records is very large.The mapping between numeric values and image list indices is continuous, starting from zero. Pictures are painted in cells that have numeric values between zero and the number of images on the list minus one. Cells that are empty, contain non-numeric values, or contain values that are outside the image list range, do not get pictures.When a cell picture comes from an image list, the text contents of the cell are not drawn, and the image is aligned based on the setting of the ColAlignment property.

See Also

C1FlexGridClassic Class

ImageMap Property (Column)


ColIndex Property

ColIndex Property

Returns the column index that matches the given key.

Syntax

[VB]

Public ColIndex As Integer

[C#]

public int ColIndex {get; set}

[Delphi]

property ColIndex: Integer;

Remarks

The ColIndex property is used in conjunction with the ColKey property to identify and refer to columns regardless of their physical position on the grid. These properties are useful when the grid is bound to a recordset or when the user is allowed to move columns around by dragging their header cells.To use these properties, assign unique keys to each column using the ColKey property. When you want to refer to a specific column, convert the key into an index using the ColIndex property.For example, the code below counts how many times the MouseMove event fired and displays the total on a "Counter" column. The user may move the column to a different position with the mouse, and the code will follow the column around:

Private Sub fg_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) _

Handles fg.MouseMove
Dim c%
c = fg.get_ColIndex("Counter")
fg.set_TextMatrix(1, c, fg.get_ValueMatrix(1, c) + 1)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
fg.ExplorerBar = ExplorerBarSettings.flexExMove
fg.set_TextMatrix(0, 1, "Counter")
fg.set_ColKey(1, "Counter")
End Sub

When the grid is bound to a recordset, ColKey values are automatically set to the field names. This allows you to refer to columns by their field names, as in the following code (which assumes the fg grid is bound to a recordset with a field called "CategoryID"):

fg.set_ColAlignment(fg.get_ColIndex("CategoryID"), C1.Win.C1FlexGrid.Classic.AlignmentSettings.flexAlignCenterCenter)

If the Key argument does not correspond to any ColKey value, the ColIndex property returns -1.

See Also

C1FlexGridClassic Class

Index Property (Column)


ColIsVisible Property

ColIsVisible Property

Returns whether a given column is currently within view.

Syntax

[VB]

Public ColIsVisible As Boolean

[C#]

public bool ColIsVisible {get; set}

[Delphi]

property ColIsVisible: Boolean;

Remarks

The ColIsVisible and RowIsVisible properties are used to determine whether the specified column or row is within the visible area of the control or whether it has been scrolled off the visible part of the control.This example checks to see if the second column is currently within view:

If fg.get_ColIsVisible(1) Then

Debug.WriteLine("Column 1 is visible")

End If

If a column has zero width or is hidden but is within the scrollable area, ColIsVisible returns True.To ensure a given column is visible, use the ShowCell method.

See Also

C1FlexGridClassic Class

LeftCol Property

RightCol Property


ColKey Property

ColKey Property

Returns or sets a key used to identify the given column.

Syntax

[VB]

Public ColKey As String

[C#]

public string ColKey {get; set}

[Delphi]

property ColKey: string;

Remarks

The ColKey property is used in conjunction with the ColIndex property to identify and refer to columns regardless of their physical position on the grid. These properties are useful when the grid is bound to a recordset or when the user is allowed to move columns around by dragging their header cells.To use these properties, assign unique keys to each column using the ColKey property. When you want to refer to a specific column, convert the key into an index using the ColIndex property.

See Also

C1FlexGridClassic Class

Name Property (Column)


ColPos Property

ColPos Property

Returns the left (x) coordinate of a column relative to the edge of the control, in twips.

Syntax

[VB]

Public ColPos As Integer

[C#]

public int ColPos {get; set}

[Delphi]

property ColPos: Integer;

Remarks

This property is similar to the CellLeft property, except ColPos applies to an arbitrary column and will not cause the control to scroll. The CellLeft property applies to the current selection, and reading it will make the current cell visible, scrolling the contents of the control if necessary.

See Also

C1FlexGridClassic Class

GetCellRect Method


ColPosition Property

ColPosition Property

Moves a given column to a new position.

Syntax

[VB]

Public ColPosition As Integer

[C#]

public int ColPosition {get; set}

[Delphi]

property ColPosition: Integer;

Remarks

The Col and NewPosition parameters must be valid column indices (in the range 0 to Cols - 1), or an error will be generated.When a column or row is moved with ColPosition or RowPosition, all formatting information moves with it, including width, height, alignment, colors, fonts, etc. To move text only, use the Clip property instead.For example, the following code shows how you can insert a new column at an arbitrary position on the grid:

Sub InsertCol(pos%)
fg.Cols = fg.Cols + 1
fg.set_ColPosition(fg.Cols - 1, pos)
fg.set_TextMatrix(0, pos, "New " & fg.Cols)
End Sub

The ColPosition property gives you programmatic control over the column order. You may also use the ExplorerBar property to allow users to move columns with the mouse.

See Also

C1FlexGridClassic Class

Move Method (ColumnCollection)


ColSort Property

ColSort Property

Returns or sets the sorting order for each column (for use with the Sort property).

Syntax

[VB]

Public ColSort As SortSettings

[C#]

public SortSettings ColSort {get; set}

[Delphi]

property ColSort: SortSettings;

Remarks

This property allows you to specify different sorting orders for each column on the grid. The most common settings for this property are flexSortGenericAscending and flexSortGenericDescending. For a complete list of possible settings, see the Sort property.To perform the sort using the settings assigned to each column, set the Sort property to flexSortUseColSort.For example, the following code sorts the grid so that the first row is in ascending order, the second is ignored, and the third is in descending order:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

fg.Cols = 4
fg.set_ColSort(1, SortSettings.flexSortGenericAscending)
fg.set_ColSort(2, SortSettings.flexSortNone)
fg.set_ColSort(3, SortSettings.flexSortGenericDescending)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
fg.Select (1, 1, 1, 3)
fg.Sort = SortSettings.flexSortUseColSort
End Sub

See Also

C1FlexGridClassic Class

Sort Property (Column)


ColWidth Property

ColWidth Property

Returns or sets the width of the specified column in twips.

Syntax

[VB]

Public ColWidth As Integer

[C#]

public int ColWidth {get; set}

[Delphi]

property ColWidth: Integer;

Remarks

Use this property to set the width of a column at runtime. To set width limits for all columns, use the ColWidthMin and ColWidthMax properties. To set column widths automatically, based on the contents of the control, use the AutoSize method.If the Col parameter is -1, then the specified width is applied to all columns.If set ColWidth to -1, the column width is reset to its default value, which depends on the size of the control's current font. If set ColWidth to zero, the column becomes invisible. If you want to hide a column, however, consider using the ColHidden property instead. This allows you to make the column visible again with the same width it had before it was hidden.This example sets the width of the third column to 1 inch (1440 twips)

fg.set_ColWidth(2, 1440)

See Also

C1FlexGridClassic Class

Width Property (Column)


ColWidthMax Property

ColWidthMax Property

Returns or sets the maximum column width, in twips.

Syntax

[VB]

Public ColWidthMax As Integer

[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):

fg.ColWidthMax = 2880

See Also

C1FlexGridClassic Class

MaxSize Property (ColumnCollection)


ColWidthMin Property

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.This example sets the minimum column width to 1/2 inch (720 twips):

fg.ColWidthMin = 720

See Also

C1FlexGridClassic Class

MinSize Property (ColumnCollection)


Editable Property

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 ColComboList property. You may also specify an editing mask using the EditMask and ColEditMask properties. 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

AllowEditing Property (C1FlexGrid)


EditSelLength Property

EditSelLength Property

Returns or 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.

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

See Also

C1FlexGridClassic Class

Editor Property


EditSelStart Property

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.

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

See Also

C1FlexGridClassic Class

Editor Property


EditSelText Property

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.

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

See Also

C1FlexGridClassic Class

Editor Property


EditText Property

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

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" And 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

See Also

C1FlexGridClassic Class

Editor Property


EditWindow Property

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:

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

See Also

C1FlexGridClassic Class

Editor Property


Ellipsis Property

Ellipsis Property

Returns or sets whether the control will display ellipsis (...) after long strings.

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

Trimming Property


ExplorerBar Property

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:

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:

'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

AllowResizing Property

AllowSorting Property (C1FlexGrid)


FillStyle Property

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

Selection Property


FixedAlignment Property

FixedAlignment Property

Returns or sets the alignment for the fixed rows in a column.

Syntax

[VB]

Public FixedAlignment As AlignmentSettings

[C#]

public AlignmentSettings FixedAlignment {get; set}

[Delphi]

property FixedAlignment: AlignmentSettings;

Remarks

The FixedAlignment property behaves like the ColAlignment property except that it only affects the alignment of fixed cells. You can use this property to align headings differently than the rest of the cells.For a list of valid settings, see the ColAlignment property.

See Also

C1FlexGridClassic Class

StyleFixedDisplay Property


FixedCols Property

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;

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.

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, GridLinesFixed, and FixedAlignment 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

Fixed Property (ColumnCollection)


FixedRows Property

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.

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, GridLinesFixed, and FixedAlignment 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

Fixed Property (RowCollection)


ForeColorFixed Property

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

Styles Property


ForeColorSel Property

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

Styles Property


GridColor Property

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

Styles Property


GridColorFixed Property

GridColorFixed Property

Returns or sets the color used to draw the grid lines between the fixed cells.

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

Styles Property


GridLines Property

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

Styles Property


GridLinesFixed Property

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

Styles Property


GridLineWidth Property

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

Styles Property


IsSelected Property

IsSelected Property

Returns or sets whether a row is selected (for listbox-type selections).

Syntax

[VB]

Public IsSelected As Boolean

[C#]

public bool IsSelected {get; set}

[Delphi]

property IsSelected: Boolean;

Remarks

This property allows you to select individual rows, not necessarily adjacent, independently of the RowSel property and ColSel property.To implement this type of row selection, you will typically set the SelectionMode property to flexSelectionListBox, which allows the user to select individual rows using the mouse or the keyboard, and to toggle the selection for a row by CTRL-clicking on it. If you set SelectionMode property to something other than flexSelectionListBox, you may still select and de-select rows using the IsSelected property, but the user will not be able to alter the selection with the mouse or keyboard (unless you write the code to do it).

See Also

C1FlexGridClassic Class

Selected Property (RowCollection)


MergeCells Property

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

The MergeCells property is used in conjunction with the MergeRow and MergeCol properties 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 MergeRow and MergeCol properties to True for the rows and columns you wish to merge (except when using the flexMergeSpill mode). After these properties are set, 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 MergeCol and MergeRow properties, 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.

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

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

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

See Also

C1FlexGridClassic Class


MergeCol Property

MergeCol Property

Returns or sets whether a column will have its cells merged (see also the MergeCells property).

Syntax

[VB]

Public MergeCol As Boolean

[C#]

public bool MergeCol {get; set}

[Delphi]

property MergeCol: Boolean;

Remarks

The MergeCol property is used in conjunction with the MergeCells and MergeRow properties 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 MergeRow and MergeCol properties are used to determine which rows and columns should have their cells merged. By default, MergeRow and 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 Col parameter should be set to a value between zero and Cols - 1 to set MergeCol for a single column, or -1 to set all columns.For more details and examples, see the MergeCells property.

See Also

C1FlexGridClassic Class

AllowMerging Property (Column)


MergeRow Property

MergeRow Property

Returns or sets whether a row will have its cells merged (see also the MergeCells property).

Syntax

[VB]

Public MergeRow As Boolean

[C#]

public bool MergeRow {get; set}

[Delphi]

property MergeRow: Boolean;

Remarks

The MergeRow property is used in conjunction with the MergeCells and MergeCol properties 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 MergeRow and MergeCol properties are used to determine which rows and columns should have their cells merged. By default, MergeRow and 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 MergeRow to True when MergeCells is set to flexMergeSpill (6).For more details and examples, see the MergeCells property.

See Also

C1FlexGridClassic Class

AllowMerging Property (Row)


RowData Property

RowData Property

Returns or sets a user-defined variant associated with the given row.

Syntax

[VB]

Public RowData As Object

[C#]

public Object RowData {get; set}

[Delphi]

property RowData: Object;

Remarks

The RowData and ColData properties allow you to associate values with each row or column on the control. A typical use for these properties is to keep indices into an array of data structures associated with each row, or pointers to objects represented by the data in the row or column. The values assigned will remain current even if you sort the control or move its columns.Because these properties hold Objects, you have extreme flexibility in the types of information you may associate with each row, column or cell. The example below shows some ways in which you can use the RowData property:

Dim coll As New Collection

coll.Add "Hello"
coll.Add "World"

fg.set_RowData(1, 212) ' store a number
fg.set_RowData(2, "Hello") ' store a string
fg.set_RowData(3, coll) ' store a pointer to an object
fg.set_RowData(4, Me) ' store a pointer to a form

Debug.WriteLine(TypeName(fg.get_RowData(1)), fg.get_RowData(1))
Debug.WriteLine(TypeName(fg.get_RowData(2)), fg.get_RowData(2))
Debug.WriteLine(TypeName(fg.get_RowData(3)), fg.get_RowData(3).Item(2))Debug.WriteLine(TypeName(fg.get_RowData(4)), fg.get_RowData(4).Caption)

This code produces the following output:

Integer 212

String Hello

Collection World

Form1 Form1

You can search for rows that contain specific RowData values using the FindRow property.

See Also

C1FlexGridClassic Class

UserData Property (Row)


RowHeight Property

RowHeight Property

Returns or sets the height of the specified row in twips.

Syntax

[VB]

Public RowHeight As Integer

[C#]

public int RowHeight {get; set}

[Delphi]

property RowHeight: Integer;

Remarks

Use this property to set the height of a row at runtime. To set height limits for all rows, use the RowHeightMin and RowHeightMax properties.If the Row parameter is -1, then the specified height is applied to all rows.If you set RowHeight to -1, the row height is reset to its default value, which depends on the size of the control's current font. If you set RowHeight to zero, the column becomes invisible. If you want to hide a row, however, consider using the RowHidden property instead. This allows you to make the row visible again with the same height it had before it was hidden.To set row heights automatically, based on the contents of the control, set the AutoSizeMode property to flexAutoSizeRowHeight (1) and call the AutoSize method.

See Also

C1FlexGridClassic Class

Height Property


RowHeightMax Property

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

MaxSize Property (RowCollection)


RowHeightMin Property

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;

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

MinSize Property (RowCollection)


RowHidden Property

RowHidden Property

Returns or sets whether a row is hidden.

Syntax

[VB]

Public RowHidden As Boolean

[C#]

public bool RowHidden {get; set}

[Delphi]

property RowHidden: Boolean;

Remarks

Use the RowHidden property to hide and display rows. This is a better approach than setting the row's RowHeight property to zero, it allows you to display the row later with its original height.When the control collapses or expands an outline branch, either as a result of user mouse action or programmatically (see the Tree.Show method and Node.Collapsed property), it sets the RowHidden property accordingly.Hidden rows are ignored by the AutoSize method.When setting this property, the Row parameter should be set to a value between zero and Rows - 1 to hide or show a given row, or to -1 to hide or show all rows.

See Also

C1FlexGridClassic Class

Visible Property (Row)


RowIsVisible Property

RowIsVisible Property

Returns whether a given row is currently within view.

Syntax

[VB]

Public RowIsVisible As Boolean

[C#]

public bool RowIsVisible {get; set}

[Delphi]

property RowIsVisible: Boolean;

Remarks

The ColIsVisible and RowIsVisible properties are used to determine whether the specified column or row is within the visible area of the control or whether it has been scrolled off the visible part of the control.If a row has zero height or is hidden but is within the scrollable area, RowIsVisible will return True. To ensure a given row is visible, use the ShowCell method.

See Also

C1FlexGridClassic Class

TopRow Property

LeftCol Property


RowPos Property

RowPos Property

Returns the top (y) coordinate of a row relative to the edge of the control, in twips.

Syntax

[VB]

Public RowPos As Integer

[C#]

public int RowPos {get; set}

[Delphi]

property RowPos: Integer;

Remarks

This property is similar to the CellTop property, except RowPos applies to an arbitrary row and will not cause the control to scroll. The CellTop property applies to the current selection and reading it will make the current cell visible, scrolling the contents of the control if necessary.

See Also

C1FlexGridClassic Class

GetCellRect Method


RowPosition Property

RowPosition Property

Moves a given row to a new position.

Syntax

[VB]

Public RowPosition As Integer

[C#]

public int RowPosition {get; set}

[Delphi]

property RowPosition: Integer;

Remarks

The Row and NewPosition parameters must be valid row indices (in the range 0 to Rows - 1), or an error will be generated.When a column or row is moved with ColPosition or RowPosition, all formatting information moves with it, including width, height, alignment, colors, fonts, etc. To move text only, use the Clip property instead.See the ColPosition property for an example.

See Also

C1FlexGridClassic Class

Move Method (RowCollection)


SelectedRow Property

SelectedRow Property

Returns the position of a selected row when SelectionMode is set to flexSelectionListBox.

Syntax

[VB]

Public SelectedRow As Integer

[C#]

public int SelectedRow {get; set}

[Delphi]

property SelectedRow: 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. Using the SelectedRows and SelectedRow properties to enumerate all selected rows is equivalent to, but faster than scanning the entire control for selected rows by reading the IsSelected property.For example,

Dim i As Integer

For i = 0 to fg.SelectedRows – 1

Debug.WriteLine("Row" & fg.SelectedRow(i) & " is selected")
Next

is faster than

Dim i As Integer

For i = 0 to fg.Rows

If fg.get_IsSelected(i) Then Debug.Writeline ("Row "; i; " is selected")
Next

See Also

C1FlexGridClassic Class

Selection Property


SelectedRows Property

SelectedRows Property

Returns the number of selected rows when SelectionMode is set to flexSelectionListBox.

Syntax

[VB]

Public SelectedRows As Integer

[C#]

public int SelectedRows {get; set}

[Delphi]

property SelectedRows: Integer;

Remarks

This property works in conjunction with the SelectedRow 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. The code below prints the number of selected rows to the debug window when the selection changes:

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

Using the SelectedRows and SelectedRow properties to enumerate all selected rows is equivalent to, but faster than scanning the entire control for selected rows by reading the IsSelected property.For an example, see the SelectedRow property.

See Also

C1FlexGridClassic Class

Selection Property


SheetBorder Property

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

See Also

C1FlexGridClassic Class

Styles Property


Sort Property (C1FlexGridClassic)

Sort Property (C1FlexGridClassic)

Previous Next

Specifies a sorting order.

Syntax

[VB]

Public Sort As SortSettings

[C#]

public SortSettings Sort {get; set}

[Delphi]

property Sort: SortSettings;

Remarks

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


TabBehavior Property

TabBehavior Property

Returns or sets whether the tab key will move focus between controls (VB default) or between grid cells.

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:

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

See Also

C1FlexGridClassic Class

KeyActionEnter Property

KeyActionTab Property


Text Property

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":

fg.Select 3, 3

fg.Text = "Apple"

See Also

C1FlexGridClassic Class

GetData Method

SetData Method


TextMatrix Property

TextMatrix Property

Returns or sets the contents of a cell identified by its row and column coordinates.

Syntax

[VB]

Public TextMatrix As String

[C#]

public string TextMatrix {get; set}

[Delphi]

property TextMatrix: string;

Remarks

The TextMatrix property allows you to set or retrieve the contents of a cell without changing the Row property and Col property.The following code places text into an arbitrary cell:

fg.set_TextMatrix(1, 1, "Apple")

See Also

C1FlexGridClassic Class

GetData Method

SetData Method


TextStyle Property

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

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:

fg.TextStyle = TextStyleSettings.flexTextInset

See the CellTextStyle property for an enumeration listing.

See Also

C1FlexGridClassic Class

Styles Property


TextStyleFixed Property

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 this property are the same as those for the TextStyle property.The example below prints text with a raised 3-D effect in fixed cells:

fg.TextStyleFixed = TextStyleSettings.flexTextRaised

See the CellTextStyle property for an enumeration listing.

See Also

C1FlexGridClassic Class

Styles Property


Value Property

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:

Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click
Debug. WriteLine (fg.Value)
End Sub

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

GetData Method

SetData Method


C1FlexGrid Classic Methods

C1FlexGrid Classic Methods

AutoSize Method

Clear Method

GetMergedRange Method

GetSelection Method

Get_ValueMatrix Method

RemoveItem Method (C1FlexGridClassic)


AutoSize Method

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.

See Also

C1FlexGridClassic Class

AutoSizeCol Method

AutoSizeRow Method


Clear Method

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.

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:

Dim r1&, c1&, r2&, c2&

fg.set_Cell(CellPropertySettings.flexcpText, r1, C1, r2, c2, "")
fg.set_Cell(CellPropertySettings.flexcpCustomFormat, r1, C1, r2, c2, False)

This example clears the text of the selected cell(s) while leaving the picture and cell data intact:

fg.Clear(ClearWhereSettings.flexClearSelection, ClearWhatSettings.flexClearText)

See Also

C1FlexGridClassic Class

Clear Method (C1FlexGrid)


GetMergedRange Method

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 C1FlexGrid Classic 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:

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

For more details on cell merging, see the MergeCells property.

See Also

C1FlexGridClassic Class

GetMergedRange Method (C1FlexGrid)


GetSelection Method

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 VSFlexGrid 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.For example, the code below prints the contents of the selected range:

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

See Also

C1FlexGridClassic Class

Selection Property


Get_ValueMatrix Method

Get_ValueMatrix Method

Returns the numeric value of a cell identified by its row and column coordinates.

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:

Debug.WriteLine(fg.get_ValueMatrix(1, 1))

See Also

C1FlexGridClassic Class

GetData Method

SetData Method


RemoveItem Method (C1FlexGridClassic)

RemoveItem Method (C1FlexGridClassic)

Previous Next

Removes a row from the control.

Syntax

[VB]

Object.RemoveItem ()

Object.RemoveItem (int Row)

[C#]

public void RemoveItem ( )

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

Remove Method (RowCollection)


C1FlexGrid Classic Enumeration Reference

C1FlexGrid Classic Enumeration Reference

AlignmentSettings Enumeration

AllowUserResizeSettings Enumeration

AutoSizeSettings Enumeration

CellCheckedSettings Enumeration

ClearWhatSettings Enumeration

ClearWhereSettings Enumeration

EditableSettings Enumeration

EditFlags Enumeration

EllipsisSettings Enumeration

ExplorerBarSettings Enumeration

FillStyleSettings Enumeration

GridStyleSettings Enumeration

MergeSettings Enumeration

PictureAlignmentSettings Enumeration

SortSettings Enumeration

TabBehaviorSettings Enumeration

TextDirectionEnum Enumeration

TextStyleSettings Enumeration


AlignmentSettings Enumeration

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, ColAlignment, and FixedAlignment in the C1FlexGrid Classic 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.
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

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 C1FlexGrid Classic 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

AutoSizeSettings Enumeration

Specifies whether AutoSize will adjust column widths or row heights to fit cell contents.

Syntax

[VB]

Public enum AutoSizeSettings

[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 AutoSize property in the C1FlexGrid Classic control.

Member Name | Description
flexAutoSizeColWidth | The user may not resize rows or columns.
flexAutoSizeRowHeight | The user may resize column widths.


CellCheckedSettings Enumeration

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 C1FlexGrid Classic 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.


ClearWhatSettings Enumeration

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 C1FlexGrid Classic 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.


ClearWhereSettings Enumeration

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 C1FlexGrid Classic control.

Member Name | Description
flexClearEverywhere | Clear from entire grid.
flexClearScrollable | Clear from only scrollable portion of grid.
flexClearSelection | Clear from selected area.


EditableSettings Enumeration

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 C1FlexGrid Classic 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.


EditFlags Enumeration

EditFlags Enumeration

Specifies whether the built-in ComboBox searches for items as the user types, cycles items when the user double clicks, or toggles all check boxes in a selection.

Syntax

[VB]

Public Enum EditFlags

[C#]

public sealed enum EditFlags : Enum

[Delphi]

type EditFlags = (AutoSearch, CycleOnDoubleClick, MultiCheck);

Remarks

Use the members of this enumeration to set the value of the EditOptions property in the C1FlexGrid Classic control.

Member Name | Description
AutoSearch | Gets or sets whether the built-in ComboBox should search for items as the user types.
CycleOnDoubleClick | Gets or sets whether the built-in ComboBox should cycle items when the user double-clicks a cell.
MultiCheck | Gets or sets whether the grid should toggle all checkboxes in a selection.


EllipsisSettings Enumeration

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 C1FlexGrid Classic 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

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 C1FlexGrid Classic control.

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

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 C1FlexGrid Classic 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

GridStyleSettings Enumeration

Specifies the style of the grid’s lines.

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 C1FlexGrid Classic 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

MergeSettings Enumeration

Specifies how cells are merged.

Syntax

[VB]

Public enum MergeSettings

[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 C1FlexGrid Classic 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.


PictureAlignmentSettings Enumeration

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 C1FlexGrid Classic 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.
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.


SortSettings Enumeration

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 ColSort and Sort properties in the C1FlexGrid Classic 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.
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

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 C1FlexGrid Classic 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.


TextDirectionEnum Enumeration

TextDirectionEnum Enumeration

Specifies the vertical direction of the text.

Syntax

[VB]

Public Enum TextDirectionEnum

[C#]

public sealed enum TextDirectionEnum :Enum

[Delphi]

type TextDirectionEnum = (Down, Normal, Up);

Remarks

Use the members of this enumeration to set the value of the TextDirection property in the C1FlexGrid Classic control.

Member Name | Description
Down | Vertical text, rendered from top to bottom of the cell.
Normal | Horizontal text.
Up | Vertical text, rendered from bottom to top of the cell.


TextStyleSettings Enumeration

TextStyleSettings Enumeration

Specifies the text style.

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 C1FlexGrid Classic 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.


AggregateEnum Enumeration

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

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.


AllowDraggingEnum Enumeration

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.


AllowFreezingEnum Enumeration

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

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

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

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.
BothUniform | The user may resize rows and columns with the mouse. When a row is resized, the new row height is applied to all rows. Columns are still resized independently.


AllowSortingEnum Enumeration

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

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

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

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

[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

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

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

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

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.
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.
Frozen | Style used to render cells that are frozen (editable and selectable, but not scrollable). By default, this style has a custom background color.
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

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.


ClearFlags Enumeration

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

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).
OverLay | Image and value (overlaid).
Stack | Image and value (side by side).
TextOnly | Display value only (no image).


DragModeEnum Enumeration

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

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

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

DropModeEnum Enumeration

Specifies how the control handles OLE drag-drop operations.

Syntax

[VB]

Public Enum DropModeEnum

[C#]

public sealed enum DropModeEnum : System.Enum

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


FileFormatEnum Enumeration

FileFormatEnum Enumeration

Specifies the type of text 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.


FocusRectEnum Enumeration

FocusRectEnum Enumeration

Specifies the appearance of the focus rectangle on the grid.

Syntax

[VB]

Public Enum FocusRectEnum

[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

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

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

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

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

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

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

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.


NodeMoveEnum Enumeration

NodeMoveEnum Enumeration

Specifies the destination of nodes when they are moved with the Node.Move method.

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

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

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

SelectionModeEnum Enumeration

Specifies the type of grid selection to use.

Syntax

[VB]

Public Enum SelectionModeEnum

[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

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

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

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.

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.
All | The style defines all elements.


SubTotalPositionEnum Enumeration

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

[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

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.
GeneralBottom | Numbers are aligned to the right, other values to the left, and vertically aligned to the bottom.


TextEffectEnum Enumeration

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.

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

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