BeeGrid Cover Page

Hierarchical ActiveX Grid Control.

Information in this document is subject to change without notice and does not represent a commitment on the part of Stinga. The software described in this document and this document itself are furnished under the provisions of a license agreement. The software may be used or copied only in accordance with the terms of the agreement. It is against the law to copy this software on any medium except as is specifically allowed in the license or nondisclosure agreement. No part of the documentation may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photo copying, recording, or information storage and retrieval systems, for any purpose without the express written permission of Stinga.
Companies, names, and data used in examples are fictitious unless otherwise noted.

Microsoft, Visual Basic, Visual C++, Windows, Win32, Visual Basic 5.0, Visual Basic 6.0, Access 97, Access, Excel, Internet Explorer and ActiveX are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

Copyright © 2000-2001 Stinga
Buconjiceva 14
Zagreb, Croatia
http://www.stinga.com


BeeGrid Overview

Hierarchical ActiveX Grid Control.

Thank you for choosing BeeGrid! BeeGrid is a full-featured, database-aware ActiveX® grid control. It can be used in a bound (both OLEDB and ICursor), unbound and virtual data modes. BeeGrid has all features expected from a modern grid control: fast and easy manipulation of tabular data, powerful display capabilities, easy to use unbound mode, easy to use event and interface based virtual modes, outlook-like grouping, etc.

But it doesn't stop there. BeeGrid has some unique features that will make your applications stand out. This is just a small list of control's major features:

Free Edition | BeeGrid is published in two editions: Free and Pro. Free Edition can be freely used in any application: personal or commercial. Please check a list of Free Edition limitations and Free Edition license agreement. Pro Edition does not require any royalty fees.
Rich object model | BeeGrid is composed from about 30 objects and collections. Click here to check grid's object model.
Bind to databases | Supports OLEDB (ADO) and ICursor (Visual Basic's data control) data sources. MS RDC is not supported in this version.
Easy to use unbound mode | BeeGrid has an easy to use unbound mode in which all data is stored in grid's internal buffer.
Powerful virtual modes | BeeGrid supports two powerful virtual modes. One is driven by standard events and can be used by a scripting client. The other one is a much faster, interface based virtual mode, and can be used by VB and VC containers. Both of these modes are ideal for displaying data stored in a non-standard databases and application's internal data structures.
Value lists | Supports automatic translation of the underlying data values into the text and/or picture.
In-cell editing | Uses single and multi-line edit box, action button, check box and combo box for in-cell editing.
Data display | Supports a variety of cell display techniques. BeeGrid can show text and pictures in separate cells and combined. Cell drawing is controlled with powerful style model. Data-sensitive styles are supported.
Alpha blending and gradient fill. | Each object that has a style associated with it (row, column, cell, range, ...) can be transparent and its background can be filled with color gradient. This feature is available on Windows® 98, Windows® Me an Windows® 2000 operating systems.
Unique custom drawing | BeeGrid implements unique, stage-driven, custom draw model. Programmers can intercept and replace one or more stages in control's paint cycle.
Unique preview pane feature | Programmers can decide to show contents of one column inside the preview pane. Preview pane can be sized and aligned along any grid's border. Custom drawing inside preview pane is also supported.
Sorting | Programmers and users can sort grid columns. Sorting is performed by the BeeGrid control itself and is available regardless of the data mode used.
Outlook-style grouping | BeeGrid supports outlook-style groupings. Programmers and users can select one or more columns and group rows based on values in selected columns. Grouping is enabled in all data modes: OLEDB, ICursor, unbound and virtual.
Group calculations | Programmers can set formulas that will be automatically calculated and results displayed in the group headers and/or footers.
Hierarchy navigation | Programmers can traverse a tree of group header and child rows with an extensive object model.
Unique row filtering | BeeGrid supports unique row filtering capabilities. A programmer can initialize a collection of row filters and filtering will be applied to all rows: existing, updated and newly inserted rows. Filtered row can be selected, hidden, displayed with a special style, marked as read-only or prepared for some custom defined action.
Data import and export | Underlying data can be saved to and loaded from an XML and character separated value files.
Reusable layouts | Grid layouts can be saved into an XML file and later loaded from a local file or an URL location. Programmers can separately save and load column definitions, group definitions, filter definitions, style conditions and style definitions.
HTML export | Programmers can use template-based HTML export feature to create flashy HTML pages. BeeGrid styles can be exported as CSS styles.
ScrollTips and CellTips | BeeGrid provides simple to use cell and scrollbar tips. Tool tip appearance is controlled by BeeGrid styles and can be customized by responding to various events. Also, tool tip pictures are supported.
Frozen rows and columns | Supports fixed, non-scrollable rows and columns. Appearance of the frozen rows and columns is controlled with the built-in style.


List of Free and Pro Edition Differences

Free-Pro Comparation Table

This is a list of Free and Pro Edition differences. Please note that this list and Free Edition restrictions can be changed at any time.

Feature | Free Edition | Pro Edition
Number of columns | 12 columns maximum and only first 12 recordset columns can be used. | 8192 columns maximum
Number of rows | 1024 rows maximum | 4 million rows maximum
Number of groups | 2 groups maximum | 64 groups maximum
Group calculations | Maximum 1 item in a Calculation collections | Unlimited1
Custom drawing | Non-functional | Functional
Preview pane | Non-functional | Functional
User defined styles | 2 user defined styles maximum | Unlimited1 number of user defined styles
Style conditions | 1 conditional style maximum | 64 conditional styles maximum
Row filtering | 1 filter maximum | 64 filters maximum
Data sorting (SGGrid.Sort method) | Can sort only 2 columns | Can sort 16 columns
Data searching (SGRows.Find method) | Non-functional | Functional
Auto-search (AutoSearch and AutoSearchDelay properties) | Non-functional | Functional
Scrollbar width and height | Read-only | Read-write

1Limited only with system resources


Title

License and Redistributable Files

BeeGrid 1.0 is developed and published by Stinga. You may use BeeGrid 1.0 for development with any programming environment. You may distribute the following files, royalty free, with any application you develop (see bellow for BeeGrid Free Edition restrictions):

BEEGD10.OCX | This is an ICursor-based BeeGrid v1.0 control compatible with the intrinsic data control of Visual Basic.
BEEGDO10.OCX | This is an OLEDB-based BeeGrid v1.0 control compatible with OLEDB and ADO data sources.

If you are building a development environment, please contact Stinga regarding a licensing arrangement for inclusion of design-time BeeGrid with your product.

BeeGrid 1.0 Free Edition can not be distributed as a part of any application in which, when used in a design-time development environment, the programmatic interface of the BeeGrid 1.0 control is exposed.

End-users of your applications are not licensed to use BeeGrid for any development, and may not redistribute any of the above files.

You are not licensed to distribute any BeeGrid file to users for development purposes. You are not allowed to add or transfer the BeeGrid license key and/or registration code to the registry of your user's computer(s).

In particular, if you create a control using a BeeGrid component as a constituent control, you are not licensed to distribute the control you created with the BeeGrid component to users for development purposes.

It is your responsibility to make such restrictions clear to your users.


What's New

Version 1.13 changes and additions

  • Added hWnd property. The hWnd property returns the control's main window handle.

  • Added DataEntryLocked property. The DataEntryLocked property can be used to temporarily disable data editing.

  • Added sgRowStatusCollapsed constant to the sgRowStatus enumeration.

  • Third parameter in the Sort method can now be a Variant array that contains sorting specification. First element in the array is a field name, second is sorting order and third is sorting type.

  • Images can be retrieved from the server side cursor and displayed in the grid cell.

  • Several bug fixes.

  • New VC++ BinaryData sample in the Samples/VC/MFC folder.

Version 1.12 changes and additions

  • Added EditText property. It returns or sets the text in the active cell-editor window.

  • Behavior of the SGGrid.Value and SGGrid.ValueEx properties is slightly changed for the situation where the following conditions are satisfied:

    • Edited column has a collection of value items.
    • LimitToList property set to True.
    • Cell-editor is active.
    • Text displayed in the active cell editor can not be resolved by the column's value items collection.

    In previous versions, value returned from the Value and ValueEx properties was a text displayed in the cell-editor window. From version 1.12, the Value and ValueEx properties returns an empty variant. The EditText property can be used to access text displayed in the cell-editor window.

  • When the grid is in a list-box mode (SpecialMode property is set to sgModeListBox) and OLEDragMode is set to sgOLEDragModeAutomatic, pressing left mouse button over the the group of selected rows, initiates the OLE drag/drop operation. In previous versions, current selection was cleared and clicked row was selected. This change simplifies OLE drag/drop operations.

  • Several bug fixes.

  • New MFC sample in the Samples/VC folder.

Version 1.11 changes and additions

  • CancelEdit method.
  • LoadAllRecords method.
  • Several bug fixes.

Version 1.1 changes and additions

  • ShadowColor and HighlightColor properties.
  • PostMessage method.
  • PostMessageEvent event.
  • LoadArray method.
  • AutoSearch and AutoSearchDelay properties.
  • SGRanges collection's indices starts from 1. In previous versions this collection was zero based.
  • SGValueItems collection's indices starts from 1. In previous versions this collection was zero based.
  • Several bug fixes.

For a more detailed and up to date list of changes, please visit our WWW site at http://www.stinga.com/beegrid/history.asp.


BeeGrid License Agreement

Pro Edition License Agreement

This License Agreement defines the scope of your license. Please treat it as valuable property.

END-USER LICENSE AGREEMENT FOR BeeGrid 1.13 PRO EDITION:

VERY IMPORTANT - READ CAREFULLY: This End-User License Agreement (hereinafter "EULA") is a legal agreement between you (either an individual or a single entity) and Stinga (hereinafter "STINGA"), for the use of the BeeGrid Pro Edition product, which includes "on-line" or electronic documentation (hereinafter "SOFTWARE" or "SOFTWARE PRODUCT"). By installing and/or using the SOFTWARE, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, do not download and/or use SOFTWARE from STINGA.

SOFTWARE PRODUCT LICENSE

Copyright laws and international copyright treaties, as well as other intellectual property laws and treaties protect the SOFTWARE. The SOFTWARE is licensed, not sold.

I. GRANT OF LICENSE. This EULA grants you the following rights:

A. You may install and use one copy of the enclosed SOFTWARE PRODUCT on a single computer to design, develop, and test software application products ("Application"). The SOFTWARE is in "use" on a computer when it is loaded into temporary memory (e.g., hard disk, CD-ROM, or other storage device) of that computer. However, installation on a network server for the sole purpose of internal distribution shall not constitute "use" for which a separate license is required, provided you have a separate license for each computer to which the software is distributed.

B. SOFTWARE PRODUCT KEY. The SOFTWARE package includes a unique SOFTWARE PRODUCT KEY, which allows for the registration of the SOFTWARE. The SOFTWARE PRODUCT KEY, is subject to the restrictions set forth in this license agreement and may not be distributed either with your applications, application components or in any other way.

C. STINGA grants you a royalty-free right to reproduce and distribute the SOFTWARE with your applications or application components provided that you (i) do not distribute, bundle, wrap or subclass the SOFTWARE as a component which, when used in a DESIGNTIME development environment exposes the programmatic interface of the SOFTWARE; (ii) distribute the SOFTWARE only in conjunction with and as a part of your application (".EXE") or as an application component; (iii) do not use STINGA's name, logo, or trademarks to market your application or application component without the express written consent of STINGA; (iv) include STINGA's copyright notice for the SOFTWARE on your product label or in the "About Box" of your application; (v) agree to indemnify, hold harmless, and defend STINGA from and against any claims or lawsuits, including attorney's fees that may arise from the use or distribution of your application or application component with the SOFTWARE modules; (vi) use the SOFTWARE to create an application or an application component that is significantly different than the SOFTWARE. STINGA reserves all rights not expressly granted to you in this EULA.

II. TITLE; COPYRIGHT.
All title and copyrights in and to the SOFTWARE (including but not limited to any images, photographs, animation, video, audio, music, text, games, scripts and applets incorporated into the SOFTWARE), the accompanying printed materials, and any copies of the SOFTWARE are owned by STINGA or its suppliers. Copyright laws and international treaty provisions protect the SOFTWARE. Therefore, you must treat the SOFTWARE like any other copyrighted material.

III. ADDITIONAL RIGHTS AND LIMITATIONS.

A. No Separation of Components. The SOFTWARE is licensed as a single product and the software programs comprising the SOFTWARE may not be separated for use by more than one user at a time.

B. Rental. You may not rent or lease the SOFTWARE.

C. Software Transfer. You may NOT transfer any of your rights under this LICENSE.

D. Termination. Without prejudice to any other rights, STINGA may terminate this LICENSE if you fail to comply with the terms and conditions of this LICENSE. In such event, you must destroy all copies of the SOFTWARE.

IV. CROATIAN LAW.
Croatian copyright law description is described under paragraphs (NN53/91) and (NN58/93) defines software copyrights with sanction against violator described in subparagraph (95) and (96) and penalties for violators described in subparagraph (101) (103) and (103b). Croatian law can prosecute all violators by Croatian law and violator's domicile state law. Manufacturer is STINGA, Buconjiceva 14, Zagreb 10000, Croatia. International law may be applied under full extent against violator of this end user license agreement.

LIMITED WARRANTY

LIMITED WARRANTY. EXCEPT WITH RESPECT TO THIRD PARTY REDISTRIBUTABLES, WHICH ARE PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, STINGA WARRANTS THAT THE SOFTWARE WILL PERFORM SUBSTANTIALLY IN ACCORDANCE WITH THE ACCOMPANYING WRITTEN MATERIALS FOR A PERIOD OF THIRTY (30) DAYS FROM THE DATE OF RECEIPT. SOME STATES AND JURISDICTIONS DO NOT ALLOW LIMITATIONS OF DURATION OF AN IMPLIED WARRANTY, SO THE ABOVE LIMITATION MAY NOT APPLY TO YOU. TO THE EXTENT ALLOWED BY APPLICABLE LAW, IMPLIED WARRANTIES ON THE SOFTWARE, IF ANY, ARE LIMITED TO THIRTY (30) DAYS.

CUSTOMER REMEDIES. STINGA'S AND ITS SUPPLIERS' ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL BE, AT STINGA'S OPTION, EITHER

(A) RETURN OF THE PAID PRICE, OR (B) REPAIR OR REPLACEMENT OF THE SOFTWARE. PRODUCTS PURCHASED OTHER THAN DIRECTLY FROM STINGA SHALL BE RETURNED THROUGH THE RESELLER FROM WHICH IT WAS PURCHASED. THIS LIMITED WARRANTY IS VOID IF FAILURE OF THE SOFTWARE HAS RESULTED FROM ACCIDENT, ABUSE, OR MISAPPLICATION. ANY REPLACEMENT SOFTWARE WILL BE WARRANTED FOR THE REMAINDER OF THE ORIGINAL THIRTY (30) DAY PERIOD.

NO OTHER WARRANTIES. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, STINGA AND ITS SUPPLIERS DISCLAIM ALL OTHER WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH REGARD TO THE SOFTWARE. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO STATE/JURISDICTION.

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

LICENSEE ACKNOWLEDGES THAT IT HAS READ AND UNDERSTANDS THIS AGREEMENT AND AGREES TO BE BOUND BY ITS TERMS. LICENSEE FURTHER AGREES THAT THIS AGREEMENT IS THE COMPLETE AND EXCLUSIVE STATEMENT OF THE AGREEMENT BETWEEN LICENSEE AND LICENSOR, AND SUPERCEDES ANY PROPOSAL OR PRIOR AGREEMENT, ORAL OR WRITTEN, AND ANY OTHER COMMUNICATIONS RELATING TO THE SUBJECT MATER OF THIS AGREEMENT.


BeeGrid License Agreement

Free Edition License Agreement

This License Agreement defines the scope of your license. Please treat it as valuable property.

END-USER LICENSE AGREEMENT FOR BeeGrid 1.13 FREE EDITION:

VERY IMPORTANT - READ CAREFULLY: This End-User License Agreement (hereinafter "EULA") is a legal agreement between you (either an individual or a single entity) and Stinga (hereinafter "STINGA"), for the use of the BeeGrid Free Edition product, which includes "on-line" or electronic documentation (hereinafter "SOFTWARE" or "SOFTWARE PRODUCT"). By installing and/or using the SOFTWARE, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, do not download and/or use SOFTWARE from STINGA.

SOFTWARE PRODUCT LICENSE

Copyright laws and international copyright treaties, as well as other intellectual property laws and treaties protect the SOFTWARE. The SOFTWARE is licensed, not sold.

I. GRANT OF LICENSE. This EULA grants you the following rights:

A. You may install and use the enclosed SOFTWARE product on any number of computers to design, develop, and test software application products ("Application").

B. STINGA grants you a royalty-free right to reproduce and distribute the SOFTWARE with your applications or application components provided that you (i) do not distribute, bundle, wrap or subclass the SOFTWARE as a component which, when used in a DESIGNTIME development environment exposes the programmatic interface of the SOFTWARE; (ii) distribute the SOFTWARE only in conjunction with and as a part of your application (".EXE") or as an application component; (iii) do not use STINGA's name, logo, or trademarks to market your application or application component without the express written consent of STINGA; (iv) include STINGA's copyright notice for the SOFTWARE on your product label or in the "About Box" of your application; (v) agree to indemnify, hold harmless, and defend STINGA from and against any claims or lawsuits, including attorney's fees that may arise from the use or distribution of your application or application component with the SOFTWARE modules; (vi) use the SOFTWARE to create an application or an application component that is significantly different than the SOFTWARE. STINGA reserves all rights not expressly granted to you in this EULA.

II. TITLE; COPYRIGHT.
All title and copyrights in and to the SOFTWARE (including but not limited to any images, photographs, animation, video, audio, music, text, games, scripts and applets incorporated into the SOFTWARE), the accompanying printed materials, and any copies of the SOFTWARE are owned by STINGA or its suppliers. Copyright laws and international treaty provisions protect the SOFTWARE. Therefore, you must treat the SOFTWARE like any other copyrighted material.

III. ADDITIONAL RIGHTS AND LIMITATIONS.

A. No Separation of Components. The SOFTWARE is licensed as a single product and the software programs comprising the SOFTWARE may not be separated for use by more than one user at a time.

B. Rental. You may not rent or lease the SOFTWARE.

C. Software Transfer. You may NOT transfer any of your rights under this LICENSE.

D. Termination. Without prejudice to any other rights, STINGA may terminate this LICENSE if you fail to comply with the terms and conditions of this LICENSE. In such event, you must destroy all copies of the SOFTWARE.

IV. CROATIAN LAW.
Croatian copyright law description is described under paragraphs (NN53/91) and (NN58/93) defines software copyrights with sanction against violator described in subparagraph (95) and (96) and penalties for violators described in subparagraph (101) (103) and (103b). Croatian law can prosecute all violators by Croatian law and violator's domicile state law. Manufacturer is STINGA, Buconjiceva 14, Zagreb 10000, Croatia. International law may be applied under full extent against violator of this end user license agreement.

LIMITED WARRANTY

LIMITED WARRANTY. EXCEPT WITH RESPECT TO THIRD PARTY REDISTRIBUTABLES, WHICH ARE PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, STINGA WARRANTS THAT THE SOFTWARE WILL PERFORM SUBSTANTIALLY IN ACCORDANCE WITH THE ACCOMPANYING WRITTEN MATERIALS FOR A PERIOD OF THIRTY (30) DAYS FROM THE DATE OF RECEIPT. SOME STATES AND JURISDICTIONS DO NOT ALLOW LIMITATIONS OF DURATION OF AN IMPLIED WARRANTY, SO THE ABOVE LIMITATION MAY NOT APPLY TO YOU. TO THE EXTENT ALLOWED BY APPLICABLE LAW, IMPLIED WARRANTIES ON THE SOFTWARE, IF ANY, ARE LIMITED TO THIRTY (30) DAYS.

CUSTOMER REMEDIES. STINGA'S AND ITS SUPPLIERS' ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL BE, AT STINGA'S OPTION, EITHER

(A) RETURN OF THE PAID PRICE, OR (B) REPAIR OR REPLACEMENT OF THE SOFTWARE. PRODUCTS PURCHASED OTHER THAN DIRECTLY FROM STINGA SHALL BE RETURNED THROUGH THE RESELLER FROM WHICH IT WAS PURCHASED. THIS LIMITED WARRANTY IS VOID IF FAILURE OF THE SOFTWARE HAS RESULTED FROM ACCIDENT, ABUSE, OR MISAPPLICATION. ANY REPLACEMENT SOFTWARE WILL BE WARRANTED FOR THE REMAINDER OF THE ORIGINAL THIRTY (30) DAY PERIOD.

NO OTHER WARRANTIES. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, STINGA AND ITS SUPPLIERS DISCLAIM ALL OTHER WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH REGARD TO THE SOFTWARE. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO STATE/JURISDICTION.

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

LICENSEE ACKNOWLEDGES THAT IT HAS READ AND UNDERSTANDS THIS AGREEMENT AND AGREES TO BE BOUND BY ITS TERMS. LICENSEE FURTHER AGREES THAT THIS AGREEMENT IS THE COMPLETE AND EXCLUSIVE STATEMENT OF THE AGREEMENT BETWEEN LICENSEE AND LICENSOR, AND SUPERCEDES ANY PROPOSAL OR PRIOR AGREEMENT, ORAL OR WRITTEN, AND ANY OTHER COMMUNICATIONS RELATING TO THE SUBJECT MATER OF THIS AGREEMENT.


Supported Development Platforms

BeeGrid Pro version 1.12 and earlier is developed and supported by Stinga. Support is available for these development platforms:

  • Visual Basic 5
  • Visual Basic 6
  • Visual C++ 6
  • IE5

We will do our best to answer questions about the other platforms, but those listed above have a priority.


Technical Support

BeeGrid Pro 1.0 is developed and supported by Stinga. Product support for BeeGrid Pro 1.0 is provided through our WWW site and e-mail. Before you try to get in contact with us, please check our online FAQ and bug list.

Search | Search articles in our knowledge base.
FAQ | List of frequently asked questions and answers.
Bug List | Bug list contains articles describing all open and resolved issues.
E-mail | If you did not find solution in our FAQ and bug list, please email us at BeeGrid@stinga.com or support@stinga.com. In your email include your BeeGrid registration code, name and version of your operating system and development environment.

Support for the Free Edition users is also available but limited with our resources.


Basic

BeeGrid Basics

This chapter provides quick solutions to some typical tasks.

  • How to add the BeeGrid control to a VB Project?
  • Which data modes are supported?
    • Bound
    • Unbound
    • Virtual Events
    • Virtual Interface
  • Working with columns
  • Working with rows
  • Working with styles
  • Working with style conditions
  • Working with condition objects
  • Groups and grouping
  • Working with group calculations
  • Working with formulas
  • Using row filters
  • Using value items
  • Using images


BeeGrid Basics - Adding BeeGrid to a VB Project

See Also Send us your Feedback
BeeGrid Basics - Adding BeeGrid to a VB Project

There are two different BeeGrid controls. The first one (BEEGD10.OCX) supports older ICursor (DAO) data sources and the second one (BEEGDO10.OCX) supports OLEDB (ADO) based data source. Both controls supports unbound and virtual data modes.

File Name |  | Description | Data Source
 | BEEGD10.OCX | Stinga BeeGrid Control 1.0 (ICursor) | VB Data Control (VB5,VB6)
 | BEEGDO10.OCX | Stinga BeeGrid Control 1.0 (OLEDB) | OLEDB Recordset, ADO Data Control, Data Environment

Follow these instructions to add BeeGrid control to the VB Project:

  • Press Ctrl+T or select Components from Project menu.
  • Check the Stinga BeeGrid Control 1.0.
  • Press OK or Apply button to add control to the Visual Basic Toolbox.

See Also

License and Redistributable Files


BeeGrid Basic - Data Modes

BeeGrid Basics - Data Modes

When you start to build an application with BeeGrid control, as a first step you have to choose which data mode to use. Data mode defines where is data that is displayed in grid cells, stored. In bound mode grid is connected to the ICursor (DAO) or OLEDB (ADO) recordset. In unbound mode grid uses internal buffer for storing data, and in virtual modes, programmer is responsible for storing and maintaining data displayed in grid cells. The most of the grid's functionality is same for all data modes. For example, data validation, row grouping, row filtering and style manipulation are the same within all data modes. In addition, you can save grid layout in one data mode and use it in another.

BeeGrid supports following data access modes:

Bound

The grid is connected to the external data source: OLEDB (ADO) or ICursor (VB Data Control). In this mode grid is synchronized with data source and automatically handles data manipulation. This is the most common way of using BeeGrid control.

Unbound

In unbound mode, BeeGrid stores data in the internal two-dimensional array. You can access this internal array with the grid's Array property. Data can be easily saved and loaded with the ImportData and the ExportData methods. This is the simplest way to use the BeeGrid control.

Virtual Events

The BeeGrid control uses events to fetch and request data manipulation. Programmer must maintain data, usually in some kind of an array or recordset.

Virtual Interface

The grid uses custom COM interface as an interface to the data source. This mode is useful when you have large amounts of data stored in custom structures or objects.


BeeGrid Basic - Bound

See Also Send us your Feedback
BeeGrid Basics - Bound Data Mode

BeeGrid 1.0 includes two separate grid controls, one for the older ICursor data sources and one for the OLEDB based data source. The ICursor grid can bind to Visual Basic's intrinsic Data control. The OLEDB grid control can bind to the Microsoft's ADO Data Control, the Data Environment or directly to OLEDB recordset.

To use bound mode, set the grid's DataMode property to sgBound. Then, set the DataSource property to reference a data source. If the AutoFields property is set to True, grid will automatically derive new column bindings from the data source during its binding process. If you want to create columns layout manually, use the DBField property of the Column object to bind database field to a particularly column. Setting DBField property to an empty string, creates unbound column and FetchColumnData event will be fired to fetch data for that column.

In Bound data mode some restrictions apply:

  • The ICursor version does not display pictures stored in BLOB fields.
  • The OLEDB version display pictures stored in BLOB only if the recordset's CursorLocation property is set to adUseClient.
  • The RDO and MS Remote Data Control are not supported.

See Also


BeeGrid Basic - Unbound

See Also Send us your Feedback
BeeGrid Basics - Unbound Data Mode

The unbound data mode is very simple to use. With just a few lines of code you can create functional forms and applications. Note that in this mode, all data is stored in grid's internal array and if you need to handle large amounts of data, grid could reserve large blocks of memory. Array property can be used to access data stored in the grid's internal buffer.

By default, grid is in an unbound data mode.

Following these steps to use grid in an unbound data mode:

  1. Create columns and rows. The easiest way is to set the DataColCount and the DataRowCount properties.
  2. Use the Value property of the SGArray object to populate the data array from the code.
  3. Load and save data using the ImportData and the ExportData methods.

Note: if you import/export data to the XML format, grid will use the column's DBField property to load data to a particular column.


BeeGrid Basic - Virtual Events Mode

See Also Send us your Feedback
BeeGrid Basics - Virtual Events Mode

In Virtual Events data mode, grid uses events to fetch cell data. Data must be stored and maintained by application itself. Four virtual data mode events are used for reading, writing, adding and deleting rows.

When grid needs data for a row it fires VirtualReadData event. In an event handler, you must initialize SGRowBuffer object passed as a parameter. To pass row data to grid control, use Value property. To inform grid that there are no more rows, set RowIndex property to -1.

When user changes data, grid fires VirtualWriteData event and you should copy data from the SGRowBuffer to your application's buffer. Also, you can cancel data update by setting Cancel property to True.

When a new row needs to be added, grid fires VirtualAddRow event. Row buffer parameter contains data for a new row and you should store it into the application's dataset. Add row operation can be canceled by setting Cancel parameter to True.

When a row must be deleted, grid fires VirtualDeleteRow event. Use RowIndex and RowBookmark parameters to identify row that should be deleted from the application's dataset. To cancel row delete operation, set Cancel parameter to True.


BeeGrid Basic - Virtual Interface Mode

See Also Send us your Feedback
BeeGrid Basics - Virtual Interface Mode

Grid in Virtual Interface data mode uses custom COM interface to access data. Data itself must be stored and maintained by application. Virtual Interface data mode advantages are speed and flexibility. To use this mode, you need to create object that implement IsgGridDataSource interface and assign that object to the SimpleDataSource property. In Visual Basic, Implements keyword is used to implement interface in class or form module.

The IsgGridDataSource interface contains these functions:

  • AddRow Called when a new row should be added the data source.
  • DeleteRow Called when a row should be deleted from the data source.
  • GetRowCount Returns number of rows provided by the data source implementation.
  • GetRowData Called to retrieve data for the specified row.
  • SetRowData Called to modify row's data.
Note: this mode doesn't use bookmarks.


BeeGrid Basic - Columns

See Also Send us your Feedback
BeeGrid Basics - Columns

Grid columns are represented with SGColumns collection and each column is represented by SGColumn object. By manipulating these objects, you can add or remove columns and change column attributes. To reference a particular column, you can use column position, column index or column key.

Column position is a current left-to-right counted position of a column in a grid. Left-most column has position 0 (zero). Column position can be changed when user drags and drops column in a grid. If a column is hidden, its position is not changed. To access column with its position use column collection's At method.

Column index is a unique number that is assigned to a column when it is created. Heading column (column with row selectors) has index with value zero. Data columns indices start with 1. Changing column position does not change its index, but when columns are added or removed from the columns collection or when columns layout is restored (with SetDefinition method), value of the ColIndex property can change. To access column by its index, use Columns(index) syntax.

Column key is a unique, user-defined string that identifies one column. The Key property can be initialized when you use the Add method to create a new column. Column key can not be changed. Use column key to refer to columns when you are not sure that column indices will not be changed and when you want to assign meaningful names to columns. To access column by its key, use Columns(key) syntax.

The following list explains how to solve some common column tasks.

To add a column
  • Use column's Add or InsertAt method to add one column.
  • Use column collection's SetDefinition method to initialize all columns in one step.
To remove a column
  • Use the column collection's RemoveAll method to remove all columns.
  • Use column's Remove or the RemoveAt method to remove one column.
To bind a column
  • In the bound data mode, set the AutoFields to true and grid will automatically create columns for all data source fields.
  • Set the column's DBField property to a name of the data source field.
To unbind a column
  • Set the column's DBField property to an empty string.
To hide a column
  • Set the column's Hidden property to True.
  • Set the column's UserHiding property to sgAllowColHide or sgAllowRowColHide to allow users to hide columns.
To move a column
  • Change the column's Position property.
  • Set the column's UserDragging property to sgAllowColDrag or sgAllowRowColDrag to allow users to move columns.
To size a column
  • Set the column's Width property.
  • In the bound mode, set the column's AutoResize property to sgAutoResizeColumns or sgAutoResizeRowsAndColumns to fit each column with its contents.
  • Call the AutoSizeColumns method to auto size columns.
  • Set the UserResizing property to sgAllowColResizing or sgAllowRowColResizing to allow the user to size columns.
To change column appearance
  • Use the column's Style property.
  • Set the column's FetchCellStyle property to True and change column's appearance in the FetchCellStyle event.
  • Use the column's SGStyleConditions collection to add conditional styles to a column.


BeeGrid Basic - Rows

See Also Send us your Feedback
BeeGrid Basics - Working With Rows

Grid rows are represented with SGRows collection and each row is represented by SGRow object. By manipulating these objects, you can add or remove rows and change row attributes. There are three types of rows: simple rows (sgSimpleRow), group header rows (sgGroupHeader) and group footer rows (sgGroupFooter). Simple row is bound to the data source and it displays data retrieved from the data source. Group header or footer row displays values and calculation results defined in the SGGroup object.

To reference a particular row, you can use row position, row key or row bookmark.

Row position is a current top-to-bottom counted position of a row in a grid. Top-most row has position 0 (zero). Row position can be changed when grid is sorted or when user drags and drops a row in a grid. If a row is hidden, its position is not changed. To access row with its position use row collection's At method.

Row key is a unique number that identifies one row. It is assigned to a row at row creation time and can not be changed. To access row with its key, use Rows(key) syntax.

A bookmark is a variant that uniquely identifies a particular record in a database.

The following list explains how to solve some common row tasks.

To add a row
  • Use the row collection's Add or InsertAt method.
To remove a row
  • Use the row collection's Remove method to delete one row.
  • Use the Delete method to remove the current row.
  • Set the AllowDelete property to True to allow users to delete the current row with the Del key.
To size a row
  • Use the row's Height property.
  • Use the AutoSizeRows method to auto size rows.
  • Set the UserResizing property to sgAllowRowResizing or sgAllowRowColResizing to allow users to size a row.
  • In the bound mode, set the AutoResize property to sgAutoResizeRows or sgAutoResizeRowsAndColumns to fit each row with a its contents.
To move a row
  • Use the row's Position property.
  • Set the UserDragging property to sgAllowRowDrag or sgAllowRowColDrag to allow users to move a row.
To hide a row
  • Set the row's Hidden property to True.
  • Set the UserHiding property to sgAllowRowHide or sgAllowRowColHide to allow users to hide a row.
To change row appearance
  • Use the row's Style property.
  • Use the RowStyleConditions collection to add conditional styles to a row.


BeeGrid Basic - Working With Styles

See Also Send us your Feedback
BeeGrid Basics - Working With Styles

The BeeGrid uses a style model to simplify customization of grid's appearance. BeeGrid styles are organized in a Style hierarchy with the "Normal" style in the hierarchy root. Following list shows predefined styles and their relationship.

Normal | Root of the style hierarchy. Attributes of this style are applied when no other style defines particular attribute.
Heading | Applied to the row and column headings.
Caption | Applied to the grid caption.
Selection | Applied to the selection.
InactiveSelection | Applied to the selection when grid doesn't have input focus.
CurrentRow | Applied to all cells in a current row.
CurrentCell | Applied to the current cell.
FilteredRow | Applied to the filtered row.
FrozenRow | Applied to the frozen row.
GroupHeader | Applied to the group headers.
GroupFooter | Applied to the group footers.
Tip | Applied to the cell and scroll tips.
PreviewPane | Applied to the preview pane.
GroupByBox | Applied to the group-by box.
GroupByBoxCell | Applied to cells inside the group-by box.
GridBackground | Applied to the grid background.

Each SGStyle object encapsulates appearance attributes such as a font, picture, color, Alpha blending or formatting. Style hierarchy enables attribute inheritance, so for example, if color is not initialized in one style, it is inherited from a parent style.

When BeeGrid draws a particular cell it uses styles applied to that cell to determine its appearance. This is a list that defines the order in which styles are applied.

  1. Grid's "Normal" style.

  2. Style from the row's Style property

  3. Style from the column's Style property.

  4. Conditional styles from the RowStyleConditions collection. Styles are applied in their collection order.

  5. Conditional styles from the StyleConditions collection. Styles are applied in their collection order.

  6. Conditional styles from the CellStyleConditions collection. Styles are applied in their collection order.

  7. If cell is a member of the group header or footer row, "GroupHeader" or "GroupFooter" styles are applied.

  8. If cell is a row or column heading, "HeadingStyle" is applied.

  9. If cell is a column heading cell, style from the column's HeadingStyle property

  10. If cell is a row heading cell, style from the first column's Style property.

  11. Style from the cell's Style property.

  12. Even/odd row colors.

You can create your own styles with the Add method of the SGStyles collection.

Dim sty As SGStyle

Set sty = SGGrid1.Styles.Add("MyStyle")

To access style from the Styles collection use its name. For example, to access the "Normal" style use following syntax:

Dim sty As SGStyle

Set sty = SGGrid.Styles("Normal")

To save and load style definitions use the GetDefinition and SetDefinition methods of the SGStyles collection.


Basics - Working With Style Conditions

See Also Send us your Feedback
Basics - Working With Style Conditions

The StyleConditions collection gives you a flexible and powerful way to apply style to an object that meets specified condition. Style conditions can be applied to cells and rows. There are three places where you can define style conditions:

  • To apply style condition to any cell that meets criteria use the grid's CellStyleConditions collection.
  • To apply style conditions to cells in one column, use the column's StyleConditions collection.
  • To apply style conditions to all cells in a row, use the grid's RowStyleConditions collection.

The code bellow demonstrates style condition usage. Note that last parameter in the RowStyleConditions.Add method is a key of the column whose values are used when evaluating condition. That parameter is ignored when adding style conditions to the column's style condition collection.

Copy Code

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j  As Integer

   With SGGrid1
      'create columns and rows
      .Columns.RemoveAll False
      For i = 1 To 5
         With .Columns.Add("Column " & Trim(i))
            .DataType = sgtShort
         End With
      Next

      .DataRowCount = 10
      'create new global cell style condition
      With .Styles.Add("CellCond")
         .BackColor = vbRed
         .BackColor2 = vbWhite
         .BkgStyle = sgCellBkgGradientVertical
      End With

      .CellStyleConditions.Add _
         "CellCond", sgConditionCellValue, _
         sgOpBetween, 2, 12

      'create new row style condition
      With .Styles.Add("RowCond")
         .Font.Bold = True
         .ForeColor = RGB(0, 128, 0)
         .BackColor = vbYellow
         .TextAlignment = sgAlignCenterCenter
      End With

      .RowStyleConditions.Add _
         "RowCond", sgConditionCellValue, _
         sgOpBetween, 2, 12, "Column 3"

      'create new column style condition
      With .Styles.Add("ColCond")
         Set .BkgPicture = Me.Icon
         .BkgPictureAlignment = sgPicAlignTile
      End With

      .Columns("Column 4").StyleConditions.Add _
         "ColCond", sgConditionCellValue, sgOpGreaterThan, 5

   End With
   'populate grid with data
   For i = 0 To 9
      For j = 0 To 4
         SGGrid1.Array.Value(i, j) = i * j
      Next
   Next
End Sub

The column's DataType property is important and determines how are conditions evaluated. For example, when column type is sgtString, value "400" is smaller than value "5".

The code below shows results for a different data types.

Copy Code

Private Sub SGGrid1_OnInit()
   SGGrid1.Columns.RemoveAll False
   SGGrid1.DataRowCount = 5

   With SGGrid1.Columns.Add("String")
      .DataType = sgtString
   End With

   With SGGrid1.Columns.Add("Number")
      .DataType = sgtDouble
   End With

   With SGGrid1.Columns.Add("Date")
      .DataType = sgtDateTime
   End With

   SGGrid1.CellStyleConditions.Add "Heading", sgConditionCellValue, sgOpGreaterThan, 400

   With SGGrid1.Array
      'string column
      .Value(0, 0) = "39898"           'No
      .Value(1, 0) = "5"               'Yes
      'number column
      .Value(0, 1) = 39898             'Yes
      .Value(1, 1) = 5                 'No
      'date column
      .Value(0, 2) = CDate(39898)      'Yes
      .Value(1, 2) = CDate(5)          'No
   End With
End Sub


BeeGrid Basics - Condition Objects

See Also Send us your Feedback
BeeGrid Basics - Condition Objects

SGCondition object encapsulates a simple condition expression used by group calculations, filters and conditional styles. Condition expression has following form:

LhsValue operator (RhsValue1, RhsValue2)

LhsValue (left-hand-side value) is a value defined by the object that uses condition. For example, in conditional style, LhsValue is a value of the cell to which conditional style is applied.

RhsValue1 and RhsValue2 (right-hand-side values) are values stored in the condition object. These values are compared with the LhsValue. RhsValue2 is used only if sgOpBetween or sgOpCallback operator is specified.

Operator can be one of following constants:

sgOpFalse | Always fail.
sgOpTrue | Always succeed.
sgOpLessThan | Succeeds if the left-side value is smaller then the right-side value.
sgOpLessThanOrEqual | Succeeds if the left-side value is smaller than or equal to the right-side value.
sgOpGreaterThan | Succeeds if the left-side value is greater then the right-side value.
sgOpGreaterThanOrEqual | Succeeds if the left-side value is greater then or equal to the right-side value.
sgOpEqual | Succeeds if the left-side value is equal to the right-side value.
sgOpBetween | Succeeds if the left-side value is both greater then the first right-side value and smaller or equal to the second right-side value.
sgOpContains | Succeeds if left-side value is contained in the right-side value. Applies only to string and integral (byte, short, long) types.
sgOpRegEx | Succeeds if regular expression is matched. Applies only to string values.
sgOpCallback | Uses the custom IsgConditionTest interface to test an LhsValue value. RhsValue1 should be an object that implements IsgConditionTest interface. RhsValue2 is a Tag value passed as the Test method's Tag parameter.
sgOpNot | Negate operator. Can be used only in a combination with some other operator.

Along with Operator, Value1 and Value2 (rhs values) properties, SGCondition object has the CaseSensitive property that indicates whether string comparation is case-sensitive. Also, you can use the GetDefinition and SetDefinition methods to save and load comparation expression as an XML string.

See Also

SGCondition


BeeGrid Basics - Groups and Grouping

See Also Send us your Feedback
BeeGrid Basics - Groups and Grouping

The BeeGrid control can group successive rows that have the same value in the grouping column. Grouping column is a column that is specified, with some other group settings, by the SGGroup object. Each group has a group heading row and each group can have a group footer row. Group header and footer rows display values defined by the SGGroup properties. Among other things, group header and footer can show results from various calculation and formulas.

Groups can be created from code and/or you can allow users to drop column headers into the group-by box.

Creating group definitions in code

Use the Add method of the SGGroups collection to create new group definition. With Add method parameters, you can control whether grouping column is going to be sorted (SortOrder parameter) and whether grouping should occur before Add method finishes (DoRefresh parameter). Typically, if recordset is already sorted, you do not want to sort it again. Also, if you are adding more than one group, it's more efficient to regroup only when last group is added. Note that you can use the RefreshGroups method to regroup rows any time later.

Group definitions can be persisted with the SGGroups collection's GetDefinition and SetDefinition methods. Use the GetDefinition method to retrieve XML presentation of the current group settings. Returned string can be saved to a file, database or some other persistent storage. Later, you can use the SetDefinition method to recreate group settings.

Group-by box

To allow users to group data, you should enable the group-by box. The group-by box is a rectangle area at the top of the grid into which a user can drop a column header. To enable group-by box, set GroupByBoxVisible property to True. To change text displayed in the group-by box, use the GroupByBoxText property. Built-in style "GroupByBox", can be used to change box's appearance. For example, the code below changes the box's background color:

SGGrid1.Styles("GroupByBox").BackColor = RGB(240, 255, 255)

When a column header is dropped into the group-by box, two events gives you an opportunity to control user actions. Before a group is added, deleted or moved, the BeforeGroupChange event is fired. In this event's handler, you can enable or disable sorting (if recordset is already sorted), change sorting parameters, show or hide group footer and eventually, cancel user actions. If an action was not canceled, the AfterGroupChange event occurs. In this event you can further customize attributes of the newly created group, or change attributes of the un-grouped column (e.g. hide it).

Group header and footer text

Which data is displayed in the group header and footer is controlled by the SGGroup object's HeaderTextSource and FooterTextSource properties. Following tables shows possible combinations.

HeaderTextSource value | What is displayed in the group header?
sgGrpHdrEmpty | Nothing.
sgGrpHdrColCaptionAndValue | Value of the Caption property and grouping value are separated by a semicolon (:).
sgGrpHdrCaptionAndValue | Value of the HeaderCaption property and grouping value are separated by a semicolon (:).
sgGrpHdrCaption | Value of the HeaderCaption property.
sgGrpHdrFormula | Result of the formula contained in the HeaderFormula property.
sgGrpHdrFireFetchText | Data returned from the FetchGroupHeaderData event.

FooterTextSource value | What is displayed in the group footer?
sgGrpFooterEmpty | Nothing.
sgGrpFooterCaption | Value of the FooterCaption property.
sgGrpFooterFormula | Result of the formula contained in the FooterFormula property.
sgGrpFooterFireFetchText | Data returned from the FetchGroupFooterText event

For more info on grid formulas, please click here.

Group header pictures

You can show a picture inside the group header row. To control which picture is displayed when group is collapsed, use the PictureCollapsed property. For picture on expanded group, use the PictureExpanded property. Following table shows possible values for these properties.

PictureCollapsed or PictureExpanded value | Which picture is displayed?
Empty variant | No picture is displayed.
Picture object | Picture represented by this picture object
Integer value smaller then sgbipFirst | Picture from the image list assigned to the SGGrid.ImageList.
sgbipFirst + X | Picture from the built-in image list.
sgGroupHeaderColumnPicture | Picture from the grouped column's HeadingPicture property.
sgGroupHeaderFetchPicture | Picture returned from the FetchGroupHeaderData event.

Customizing group header and footer appearance

To customize group header and footer appearance, change attributes of the "GroupHeader" and "GroupFooter" built-in styles. If you want to apply different styles to different group headers and footers, you can set the FetchHeaderStyle and/or FetchFooterStyle properties to True and handle the FetchGroupHeaderStyle and FetchGroupFooterStyle events.

Enumerating groups

To enumerate groups, you can use SGRows or SGGroupHeadings collections. When you use SGRows collection, check the row object's Type property. For a group header it will have sgGroupHeader value.

Grid's GroupHeadings property is a collection of all root level group headings. Each heading in this collection is represented with one SGGroupHeading object. Since the SGGroupHeading object has collections of child groups and rows, you can look at the grid's GroupHeadings property as o root of the group hierarchy. The code below recursively enumerates all groups in the grid:

Private Sub EnumGroups(ghs As SGGroupHeadings)
   Dim gh As SGGroupHeading

   For Each gh In ghs
      ' Print group header text
      Debug.Print gh.Row.Cells(0).Value & " (" & gh.ChildRows.Count & ")"
      EnumGroups gh.Headings
   Next
End Sub


BeeGrid Basics - Group Calculations

See Also Send us your Feedback
BeeGrid Basics - Group Calculations

Each group can have a collection of numerical calculations associated with it. Group calculations are represented with a collection of SGCalculation objects. When you add a calculation to a group definition, grid will apply it to records in that group. Result of a calculation can be accessed from code or you can use group formula to show it inside group header or footer.

For example, the following code will calculate a total of the 'Amount' column and show it inside the group footer row:

Dim grp As SGGroup
grp.Calculations.Add sgCalcSum, "Amount"
grp.HeaderTextSource = sgGrpHdrFormula
grp.HeaderFormula = "'Total: ' & GroupCalc(1)"

By default, calculation uses all rows in a group. If you want to skip some rows, you should use conditions. When you create a new calculation with the Add method, you can specify a condition which must be satisfied for a row to be used in a calculation. Following code will calculate total across all items that are not discontinued:

Dim grp As SGGroup
grp.Calculations.Add sgCalcSum, "Amount", "Discontinued", sgOpNot + sgOpEqual, True
grp.HeaderTextSource = sgGrpHdrFormula
grp.HeaderFormula = "'Total: ' & GroupCalc(1)"

Result of a calculation can also be accessed from a code. To access it, use CalculationResult property. In the following example, the FetchGroupFooterText event is used to display custom text in the group footer.

Private Sub SGGrid1_FetchGroupFooterText(ByVal GroupIndex As Integer, _
                                         ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading
   Set gh = SGGrid1.Rows(RowKey).Parent

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub


BeeGrid Basics - Formula Syntax

See Also Send us your Feedback
BeeGrid Basics - Formula Syntax

To customize values displayed in the group headers and footers, you can use custom formulas. Formulas have simple VB-like syntax and can greatly improve your application appearance and functionality.

Formula operators

+ | Addition
- | Subtraction
* | Multiplication
/ | Division
& | String concatenation
( and ) | Subexpression grouping

Predefined read-only variables and functions

GroupingValue | Current group's grouping value.
ChildCount | Number of first level child rows.
TotalChildCount | Number of rows in the group (in all sublevels).
HeaderCaption | Value of the group's HeaderCaption property.
FooterCaption | Value of the group's FooterCaption property.
GroupColCaption | Value of the grouped column's Caption property.
GroupCalc(index) | Returns group calculation result. index is the index of the calculation in the Calculations collection.
Format(val, format) | Formats val value according to the VB-like format specified in the format parameter. Available only if host application provides Visual Basic formatting capabilities.

Following sample shows how to display count of child rows in the group footer.

Dim grp As SGGroup
Set grp = SGGrid1.Groups(1)
grp.FooterTextSource = sgGrpFooterFormula
grp.FooterFormula = "'Child row count is ' & ChildCount"


BeeGrid Basic - Using Filters

See Also Send us your Feedback
BeeGrid Basics - Using Row Filters

The BeeGrid control allows you to filter grid rows. When a row is marked with a filter marker, the grid can display it in some special manner. For example, row can be hidden or rendered with "FilteredRow" style. In addition, you can enumerate rows and perform some custom action on filtered rows.

Note that individual filter conditions are connected with a logical AND operation. That means that for a row to be marked, all conditions from the SGFilters collection must be satisfied.

Typically, to use row filters you follow these steps:

  • Create a new filter by using the Add method of the SGFilters collection. In addition, SGFilters collection can be saved and later loaded with GetDefinition and SetDefinition methods, respectively.

    SGGrid1.RowFilters.Add "MyFilter1", "C1", sgOpBetween, 10, 100

     If you set the ColKey parameter to an empty string ("") all columns will be included in the filter action.

  • Apply filters with the SGFilters collection's Apply method. This method enumerates all rows and marks rows that satisfy filter conditions with markers that are given as parameter.

Applied filters are persistent. That means that filter markers are not removed until ClearMarkers method is called or row itself is deleted. Also, filter is automatically applied after all changes in the existing data.


BeeGrid Basic - Value Items

See Also Send us your Feedback
BeeGrid Basics - Value Items

Value item is a mapping from a data source value to text and picture that will be displayed in a grid cell. Such a mapping is represented with the SGValueItem object. Each column has a ValueItems property that contains a collection of value items for that column.

To add value items to a column you can use the following code:

SGGrid1.Columns(1).Control.Type = sgCellDropList
SGGrid1.Columns(1).ValueItems.Add 1, "First"
SGGrid1.Columns(1).ValueItems.Add 2, "Second", LoadPicture("Second.bmp")
SGGrid1.Columns(1).ValueItems.Add 3, "Third", 1
When a column has value items, you can use the LimitToList property to control whether the user can enter a value not in a value items collection. Also, use the Translate property to enable or disable translation from the underlying data value to the display value.

The Default property can be used to indicate which item to show if underlying value does not match any item in the value items collection. This property does not have effect if the LimitToList property us set to True.

The ValueItemError event occurs when the user enters data that is not in the value items list and value items are enabled for the edited column. This event is useful when you want to add a new value to the SGValueItems collection.

When you sort a column with value items enabled, it will be sorted by its underlying data. To sort by display data, you can use custom sort or you can sort data in your code. For example, you can use an SQL statement or you can have a hidden column which you use for a sort operation. The Outlook Demo example uses various approaches for data sorting.

The code below demonstrates how to use and populate the ValueItems collection:

Copy Code

Private Sub SGGrid1_OnInit()
   Dim rs As Object
   Dim i As Integer
   Const adInteger = 3
   Const adBSTR = 8

   Set rs = CreateObject("ADODB.Recordset")

   rs.Fields.Append "Id", adInteger
   rs.Fields.Append "Caption", adBSTR, 50

   rs.Open

   For i = 1 To 10
      rs.AddNew
      rs!Id = i
      rs!Caption = "Item " & Trim(i)
      rs.Update
   Next

   SGGrid1.DataMode = sgBound
   Set SGGrid1.DataSource = rs

   With SGGrid1.Columns("Id")
      .Width = 2000
      .Control.Type = sgCellDropList
      .HeadingStyle.TextAlignment = sgAlignLeftCenter
      .Style.TextAlignment = sgAlignLeftCenter
      .Control.PopupStyle.TextAlignment = sgAlignLeftCenter
      While Not rs.EOF
         'if you try to add value items with the code
         'below the grid will accept field object not string
         '.ValueItems.Add rs!Id, rs!Caption
         'just convert it to long/string
         .ValueItems.Add CLng(rs!Id), CStr(rs!Caption)
         rs.MoveNext
      Wend
   End With

   rs.MoveFirst
End Sub


BeeGrid Basic - Images

See Also Send us your Feedback
BeeGrid Basics - Using Images

The BeeGrid control gives you several ways to show pictures in it. First, you can use a picture object. Second, you can use images from the image list associated with the grid (see the Images property) or the images from the built-in image list. Also, you can load image's binary data directly from a file or a database field.

How to use a picture object?

If you have pictures stored in files use the Visual Basic® LoadPicture method to load picture object. If you want use a picture stored in the standard Windows resources, use the Visual Basic® LoadResPicture function to load a picture object. When you save grid's layout with the GetLayoutString method, these pictures will also be saved.

How to use an image list?

To use an external image list, assign list's handle to the Images property. Later, when you want to reference an image from the image list use its index. The BeeGrid control has several built-in pictures and they are represented with constants from sgbipFirst to sgbipLast.

Note: The BkgPicture property cannot use the Image list.

How to load a picture as a byte array?

If a cell's data type is sgtBinary and cell's value is a byte array, BeeGrid will try to interpret byte array values as an image data. Formats supported are the same one supported by the Visual Basic® LoadPicture function. To display image stored as a byte array, follow these instructions:

  • Set the DataType property of the SGColumn object to sgtBinary.
  • Set the DisplayType property of the Column's SGStyle object to sgDisplayPicture.
  • Populate a cell with a byte array that represents a picture. You can use either the Value property of the Array object or the Value property of the SGCell object.

The code below demonstrates how to display picture from the file by using a byte array:

Copy Code

Private Sub SGGrid1_OnInit()
   Dim sFile As String
   Dim sWinDir As String
   Dim i As Integer

   SGGrid1.RedrawEnabled = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True

   'Column creations
   With SGGrid1.Columns.Add("File")
      .Caption = "File name"
      .Width = 2200
   End With

   With SGGrid1.Columns.Add("Picture")
      .Caption = ""
      .Width = 305
      .DataType = sgtBinary
      .Style.DisplayType = sgDisplayPicture
   End With

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.bmp", vbNormal)

   Dim iFile As Integer, lChunkSize As Long
   Dim arImages() As Byte

   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      iFile = FreeFile
      lChunkSize = FileLen(sWinDir & sFile)

      Open sWinDir & sFile For Binary As iFile

      arImages = (InputB(lChunkSize, iFile))
      SGGrid1.Rows.At(i).Cells(1).Value = arImages

      Close iFile
      sFile = Dir
   Loop

   SGGrid1.HeadingColCount = 1
   SGGrid1.RedrawEnabled = True
End Sub


Pattern Syntax

Back To Topic Send us your Feedback
Regular Expression Pattern Syntax

Literals

All characters are literals except: ".", "*", "?", "+", "(", ")", "{", "}", "[", "]", "^" and "$". These characters are literals when preceded by a "\". A literal is a character that matches itself.

Wildcard

The dot character "." matches any single character.

Repeats

A repeat is an expression that is repeated an arbitrary number of times. An expression followed by "*" can be repeated any number of times including zero. An expression followed by "+" can be repeated any number of times, but at least once. An expression followed by "?" may be repeated zero or one times only. When it is necessary to specify the minimum and maximum number of repeats explicitly, the bounds operator "{}" may be used, thus "a{2}" is the letter "a" repeated exactly twice, "a{2,4}" represents the letter "a" repeated between 2 and 4 times, and "a{2,}" represents the letter "a" repeated at least twice with no upper limit. Note that there must be no white-space inside the {}, and there is no upper limit on the values of the lower and upper bounds. All repeat expressions refer to the shortest possible previous sub-expression: a single character; a character set, or a sub-expression grouped with "()" for example.

Examples:

"ba*" will match all of "b", "ba", "baaa" etc.

"ba+" will match "ba" or "baaaa" for example but not "b".

"ba?" will match "b" or "ba".

"ba{2,4}" will match "baa", "baaa" and "baaaa".

Parenthesis

Parentheses are used to group items together into a sub-expression. For example the expression "(ab)*" would match all of the string "ababab".

Alternatives

Alternatives occur when the expression can match either one sub-expression or another, each alternative is separated by a "|". Each alternative is the largest possible previous sub-expression; this is the opposite behavior from repetition operators.

Examples:

"a(b|c)" could match "ab" or "ac".

"abc|def" could match "abc" or "def".

Sets

A set is a set of characters that can match any single character that is a member of the set. Sets are delimited by "[" and "]" and can contain literals, character ranges, character classes, collating elements and equivalence classes. Set declarations that start with "^" contain the compliment of the elements that follow.

Examples:

Character literals:

"[abc]" will match either of "a", "b", or "c".

"[^abc] will match any character other than "a", "b", or "c".

Character ranges:

"[a-z]" will match any character in the range "a" to "z" and in the range "A" to "Z".

Note that character ranges are highly locale dependent: they match any character that collates between the endpoints of the range. For example, [a-z] will match the ASCII characters a-z, and also 'A', 'B' etc.

Character classes are denoted using the syntax "[:classname:]" within a set declaration, for example "[[:space:]]" is the set of all whitespace characters. The available character classes are:

alnum | Any alpha numeric character.
alpha | Any alphabetical character a-z and A-Z. Other characters may also be included depending upon the locale.
blank | Any blank character, either a space or a tab.
cntrl | Any control character.
digit | Any digit 0-9.
graph | Any graphical character.
lower | Any lower case character a-z. Other characters may also be included depending upon the locale.
print | Any printable character.
punct | Any punctuation character.
space | Any whitespace character.
upper | Any upper case character A-Z. Other characters may also be included depending upon the locale.
xdigit | Any hexadecimal digit character, 0-9, a-f and A-F.
word | Any word character - all alphanumeric characters plus the underscore.
unicode | Any character whose code is greater than 255, this applies to the wide character traits classes only.

There are some shortcuts that can be used in place of the character classes:

\w in place of [:word:]

\s in place of [:space:]

\d in place of [:digit:]

\l in place of [:lower:]

\u in place of [:upper:]

To include a literal "-" in a set declaration you should make it the first character after the opening "[" or "[^", the endpoint of a range, or precede it with an escape character as in "[\-]". To include a literal "[" or "]" or "^" in a set then make them the endpoint of a range, or precede them with an escape character.

Line anchors

An anchor is something that matches the null string at the start or end of a line: "^" matches the null string at the start of a line, "$" matches the null string at the end of a line.

Escape operator

The escape operator may make the following character normal, for example "\*" represents a literal "*" rather than the repeat operator.

Single character escape sequences

The following escape sequences are aliases for single characters:

Escape sequence | Character code | Meaning
\a | 0x07 | Bell character.
\f | 0x08 | Form feed.
\n | 0x0A | Newline character.
\r | 0x0D | Carriage return.
\t | 0x09 | Tab character.
\v | 0x0B | Vertical tab.
\e | 0x1B | ASCII Escape character.
\0dd | 0dd | An octal character code, where dd is one or more octal digits.
\xXX | 0xXX | A hexadecimal character code, where XX is one or more hexadecimal digits.
\x{XX} | 0xXX | A hexadecimal character code, where XX is one or more hexadecimal digits, optionally a unicode character.
\cZ | z-@ | An ASCII escape sequence control-Z, where Z is any ASCII character greater than or equal to the character code for '@'.

The regular expression code in the BeeGrid control is based on the Regex++ library. Here follows its copyright notice.

Copyright (c) 1998-9 Dr John Maddock

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Dr John Maddock makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.


Tutorial

BeeGrid Tutorials

The following topics provide step-by-step instructions of how to accomplish the specified task. You can paste code from those tutorials into the Visual Basic® IDE.

  • Using bound data mode
  • Using unbound data mode
  • Using virtual events data mode
  • Using virtual interface data mode
  • Using styles


Tutor Data Modes

Tutorial - Data Modes

The following tutorials demonstrate some typical scenarios for each data mode. You can visit the Basics - Data modes chapter to learn more about BeeGrid data modes.

  • Bound
  • Unbound
  • Virtual Events
  • Virtual Interface


Tutor - Bound Mode

See Also Send us your Feedback
Tutorial - Bound Mode

This tutorial demonstrates how you can bind the BeeGrid control to the MS ADODC data control. In addition, you will learn how to sort and group data.

1. Simple Bound

  • From the Visual Basic® File menu, choose New Project.
  • Press Ctrl+T or select Components from Project menu. Check the Stinga BeeGrid Control 1.0 (OLEDB) and the Microsoft ADO Data Control 6.0 checkboxes.
  • Place a BeeGrid control and an ADO Data control on the form.
  • Create an ADODB connection.
    • Right-click on the ADO Data control and select ADODC properties.
    • Click the Build... button to open the Data link properties window.
    • Select Microsoft Jet 3.51 OLE DB Provider .
    • Click the Next button or click the Connection tab.
    • Enter the path of the NorthWind database (usually 'C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB').
    • Click the OK button to close the Data link properties window.
    • In the ADODC properties dialog select the RecordSource tab.
    • Set the Command Type property to 2 - adCmdTable.
    • Set the RecordSource property to table Catalog.
  • Set the DataMode property of the SGGrid1 control to 0 - sgBound.
  • Set the DataSource property of the SGGrid1 control to Adodc1.

Note that Picture field is automatically recognized and displayed as an image.

Show Me

2. Sorting And Merging Cells

  • Set the ColumnClickSort property to True. The column-click-sort does not work if data caching is not enabled, so set the CacheAllRecords property to True.
  • Right-click on the SGGrid1 and select Properties... to display the Property Pages dialog. Select the Columns Tab and click the Retrieve fields button to populate the grid with fields. Expand the Description column and set the property MergeCells to 1 - sgMergeFree.
    The following line sets the MergeCells from the code:
    SGGrid1.Columns("Description").MergeCells = sgMergeFree

Note: if you change columns properties using the Property Pages set the AutoFields property to False.

Show Me

3. PreviewPane

  • Set the PreviewPaneType property to sgPreviewPaneDefault.
  • Set the PreviewPanePosition property to sgPreviewPaneBottom.
  • Use the Picture column for the PreviewPaneColumn property.
  • Enlarge the PreviewPane using the PreviewPaneSize property.
  • Center picture on the PreviewPane using the "PreviewPane" style. You can do it from the code:
    SGGrid1.Styles("PreviewPane").PictureAlignment = sgPicAlignCenterCenter
  • Hide the Picture column using the Property Pages or the following code:
    SGGrid1.Columns("Picture").Hidden = True
Show Me

4. Groups

  • Add a group to the Groups collection. You can do it from the code:
    SGGrid1.Groups.Add "CategoryName", sgSortAscending, sgSortTypeString, False, True
  • Hide the CategoryName column from the Property Pages or from the code:
    SGGrid1.Columns("CategoryName").Hidden = True
Show Me

5. Frozen columns

  • You can define style for frozen columns using the "Frozen" style. For example, the code below changes the background of frozen columns:
    SGGrid1.Styles("Frozen").BackColor = &HDDFFFF
  • Set the property of the columns you want to freeze to True:
    SGGrid1.Columns("ProductName").Frozen = True
Show Me
Hide


Tutor - Unbound Mode

See Also Send us your Feedback
Tutorial - Unbound Mode

In this tutorial, you will learn how to use the unbound mode of the BeeGrid control.

1. Create Columns

  • From the Visual Basic® File menu, choose New Project.
  • Press Ctrl+T or select Components from Project menu. Check the Stinga BeeGrid Control 1.0 (OLEDB) checkbox.
  • Place a BeeGrid control on the form.
  • By default, the DataMode property is set to 1 - sgUnbound.
  • Set the AllowAddNew property to True.
  • Right-click on the SGGrid1 and select Properties... to display the Property Pages dialog. Select the Columns Tab and create the following columns: Rank, Trend, Name, Country, Points, Tours and Next Off. See picture.

    The following block creates columns from the code:

    Copy Code

Private Sub CreateColumns()
   Dim i As Integer, arKeys As Variant

   With SGGrid1
      .Columns.RemoveAll False
      .DataRowCount = 0
      .HeadingColCount = 1

      With .Columns.Add("Rank")
         .DBField = "Rank"
         .Width = 850
         .SortType = sgSortTypeNumber
         .DataType = sgtLong
         .Style.TextAlignment = sgAlignRightCenter
      End With

      With .Columns.Add("Trend")
         .DBField = "Trend"
         .Caption = ""
         .HeadingPicture = sgbipFirst + 6
         .HeadingStyle.DisplayType = sgDisplayPicture
      End With

      With .Columns.Add("Name")
         .DBField = "Name"
         .Caption = "Name"
         .Width = 2850
      End With

      With .Columns.Add("Country")
         .DBField = "Country"
         .Caption = "Country"
         .Width = 1850
      End With

      arKeys = Array("Points", "Tournament", "Next Off")
      For i = 5 To 7
         With .Columns.Add(arKeys(i - 5))
            .DBField = .Key: .Caption = .Key
            .Width = 900
            .DataType = sgtLong
            .SortType = sgSortTypeNumber
            .Style.TextAlignment = sgAlignRightCenter
         End With
      Next
   End With
End Sub
Show Me

2. Enable Editing

  • Set the AllowAddNew property to True.
  • Set the AllowDelete property to True.
  • Set the EnterKeyBehavior property to sgEnterKeyColumns to speed up keyboard navigation.
  • Set the TabKeyBehavior property to True if you prefer using the Tab key for the grid's column navigation rather to the control navigation.

    These properties can also be set using the following code:

    Copy Code

With SGGrid1
   .AllowAddNew = True
   .AllowDelete = True
   'keyboard navigation
   .EnterKeyBehavior = sgEnterKeyColumns
   .TabKeyBehavior = sgTabColumns
End With
Show Me

3. Load and Save Data

  • Load data with the following line:
    SGGrid1.ImportData App.Path & "\Tennis.txt", sgFormatCharSeparatedValue, , vbCr.
  • Save data with the following line:
    SGGrid1.ExportData App.Path & "\Tennis.txt", sgFormatCharSeparatedValue, sgExportOverwrite, , vbCr
Show Me

4. Value Items

  • You can add value items by using the Property Pages dialog or from code.
    The following code adds value items:

    Copy Code

WithSGGrid1.Columns("Trend")
   .Width = 305
   'change columns style
   .Style.DisplayType = sgDisplayPicture
   .Style.PictureAlignment = sgPicAlignCenterCenter
   'set columns control properties
   .Control.PopUpStyle.DisplayType = sgDisplayTextAndPicture
   .Control.Type = sgCellDropList
   .Control.ShowButton = sgHideButton
   .Control.Width = 1600
   .Control.PopupAlignment = sgPopupLeft
   'add value items. Use built-in pictures
   .ValueItems.Add 0, "Unchanged", sgbipFirst
   .ValueItems.Add 1, "Up", sgbipFirst + 3
   .ValueItems.Add 2, "Down", sgbipFirst + 2
   .ValueItems.Add 3, "New", sgbipFirst + 5
   .ValueItems.Translate = True
End With
Show Me

5. Group by the "Country" Column

  • Add group to the Groups collection. Do it by using the property pages or from the code:
    SGGrid1.Groups.Add "Country", sgSortAscending, sgSortTypeString, False, True
  • Hide the CategoryName column with property pages or from the code:
    SGGrid1.Columns("Country").Hidden = True
  • Enable sorting by setting the ColumnClickSort property to True.
    The following code groups data by the "Country" column and enables sorting:

    Copy Code

With SGGrid1
   .Groups.Add "Country", sgSortAscending, sgSortTypeString, False, True
   .Columns("Country").Hidden = True
   .ColumnClickSort = True
End With
Show Me

6. Change Styles

  • Heading - change heading by changing the HeadingBackColor, HeadingForeColor and HeadingFont properties.
  • Even-Odd Style - set the EvenOddStyle to sgEvenOddRows. Change default even/odd colors by setting the ColorEven and ColorOdd properties.
  • Enable row heading numbers by setting the RowNumbering property to True.
  • Fill in the empty space between cells and the grid's right border by setting the FitLastColumn to True.
  • Set the GridLines property to sgGridLineNone to hide grid lines.
  • Modify the "GroupHeader" style.
    To change the styles, use the following code:

    Copy Code

With SGGrid1
   'set heading style
   .HeadingBackColor = RGB(8, 105, 148)
   .HeadingForeColor = vbWhite
   .HeadingFont.Bold = True
   'even-odd stuff
   .ColorEven = vbWhite
   .ColorOdd = RGB(239, 239, 239)
   .EvenOddStyle = sgEvenOddRows
   'misc
   .FitLastColumn = True
   .RowNumbering = True
   .GridLines = sgGridLineNone
   .Styles("GroupHeader").BackColor = &HDDFFFF
End With
Show Me
Hide


Tutor - Virtual Events Mode

See Also Send us your Feedback
Tutorial - Virtual Events Mode

In this tutorial, you will learn how to use the Virtual Events data mode to display an array of variants. This tutorial covers reading, updating, adding and deleting records in the Virtual Events mode.

1. Read Data

  • From the Visual Basic® File menu, choose New Project.
  • Press Ctrl+T or select Components from Project menu. Check the Stinga BeeGrid Control 1.0 (OLEDB) checkbox.
  • Place a BeeGrid control on the form.
  • Set the DataMode property to 2 - sgVirtualEvents.
  • Insert the following declarations into the Declaration section of Form1:

    Copy Code

'variable to hold the data to be displayed in the grid
Private arData As Variant
'current rows count
Private mlRowsCount As Long
'max row count
Private Const MAX_ROWS = 100
  • Initialize data array into the Form_Load event:

    Copy Code

Private Sub Form_Load()
   mlRowsCount = 4
   ReDim arData(SGGrid1.DataColCount - 1, mlRowsCount)

   SGGrid1.DataRowCount = mlRowsCount
End Sub
  • Right-click on the SGGrid1 and select Properties... to display the Property Pages dialog. Select the Columns Tab and create the following columns: "Band", "Album", "Song", "Time".
  • Insert the following code into the VirtualReadData event:

    Copy Code

Private Sub SGGrid1_VirtualReadData(ByVal RowBuffer As IsgRowBuffer)
   Dim i As Integer

   For i = 0 To RowBuffer.ColumnCount - 1
      RowBuffer.Value(i) = arData(i, RowBuffer.RowIndex)
   Next

   If RowBuffer.RowIndex = mlRowsCount Then
      RowBuffer.RowIndex = -1
   End If
End Sub
Show Me

2. Write Data

  • Set the AllowEdit property to True.
  • Insert the following code into the VirtualWriteData event:

    Copy Code

Private Sub SGGrid1_VirtualWriteData _
   (ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   Dim i As Integer

   For i = 0 To RowBuffer.ColumnCount - 1
      arData(i, RowBuffer.RowIndex) = RowBuffer.Value(i)
   Next
End Sub
Show Me

3. Add New Row

  • Set the AllowAddNew property to True.
  • Insert the following code into the VirtualAddRow event:

    Copy Code

Private Sub SGGrid1_VirtualAddRow _
   (ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   Dim i As Integer

   If MAX_ROWS = mlRowsCount Then
      Cancel = True
      Exit Sub
   End If

   mlRowsCount = mlRowsCount + 1

   If mlRowsCount > UBound(arData, 2) Then
      ReDim Preserve arData(RowBuffer.ColumnCount - 1, mlRowsCount + 10)
   End If

   For i = 0 To RowBuffer.ColumnCount - 1
      arData(i, mlRowsCount - 1) = RowBuffer.Value(i)
   Next
End Sub
Show Me

3. Delete Row

  • Set the AllowDelete property to True.
  • Insert the following code into the VirtualDeleteRow event:

    Copy Code

Private Sub SGGrid1_VirtualDeleteRow _
   (ByVal RowIndex As Long, ByVal RowBookmark As Variant, _
   Cancel As Boolean)
   Dim i As Integer, j As Integer

   mlRowsCount = mlRowsCount - 1

   For i = RowIndex To mlRowsCount
      For j = 0 To UBound(arData, 1)
         arData(j, i) = arData(j, i + 1)
      Next
   Next
End Sub
Show Me

4. Group and Sort Data

Grouping and sorting is the same as in all other modes.
  • Set the CacheAllRecords property to True. This is required by the ColumnClickSort property.
  • Set the ColumnClickSort property to True.
  • Add group to the Groups collection. You can do it from the code:
    SGGrid1.Groups.Add "Band", sgSortAscending, sgSortTypeString, False, True
Show Me

Hide


Tutor - Virtual Interface

See Also Send us your Feedback
Tutorial - Virtual Interface

In this tutorial, you will learn how to use the Virtual Interface data mode to display an array. It demonstrates how to implement the IsgGridDataSource interface and how to use its functions to implement read, update, add and delete operations.

1. Read Data

  • From the Visual Basic® File menu, choose New Project.
  • Press Ctrl+T or select Components from Project menu. Check the Stinga BeeGrid Control 1.0 checkbox.
  • Place a BeeGrid control on the form.
  • Set the DataMode property to 3 - sgVirtualInterface.
  • Insert the following declarations into the Declaration section of Form1:

    Copy Code

Implements IsgGridDataSource
'variable to hold the data to be displayed in the grid
Private arData() As Long
'current rows count
Private mlRowsCount As Long
  • Init data array into the Form_Load event:

    Copy Code

Private Sub Form_Load()
   mlRowsCount = 2
   ReDim arData(mlRowsCount) As Long
   'speed up data input
   SGGrid1.EnterKeyBehavior = sgEnterKeyRows
   Set SGGrid1.SimpleDataSource = Me

   arData(0) = 100
   arData(1) = -100
End Sub
  • Right-click on the SGGrid1 and select Properties... to display the Property Pages dialog. Select the Columns Tab and create the following columns: "Minus" and "Plus".
  • Insert the following code into the IsgGridDataSource_GetRowCount and IsgGridDataSource_GetRowData functions:

    Copy Code

Private Function IsgGridDataSource_GetRowCount() As Long
   IsgGridDataSource_GetRowCount = mlRowsCount
End Function

Private Sub IsgGridDataSource_GetRowData _
   (ByVal RowIndex As Long, ByVal ColCount As Long, _
   RowData As Variant)
   Dim i As Integer

   For i = 0 To ColCount - 1
      RowData(i) = 0
   Next

   If arData(RowIndex) > 0 Then
      RowData(1) = arData(RowIndex)
   Else
      RowData(0) = arData(RowIndex)
   End If
End Sub
Show Me

2. Write Data

  • Set the AllowEdit property to True.
  • Insert the following code into the IsgGridDataSource_SetRowData function:

    Copy Code

Private Sub IsgGridDataSource_SetRowData _
   (ByVal RowIndex As Long, ByVal ColCount As Long, _
   ByVal RowData As Variant)

   If RowData(0) <> 0 Then
      arData(RowIndex) = Val(RowData(0))
   Else
      arData(RowIndex) = Val(RowData(1))
   End If
   'invoke the GetRowData function
   SGGrid1.RefetchRow Clng(SGGrid1.CurrentCell.RowKey)
End Sub
Show Me

3. Add New Row

  • Set the AllowAddNew property to True.
  • Insert the following code into the IsgGridDataSource_AddRow function:

    Copy Code

Private Function IsgGridDataSource_AddRow _
   (ByVal RowIndex As Long, ByVal ColCount As Long, _
   ByVal RowData As Variant) As Boolean

   mlRowsCount = mlRowsCount + 1

   If mlRowsCount > UBound(arData) Then
      ReDim Preserve arData(mlRowsCount + 10) As Long
   End If

   If RowData(0) <> 0 Then
      arData(mlRowsCount - 1) = Val(RowData(0))
   Else
      arData(mlRowsCount - 1) = Val(RowData(1))
   End If
   'if you are ready to add
    'row set the AddRow to true
   IsgGridDataSource_AddRow = True
End Function
Show Me

4. Delete Rows

  • Set the AllowDelete property to True.
  • Insert the following code into the IsgGridDataSource_DeleteRow function:

    Copy Code

Private Function IsgGridDataSource_DeleteRow _
   (ByVal RowIndex As Long) As Boolean
   Dim i As Integer

   mlRowsCount = mlRowsCount - 1
    'just move values for one place
   For i = RowIndex To mlRowsCount - 1
      arData(i) = arData(i + 1)
   Next
   'row will not be deleted if you dont
    'set the DeleteRow to True
   IsgGridDataSource_DeleteRow = True
End Function
Show Me

Hide


Tutor - Using Styles

See Also Send us your Feedback
Tutorial - Using Styles

In this tutorial, you will learn how to use styles to change grid's appearance.

1. Load Layout and Sample Data

  • From the Visual Basic® File menu, choose New Project.
  • Press Ctrl+T or select Components from Project menu. Check the Stinga BeeGrid Control 1.0 checkbox.
  • Place a BeeGrid control on the form.
  • Open Windows Notepad and paste grid's layout into it (Copy). Save file as "c:\SampleLayout.bgl".
  • Open Windows Notepad and paste grid's data into it (Copy). Save file as "c:\SampleData.xml".
  • Insert the following code into the Form_Load event:

    Copy Code

Private Sub Form_Load()
   SGGrid1.LoadLayoutFromFile "c:\SampleLayout.xml", sgLayoutXML
   SGGrid1.ImportData "c:\SampleData.xml", sgFormatXML

   With SGGrid1.Groups(1)
      .FooterVisible = True
      .FooterFormula = "GroupingValue & ' has ' & ChildCount & ' players'"
      .FooterTextSource = sgGrpFooterFormula
   End With
   SGGrid1.RefreshGroups
End Sub
Show Me

2. Named Styles

  • The following code changes the properties of a few named styles:

    Copy Code

   With SGGrid1
      .SpecialMode = sgModeListBox
      With .Styles("Caption")
         .Font.Size = 12
         .Font.Bold = True
         .TextAlignment = sgAlignLeftCenter
         .BorderColor = RGB(255, 207, 0)
         .Borders = sgCellBorderAll
         .BorderSize = 3
         .BackColor = vbWhite
         .ForeColor = RGB(0, 0, 128)
      End With

      .Caption = "Woman Tennis Rank List"

      With .Styles("Heading")
         .BackColor = RGB(206, 48, 0)
         .ForeColor = vbWhite
         .Font.Bold = True
      End With

      With .Styles("GroupHeader")
         .BackColor = RGB(255, 207, 0)
         .Font.Bold = True
         .TextAlignment = sgAlignCenterCenter
      End With

      With .Styles("GroupFooter")
         .BackColor = RGB(0, 0, 128)
         .Font.Bold = True
         .TextAlignment = sgAlignCenterCenter
         .ForeColor = vbWhite
      End With

      With .Styles("InactiveSelection")
         .BackColor = RGB(156, 154, 206)
         .ForeColor = vbBlack
      End With

      With .Styles("Selection")
         .BackColor = RGB(0, 128, 0)
         .ForeColor = vbWhite
         .Font.Bold = True
      End With
   End With
Show Me

3. Cell Tips and Scroll Tips

  • Set the CellTips property to sgCellTipsFloat.
  • Set the ScrollBarTips property to sgScrollTipsBoth.
  • Use the CellTipsDelay property to define the amount of time before the cell tip is displayed. By default, this property is set to 1000 (milliseconds).
  • Use the "Tip" style to change the default look of the tool tip window.

    The following code sets the cell and scroll tool tips:

    Copy Code

   With SGGrid1
      .CellTips = sgCellTipsFloat
      .CellTipsDelay = 500
      .ScrollBarTips = sgScrollTipsBoth

      With .Styles("Tip")
         .BackColor = RGB(206, 48, 0)
         .ForeColor = vbWhite
         .Font.Bold = True
         .Font.Size = 10
         .BorderSize = 2
         .BorderColor = RGB(255, 207, 0)
         .Borders = sgCellBorderAll
      End With
   End With
Show Me

4. Cell Editor Style

  • Change the style for the "Trend" and "Country" column editors.

    Insert the following code into the Form_Load event:

    Copy Code

   With SGGrid1.Columns("Trend").Control
      .ShowButton = sgHideButton
      .PopUpStyle.Appearance = sg3DLight
      .PopUpStyle.TextAlignment = sgAlignLeftCenter
      .PopUpStyle.Font.Bold = True
   End With

   With SGGrid1.Columns("Country").Control.PopupStyle
      .BackColor = RGB(206, 48, 0)
      .ForeColor = vbWhite
      .Font.Bold = True
      .Borders = sgCellBorderBottom
      .BorderSize = 1
      .BorderStyle = sgCellBorderDotted
      .BorderColor = RGB(255, 207, 0)
   End With
Show Me

5. Cell Style Conditions

  • Use the Add method of the SGStyle object to create a new style "NextOff".
  • Use the Add method of the SGStyleConditions object to add the new style conditions to the collection.

    Insert the following code into the Form_Load event:

    Copy Code

   With SGGrid1
      With .Styles.Add("NextOff")
         .BaseStyle = "Normal"
         .BorderSize = 1
         .BorderColor = RGB(255, 207, 0)
         .Borders = sgCellBorderBottom
         .BackColor = RGB(255, 255, 240)
      End With
      .Columns("Next Off").StyleConditions.Add "NextOff", _
             sgConditionCellValue, sgOpGreaterThan, 5000
   End With
Show Me

6. Fetch Styles

  • Set the FetchCellStyle property of the "Rank" column to True. Insert the code into the FetchCellStyle event (see listing).
  • Set the FetchFooterStyle property of the SGGroup object to True. Insert the code into the FetchGroupFooterStyle event (see listing).
  • Set the FetchHeaderStyle property of the SGGroup object to True. Insert the code into the FetchGroupHeaderStyle event (see listing).

    Insert the following code into the project:

    Copy Code

'Form_Load
With SGGrid1
   .Columns("Rank").FetchCellStyle = True
   .Groups(1).FetchFooterStyle = True
   .Groups(1).FetchHeaderStyle = True
End With

Private Sub SGGrid1_FetchCellStyle(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellValue As Variant, _
   ByVal CellStyle As IsgStyle)
   If CellValue < 31 Then
      CellStyle.ForeColor = vbRed
   End If
End Sub

Private Sub SGGrid1_FetchGroupFooterStyle( _
   ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, _
   ByVal FooterStyle As IsgStyle)

   Select Case SGGrid1.Rows(RowKey).Parent.ChildRows.Count
      Case 1
         FooterStyle.BackColor = RGB(0, 0, 255)
      Case 2
         FooterStyle.BackColor = RGB(0, 0, 240)
      Case 3
         FooterStyle.BackColor = RGB(0, 0, 196)
      Case Else
         FooterStyle.BackColor = RGB(0, 0, 128)
   End Select
End Sub

Private Sub SGGrid1_FetchGroupHeaderStyle _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, _
   ByVal HeaderStyle As IsgStyle)
   Dim row As SGRow

   For Each row In SGGrid1.Rows(RowKey).GroupHeading.ChildRows
      If row.Type = sgSimpleRow Then
         If row.Cells(1) < 31 Then
            HeaderStyle.ForeColor = RGB(206, 48, 0)
            HeaderStyle.Font.Bold = True
            Exit Sub
         End If
      End If
   Next
End Sub
Show Me

Hide


Samples

BeeGrid Samples

This section contains few HTML samples written with VB script. To see a list of all properties, methods and events used in the sample, click the Applies To button. If you want to see VBScript source code press the Sample Code button.

  • Object Model - initializes grid from the layout file and loads data from an XML file. Loaded data contains the grid's object model.
  • Data Editing - demonstrates how to customize and control in-cell editing. In addition, sample uses the TextArea control to record editing events.
  • Appearance - demonstrates how to customize grid's appearance.
  • Styles - demonstrates how to use built-in named styles.
  • Countries - demonstrates several BeeGrid features. Sample binds grid to the ADO recordset, displays pictures in cells and cell tips, uses grid's grouping features to group records, uses calculations and formulas to display summaries in group headings. In addition, it demonstrates grid's Find feature.
  • Groups - demonstrates how to use groups and how to apply styles to group's header and footer.
  • Data Binding - demonstrates how to bind the grid to a recordset.
  • Events - records grid events into the TextArea control.
  • Controls - demonstrates how to use the column's Control object.
  • User Dragging - demonstrates how to resize and move columns and rows. In addition, sample uses the TextArea control to record editing events.
  • OLEDragDrop - demonstrates how to use the OLE drag-and-drop features of the BeeGrid control.
  • Preview Pane - demonstrates how to create and use preview pane.
  • Selection - demonstrates how you can select a range of cells and then apply style to the selected range.
  • Row Filters - demonstrates how to use row filters.
  • Scroll Bars - demonstrates how to control scrollbar appearance.
  • Export HTML - demonstrates how to load styles from the XML file. In addition, it creates HTML page created with the grid's ExportHTMLString method.
  • Exchange Rate - demonstrates several BeeGrid features. First, it loads layout and data from an XML files. Then, an unbound column (Change) is created and populated with data. Also, you can see how to use the CompareCells event to sort an unbound column. In addition, the sample shows how to customize cell tip appearance.
  • Minesweeper - illustrates how to apply style by using the ApplyStyle method of the SGRange object, how to use the SGCell object and how to use grid's HitTestObject method.
  • Bridge - demonstrates how to apply different styles to grid objects. Uses the FormatText event to format playing cards. In addition, it shows how to export grid to an HTML file.
  • Chess - loads the grid's layout that contains images used by value items. Uses drag-drop features to move images from one cell to another.


BeeGrid Object Model

Applies To [image] Sample Code Send us your Feedback
BeeGrid Object Model

This sample initializes grid from the layout file and loads data from an XML file. Loaded data contains the grid's object model.

BeeGrid Object Model

Category:

LeftCol, TopRow, DataRowCount, HeadingRowCount, Columns, Styles, Array, Selection, Rows, Cell, RowFilters, Caption, GroupByBoxVisible
RefreshGroups, LoadLayoutString, ImportDataString
MouseUp, FetchScrollTip, FetchCellTip


Cell Editing Example

Applies To [image] Sample Code Send us your Feedback
Cell Editing Example

This sample demonstrates how to customize and control in-cell editing. In addition, sample uses the TextArea control to record editing events.

Cell Editing Example

Allow Edit Allow AddNew New Row Bottom Allow Delete
EnterKeyBehavior: TabKeyBehavior:
NavigationWrapMode: SkipReadOnly:

TabKeyBehavior, EnterKeyBehavior, NavigationWrapMode, SkipReadOnly, EqualRowHeight, Columns, FitLastColumn, MultiSelect, AllowAddNew, AllowDelete, AllowEdit, SpecialMode, Caption, NewRowPos
None
BeforeEdit, AfterEdit, ValidateEdit, Error, BeforeUpdate, AfterUpdate, AfterDelete, BeforeInsert, AfterInsert


Appearance Example

Applies To [image] Sample Code Send us your Feedback
Appearance Example

This sample demonstrates how to customize grid's appearance.

Appearance Example

General Cells Heading Focus Rect
Appearance: FitLastColumn:
HeadingColCount: HeadingRowCount:
BackColor:
CellsBorderVisible: CellsBorderColor:
CellBackColor: CellForeColor:
GridLines: GridLinesColor:
EvenOddStyle:
ColorEven: ColorOdd:
HeadingBackColor: -
HeadingForeColor:
HeadingGridLines:
HeadingGridLinesColor:
FocusRect: -
FocusRectColor:
FocusRectLineWidth:

EnterKeyBehavior, BackColor, LeftCol, HeadingRowCount, HeadingColCount, HeadingBackColor, HeadingForeColor, HeadingGridLinesColor, EvenOddStyle, ColorEven, ColorOdd, CellBackColor, CellForeColor, FocusRectColor, FocusRectLineWidth, CellsBorderColor, CellsBorderVisible, RowNumbering, Columns, Appearance, FitLastColumn, CacheAllRecords, ColumnClickSort, Caption
None
None


Styles Example

Applies To [image] Sample Code Send us your Feedback
Styles Example

This sample demonstrates how to use built-in named styles. To select style of a particular grid element, click on that element or select style from the combo box.

Styles Example

Apply to style:

General Text Font Borders Pictures Alpha Blend
Appearance: BaseStyle:
MousePointer: BkgStyle:
BackColor: BackColor2:
TextAlignment: Format:
ForeColor: Ellipsis:
WordWrap: Padding:

FontName:
Font:
FontSize:
Borders:
BorderColor:
BorderSize:
BkgPictureAlignment:
BkgPictureAlignment:
AlphaBlendEnabled: BackColor:
AlphaBackground: AlphaContent:
AlphaBorder: AlphaBackgroundPicture:

EnterKeyBehavior, BackColor, LeftCol, EqualRowHeight, Columns, Styles, Format, BkgPictureAlignment, FitLastColumn, SelectionMode, MultiSelect, SpecialMode, License, Groups, ColumnClickSort, PreviewPaneColumn, PreviewPaneType, PreviewPanePosition, OLEDragMode, Caption, AlphaBlendEnabled
Redraw, RefreshGroups, ImportDataString, HitTest
MouseDown


Properties Window Example

Applies To [image] Sample Code Send us your Feedback
Properties Window Example

This sample demonstrates how to use the grid as a property editor. Each row tag in the properties grid contains data describing property-value cell in that row. When the RowColChange event occurs, attributes of the property-value column is changed according to the data from the row tag.

Properties Window Example

EnterKeyBehavior, DataRowCount, DataColCount, RowNumbering, Columns, Array, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
None


Countries Example

Applies To [image] Sample Code Send us your Feedback
Countries Example

This sample demonstrates several BeeGrid features. It binds to the ADO recordset, displays pictures in cells and cell tips, uses grid's grouping features to group records, uses calculations and formulas to display summaries in the group headings. In addition, it demonstrates grid's Find feature.

Countries Example

EnterKeyBehavior, LeftCol, TopRow, ScrollBarTips, HeadingColCount, HeadingBackColor, HeadingForeColor, HeadingFont, HeadingGridLinesColor, UserDragging, RedrawEnabled, FocusRect, Row, DefaultColWidth, DataMode, Columns, Styles, DataSource, Appearance, FitLastColumn, Rows, CellTips, CellTipsDelay, SpecialMode, License, Groups, CacheAllRecords, ColumnClickSort, AutoResize, GroupByBoxVisible
RefreshGroups, ExpandAll
SelChange


Groups Example

Applies To [image] Sample Code Send us your Feedback
Groups Example

The following example demonstrates how to use groups and how to apply styles to group's header and footer.

Groups Example

Style Group header Group footer Calculations
Apply to style: BkgStyle:
TextAlignment: Font:
BackColor: ForeColor:
Borders: BorderColor: BorderSize:
HeaderTextSource: HeaderCaption:
GroupIndentation: OutlineLines:
HeaderFormula:
PictureExpanded: PictureCollapsed:
FooterTextSource:
FooterCaption:
FooterFormula:
FetchFooterStyle:
Calculations:
CalculationType: Operator:
Column: Cond Column:
Val1: Val2:

EnterKeyBehavior, LeftCol, EqualRowHeight, Columns, Styles, FitLastColumn, SelectionMode, MultiSelect, SpecialMode, Groups, OutlineLines, ColumnClickSort, GroupIndentation, OLEDragMode, GroupByBoxVisible
Redraw, ImportDataString
FetchGroupHeaderData, FetchGroupFooterText


Data Binding Example.

Applies To [image] Sample Code Send us your Feedback
Data Binding Example

The following example shows how to bind the grid to a recordset. Set data source and press "Bind to Database" button. Select the Record source from the combo box.

Data Binding Example

ODBC Data Source Name Database Name (Jet 3.51) Database Name (Jet 4.0

Data Source:
Record Source:

EnterKeyBehavior, BackColor, GridBorderStyle, HeadingColCount, DataMode, Styles, CacheAllRecords, ColumnClickSort
None
None


Events Example

Applies To [image] Sample Code Send us your Feedback
Events Example

This sample records grid events into the TextArea control. Use check boxes to filter events you want to monitor.

Events Example

Mouse events | Keyboard events | Edit events
Fetch events | DragDrop events | Misc events

ScrollBarTips, UserResizing, UserDragging, UserHiding, EqualRowHeight, Columns, FitLastColumn, SelectionMode, MultiSelect, AllowAddNew, AllowDelete, CellTips, SpecialMode, CacheAllRecords, ColumnClickSort, OLEDragMode, OLEDropMode, Caption
None
DblClick, KeyDown, KeyPress, KeyUp, MouseDown, MouseMove, MouseUp, BeforeEdit, AfterEdit, ValidateEdit, KeyDownEdit, KeyPressEdit, KeyUpEdit, ColHeadClick, RowHeadClick, OnInit, Error, BeforeUpdate, AfterUpdate, BeforeDelete, AfterDelete, BeforeInsert, AfterInsert, ButtonClick, ColMove, ColResize, ColHide, RowMove, RowResize, RowHide, BeforeRowColChange, SelChange, FetchScrollTip, FetchCellTip, FetchGroupHeaderStyle, FetchGroupHeaderData, FetchGroupFooterStyle, FetchGroupFooterText, AfterGroupExpand, AfterGroupCollapse, CompareCells, BeforeClickSort, AfterClickSort, FetchColumnData, AfterScroll, ValueItemError, OLEStartDrag, OLEGiveFeedback, OLESetData, OLECompleteDrag, OLEDragOver, OLEDragDrop, DropDownOpen, FetchCellStyle, VirtualAddRow, VirtualDeleteRow, VirtualReadData, VirtualWriteData, FormatText, GroupByBoxHeaderClick, BeforeGroupChange


Controls Example

Applies To [image] Sample Code Send us your Feedback
Controls Example

This sample uses four different controls to display cell data. Each tab contains specific properties for each control. In addition, sample demonstrates how to to drop down an arbitrary control from a grid cell. It uses the ButtonClick event to place control under the clicked cell.

Controls Example

Drop List Drop Down Action Button Check Box
Width: Height:
PopupAlignment: ButtonAlignment:
SortOrder: AutoOpen:
BackColor: ForeColor:
Width: Height:
PopupAlignment: ButtonAlignment:
SortOrder: AutoOpen:
BackColor: ForeColor:
ShowButton:
ButtonAlignment:
ButtonPicture:
3D: BackColor:

EnterKeyBehavior, BackColor, GridBorderStyle, DataRowCount, HeadingColCount, Columns, Styles, FitLastColumn, SelectionMode, MultiSelect, AllowAddNew, AllowEdit, SpecialMode, CacheAllRecords, ColumnClickSort, Cell, NewRowPos
None
KeyDownEdit, ButtonClick, FormatText


UserDragging Example

Applies To [image] Sample Code Send us your Feedback
UserDragging Example

This sample demonstrates how to resize and move columns and rows. In addition, sample uses the TextArea control to record UserDragging events.

UserDragging Example

EqualColWidth EqualRowHeight

ColWidthMin: ColWidthMax: RowHeightMin: RowHeightMax:

UserDragging: UserHiding:
UserResizing: UserResizeAnimate:

EnterKeyBehavior, LeftCol, UserResizing, RowHeightMin, RowHeightMax, ColWidthMin, ColWidthMax, UserDragging, UserHiding, RowNumbering, EqualRowHeight, EqualColWidth, Columns, Styles, CacheAllRecords, ColumnClickSort, AutoScroll
None
ColMove, ColResize, ColHide, RowMove, RowResize, RowHide


OLEDragDrop Example

Applies To [image] Sample Code Send us your Feedback
OLEDragDrop Example

This sample demonstrates how to use the OLE drag-and-drop features of the BeeGrid control. Use buttons below to select and delete data in the right-most grid.

OLEDragDrop Example

Drag selected rows from the first grid and drop them to the second one.

EnterKeyBehavior, LeftCol, Row, EqualRowHeight, Columns, FitLastColumn, SelectionMode, MultiSelect, SpecialMode, Groups, CacheAllRecords, ColumnClickSort, OLEDragMode, Caption
RefreshGroups, ImportDataString
OLEStartDrag, OLEGiveFeedback, OLESetData, OLECompleteDrag


PreviewPane Example

Applies To [image] Sample Code Send us your Feedback
Preview Pane Example

This sample demonstrates how to create and use preview pane.

PreviewPane Example

PreviewPanePosition: PreviewPaneColumn:
PreviewPaneSize:

EnterKeyBehavior, DataRowCount, RedrawEnabled, Columns, Styles, FitLastColumn, SpecialMode, CacheAllRecords, ColumnClickSort, PreviewPaneColumn, PreviewPaneType, PreviewPanePosition, PreviewPaneSize, GroupByBoxVisible
None
None


Selection Example

Applies To [image] Sample Code Send us your Feedback
Selection Example

This sample demonstrates how you can select a range of cells and then apply style to the selected range.

Selection Example

SelectionMode:
MultiSelect: SpecialMode:

Heading Normal Tip

EnterKeyBehavior, LeftCol, Row, EqualRowHeight, Columns, Styles, FitLastColumn, SelectionMode, MultiSelect, Selection, SpecialMode
ImportDataString
SelChange


RowFilters Example

Applies To [image] Sample Code Send us your Feedback
Row Filters Example

This sample demonstrates how to use row filters. Select a column on which you want to filter, choose operator and set criteria. Press "Filter" button to apply a filter.

RowFilters Example

Filter action:

Column: Operator: Not
Val 1:
Val 2:

EnterKeyBehavior, HeadingColCount, DataMode, Columns, Styles, DataSource, FitLastColumn, SpecialMode, CacheAllRecords, ColumnClickSort, AutoResize
None
None


ScrollBars Example

Applies To [image] Sample Code Send us your Feedback
Scrollbars Example

The following example shows how to control scroll bars. You can't change the VScrollWidth and the HScrollHeight properties if you are using the BeeGrid Free Edition.

ScrollBars Example

ScrollBars: VScrollWidth: HScrollHeight:
FlatScrollBars: ScrollBarTips: ScrollBarTrack:

Scroll by rows:
Scroll by cols:

EnterKeyBehavior, ScrollBars, FlatScrollBars, ScrollBarTrack, DataRowCount, DataColCount, HeadingColCount, EvenOddStyle, RowNumbering, Columns, HScrollHeight, VScrollWidth, Array, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
None


Load Styles and Export HTML Example

Applies To [image] Sample Code Send us your Feedback
Load Styles and Export HTML Example

This sample demonstrates how to load styles from the XML file. In addition, it creates HTML page created with the grid's ExportHTMLString method.

Load Styles and Export HTML Example

Load styles from XML:

EnterKeyBehavior, BackColor, EqualRowHeight, Columns, Styles, FitLastColumn, SelectionMode, MultiSelect, SpecialMode, Groups, ColumnClickSort, OLEDragMode
RefreshGroups, ImportDataString
None


Exchange Rate

Applies To [image] Sample Code Send us your Feedback
Exchange Rate

This sample demonstrates several BeeGrid features. First, it loads layout and data from an XML files. Then, an unbound column (Change) is created and populated with data. Also, you can see how to use the CompareCells event to sort an unbound column. In addition, the sample shows how to customize cell tip appearance.

Exchange Rate

DataRowCount, HeadingRowCount, Columns, Rows, AllowEdit, GroupByBoxVisible
LoadLayoutString, ImportDataString
KeyPressEdit, FetchScrollTip, FetchCellTip, CompareCells, BeforeClickSort, FetchColumnData, FetchCellStyle, FormatText


Minesweeper

Applies To [image] Sample Code Send us your Feedback
Minesweeper

This sample illustrates how to apply style by using the ApplyStyle method of the SGRange object, how to use the SGCell object and how to use grid's HitTestObject method.

Minesweeper

Mines count: Columns: Rows:

Use left mouse button to open cell and the right button to mark a mine.

BackColor, GridBorderStyle, DataRowCount, DataColCount, HeadingRowCount, GridLines, RedrawEnabled, FocusRect, DefaultColWidth, DefaultRowHeight, MouseCol, CellsBorderVisible, Columns, Styles, Array, SelectionMode, Rows, AllowEdit, GroupByBoxVisible
CreateRange
MouseUp


Bridge Example

Applies To [image] Sample Code Send us your Feedback
Bridge Example

This sample demonstrates how to apply different styles to grid objects. Uses the FormatText event to format playing cards. In addition, it shows how to export grid to an HTML file.

Bridge Example

Enable Alpha Blending

BackColor, GridBorderStyle, ScrollBars, LeftCol, TopRow, DataRowCount, DataColCount, HeadingRowCount, GridLines, RedrawEnabled, Font, CellsBorderVisible, Columns, Styles, Array, BkgPictureAlignment, FitLastColumn, Rows, GroupByBoxVisible, AlphaBlendEnabled
None
FormatText


Chess Example

Applies To [image] Sample Code Send us your Feedback
Chess Example

This sample loads the grid's layout that contains images used by value items. Uses drag-drop features to move images from one cell to another.

Chess Example

BackColor, LeftCol, TopRow, DataRowCount, HeadingRowCount, DefaultColWidth, DefaultRowHeight, MouseCol, Value, Styles, CurrentCell, GroupByBoxVisible
Redraw, LoadLayoutString, ImportDataString, HitTestObject
MouseDown, OLEDragDrop


Object Model


SGGrid Control

Properties [image] Methods [image] Events Send us your Feedback
Stinga BeeGrid Control

Name: | SGGrid
Description: | Stinga ActiveX Grid Control
ICursor GUID: | {97BD7A13-77E0-11D2-8EAE-008048E27A77}
ICursor PROGID: | StingaBeeGrid10.Grid
OLEDB GUID: | {97BD7A14-77E0-11D2-8EAE-008048E27A77}
OLEDB PROGID: | StingaBeeGridOLEDB10.Grid
Version: | 1.0

BeeGrid is a full-featured, database-aware ActiveX grid control. It can be used in a bound (both OLEDB and ICursor), unbound and virtual data modes. BeeGrid has all features expected from a modern grid control: fast and easy manipulation of tabular data, powerful display capabilities, easy to use unbound mode, easy to use event and interface based virtual modes, outlook-like grouping, etc.


SGGrid Properties

AllowAddNew | Returns or sets a value indicating whether the user can add new records.
AllowDelete | Returns or sets a value indicating whether the user can delete records.
AllowEdit | Returns or sets a value indicating whether the user can edit records.
AlphaBlendEnabled | Returns or sets a value indicating whether transparecy features are enabled.
Appearance | Returns or sets the paint style.
Array | Returns Array object that represents cell data.
AutoFields | Enables or disables automatic column/field mapping.
AutoGroup | Value indicating whether groupings are refreshed when row data is changed or a new row is added.
AutoResizeHeadings | Returns or sets a value indicating whether column headings are included in the AutoSize operation.
AutoResize | Returns or sets a value indicating whether columns and/or rows are automatically resized when grid data is loaded.
AutoScroll | Returns or sets a value indicating whether grid is scrolled as a result of user drag/size mouse operations.
AutoSearch | Returns or sets a value indicating whether auto-search is enabled.
AutoSearchDelay | Returns or sets the time interval after which the AutoSearch buffer is reset. In milliseconds.
BOF | Returns true if the current record position is before the first record.
BackColor | Returns or sets color for area outside of grid cells.
BkgPictureAlignment | Returns or sets grid's background picture alignment.
BkgPicture | Returns or sets grid's background picture.
BottomRow | Returns a zero-based index of the last visible row.
CacheAllRecords | Returns or sets a value indicating whether all records are cached in the memory.
Caption | Returns or sets the text displayed in the grid's caption bar.
CellAsPicture | Returns bitmap presentation of a specified grid cell.
CellAt | Returns specified cell object.
CellBackColor | Returns or sets cells background color.
CellBkgStyle | Returns or sets cells background style.
CellForeColor | Returns or sets cells foreground color.
CellPadding | Returns or sets the space between the contents and inside edges of cells.
CellStyleConditions | Returns the collection of conditional style rules.
CellTipsDelay | Returns or sets the amount of time before cell tip is displayed.
CellTips | Returns or sets a value indicating whether cell tips are displayed.
CellsBorderColor | Returns or sets the color of the line dividing cells from the grid background.
CellsBorderVisible | Returns or sets a value indicating whether cells border line is drawn.
Cell | Returns specified cell object.
ClientHeight | Returns height of control's client area.
ClientWidth | Returns width of control's client area.
ColCount | Returns the total number of columns.
ColWidthMax | Returns or sets the maximum column width.
ColWidthMin | Returns or sets the minimum column width.
ColorEven | Returns or sets color for even rows and/or columns.
ColorOdd | Returns or sets color for odd rows and/or columns.
ColumnClickSort | Returns or sets a value indicating whether user may sort column by clicking on the column heading.
Columns | Returns a collection of grid columns.
Col | Returns or sets current column position
CurBookmark | Returns or sets the bookmark identifying the current row.
CurrentCell | Returns current cell as an SGCell object.
CustomBkgDraw | Value indicating whether custom draw for grid background is enabled.
DataColCount | Returns or sets the total number of data columns.
DataMember | Returns or sets the DataMember for the OLEDB data source.
DataMode | Returns or sets type of the data source the control is using.
DataRowCount | Returns or sets the number of data rows.
DataSource | Returns or sets data source.
DefaultColWidth | Returns or sets the default column width.
DefaultRowHeight | Returns or sets the default row height.
DragAlphaLevel | Returns or sets an alpha transparency value to be used on the dragged image.
EOF | Returns true if the current record position is after the last record.
EditSelLength | Returns or sets the number of characters selected in the cell editor.
EditSelStart | Returns or sets the starting point of the text selected in the cell editor.
EditSelText | Returns or sets currently selected text in the cell editor.
Editing | Returns or sets flag indicating whether the current cell is currently being edited.
Ellipsis | Truncates text that does not fit in the cell and adds ellipses (...).
Enabled | Returns or sets a value that indicates whether a grid responds to user-generated events.
EnterKeyBehavior | Returns or sets ENTER key behavior.
EqualColWidth | Returns or sets whether all columns have same width.
EqualRowHeight | Returns or sets whether all rows have same height.
ErrorText | Returns the error message string.
EvenOddStyle | Enables or disables even/odd formatting.
FitLastColumn | Returns or sets flag indicating whether the last column should be adjusted to fit the control's width.
FlatScrollBars | Enables or disables flat scroll bars.
FocusRectColor | Returns or sets focus rectangle color.
FocusRectLineWidth | Returns or sets focus rectangle line width. In pixels.
FocusRect | Returns or sets focus rectangle type.
Font | Returns or sets font used in standard cells.
Format | Specifies the format for displaying numbers, dates, times and text.
FrozenColCount | Returns the number of frozen columns.
FrozenRowCount | Returns the number of frozen rows.
GridBorderStyle | Returns or sets the grid border style.
GridLinesColor | Returns or sets color for flat grid lines.
GridLines | Returns or sets grid line style.
GroupByBoxText | Returns or sets the text dispalyed in the group-by box.
GroupByBoxVisible | Returns or sets a value indicating whether group-by box is visible.
GroupHeadings | Returns the collection of group heading objects.
GroupIndentation | Returns or sets grid's hierarchy indentation size.
Groups | Returns the collection of the grid groups.
HScrollHeight | Returns or sets height of the horizontal scroll bar.
HeadingBackColor | Returns or sets background color for header rows and columns.
HeadingColCount | Returns or sets the total number of heading columns.
HeadingEllipsis | Truncates text that does not fit in the cell and adds ellipses (...).
HeadingFont | Returns or sets font for header rows and columns.
HeadingForeColor | Returns or sets foreground color for header rows and columns.
HeadingGridLinesColor | Returns or sets color for flat grid lines of header rows and columns.
HeadingGridLines | Returns or sets grid line style for header rows and columns.
HeadingRowCount | Returns or sets the total number of heading rows.
HeadingTextAlignment | Returns or sets text alignment style for header rows and columns.
HeadingWordWrap | Enables or disables word wrapping for header rows and columns.
Images | Sets user defined image list handle.
InactiveSelection | Returns or sets a value indicating how to draw selection when grid does not have focus.
IsColVisible | Returns True if column is visible.
IsRowVisible | Returns True if row is visible.
LeftCol | Returns or sets left-most visible column (zero-based).
License | Returns license description.
MaxColumns | Returns or sets the maximum number of columns.
MaxRows | Returns or sets the maximum number of rows.
MouseCol | Returns position of the column under the mouse pointer (zero-based).
MouseRow | Returns position of the row under the mouse pointer (zero-based).
MultiSelect | Controls multiple selection mode.
NavigationWrapMode | Returns or sets wrapping mode used for grid navigation.
NewRowPos | Returns or sets position of the row used to add new records.
OLEDragMode | Returns or sets whether the control can act as an OLE drag source, either automatically or under program control.
OLEDropMode | Returns or sets whether the control can act as an OLE drop target, either automatically or under program control.
OutlineLines | Returns or sets a value indicating what type of lines to draw in outline mode.
PaintObject | Sets an object that implements custom draw interface (IsgGridCustomDraw).
PreviewPaneColumn | Returns or sets key of the column displayed in the preview pane.
PreviewPanePosition | Returns or sets a value indicating preview pane position.
PreviewPaneSize | Returns or sets preview pane size (width or height). In twips.
PreviewPaneType | Returns or sets key of the column displayed in the preview pane.
RedrawEnabled | Enables or disables redrawing of the control.
RightCol | Returns a zero-based index of the last visible column.
RowCount | Returns the total number of rows.
RowFilters | Returns a collection of filter definitions.
RowHeightMax | Returns or sets the maximum row height.
RowHeightMin | Returns or sets the minimum row height.
RowNumbering | Enables or disables row heading numbers.
RowStyleConditions | Returns the collection of conditional style rules that are applied to grid rows.
Rows | Returns the collection of the grid rows.
Row | Returns or sets current row position
ScrollBarTips | Returns or sets a value indicating whether tips are displayed while the user operates scroll bars.
ScrollBarTrack | Enables or disables scroll bar tracking.
ScrollBars | Returns or sets the scroll bar flags.
ScrollTipColumn | Returns or sets key of the column that contains values for vertical scroll tips.
SelectionMode | Returns or sets selection mode.
Selection | Returns current selection.
SimpleDataSource | Returns or sets custom data source used by VirtualInterface data mode.
SkipReadOnly | Returns or sets a value indicating whether read only cells can receive focus.
SpecialMode | Returns or sets special operating mode.
Styles | Returns a collection of SGStyle objects.
TabKeyBehavior | Returns or sets TAB key behavior.
TextAlignment | Returns or sets text alignment style.
Text | Returns the current cell's underlying data value as formatted text
TopRow | Returns or sets top-most visible row (zero-based).
UserDragging | Returns or sets a value indicating whether the user is allowed to drag rows and columns with the mouse.
UserHiding | Returns or sets a value indicating whether the user is allowed to hide rows and columns with the mouse.
UserResizeAnimate | Returns or sets a value indicating row/column resize feedback.
UserResizing | Returns or sets whether the user is allowed to resize rows and columns with the mouse.
VScrollWidth | Returns or sets width of the vertical scroll bar.
ValueEx | Returns or sets cell's underlying data value.
Value | Returns or sets the current cell underlying data value.
Version | Returns string representing BeeGrid's version info.
VisibleCols | Returns the number of visible columns.
VisibleRows | Returns the number of visible rows.
Window |
WordWrap | Enables or disables word wrapping for cell text.


AllowAddNew Property

See Also [image] Example Send us your Feedback
AllowAddNew Property
Returns or sets a value indicating whether the user can add new records.

Read/Write at run time and design time.

Syntax

object.AllowAddNew As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

When the AllowAddNew property is set to True, grid will show a special row (add-new-row) into which the user can enter data for the new row. This row can be positioned at the bottom or at the top of the grid, depending on the value of the NewRowPos property. If the DataMode property is set to sgVirtualEvents or sgVirtualInterface, you must handle actual data insertion in appropriate event handlers.

If data source does not permit insertions (e.g. Recordset is read-only), user will not be able to type any data.

Show Example
Copy Code [image] Show Me

The following example shows how to set some properties important for data input.

Private Sub SGGrid1_OnInit()
   'allow full editing
   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True
   SGGrid1.AllowEdit = True
   'set keys behavior
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.NavigationWrapMode = sgNavigationWrapNext
   'skip read only columns to speed up data entering
   SGGrid1.SkipReadOnly = True
End Sub

Back to topic


AllowDelete Property

AllowDelete Property
Returns or sets a value indicating whether the user can delete records.

Read/Write at run time and design time.

Syntax

object.AllowDelete As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

If this property is set to True, the user can delete current record using the Del key. If the DataMode property is set to sgVirtualEvents or sgVirtualInterface, you must handle actual data deletion in appropriate event handlers.

Show Example
Copy Code [image] Show Me

The following example shows how to set some properties important for data input.

Private Sub SGGrid1_OnInit()
   'allow full editing
   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True
   SGGrid1.AllowEdit = True
   'set keys behavior
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.NavigationWrapMode = sgNavigationWrapNext
   'skip read only columns to speed up data entering
   SGGrid1.SkipReadOnly = True
End Sub

Back to topic


AllowEdit Property

AllowEdit Property
Returns or sets a value indicating whether the user can edit records.

Read/Write at run time and design time.

Syntax

object.AllowEdit As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The AllowEdit property enables or disables editing of the data displayed in the grid. You can use ReadOnly property of the SGColumn object to change edit status for particular column. By default, value for this property is set to True. If the DataMode property is set to sgVirtualEvents or sgVirtualInterface, you must handle actual data updates in appropriate event handlers.

Use the SkipReadOnly property to speed up the data input.

Show Example
Copy Code [image] Show Me

The following example shows how to set some properties important for data input.

Private Sub SGGrid1_OnInit()
   'allow full editing
   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True
   SGGrid1.AllowEdit = True
   'set keys behavior
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.NavigationWrapMode = sgNavigationWrapNext
   'skip read only columns to speed up data entering
   SGGrid1.SkipReadOnly = True
End Sub

Back to topic


AlphaBlendEnabled Property

AlphaBlendEnabled Property
Returns or sets a value indicating whether transparecy features are enabled.
Syntax

object.AlphaBlendEnabled As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The AlphaBlendEnabled property enables or disables the alpha blending features. When you enable alpha blending, you have to set the AlphaLevel property of the SGStyle object to value less then 255.

Note: The Alpha Blending feature is not supported by older versions of the Windows operating system. In addition, it requires video devices in a high-color or true-color mode.

Show Example
Copy Code [image] Show Me

The following example loads the background picture and sets a different AlphaLevel for each column. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim col As SGColumn
   Dim i As Integer
   Dim iStep As Integer
   'find bitmap to show
   If StrComp(Environ("OS"), "Windows_NT", vbTextCompare) = 0 Then
      Set SGGrid1.BkgPicture = _
         LoadPicture(Environ("WINDIR") & "\system32\Setup.bmp")
   Else
      Set SGGrid1.BkgPicture = _
         LoadPicture(Environ("WINDIR") & "\Setup.bmp")
   End If

   With SGGrid1
      .BkgPictureAlignment = sgPicAlignTile
      .GroupByBoxVisible = False
      .GridLines = sgGridLineNone
      .CellsBorderVisible = False
      .FitLastColumn = True
      .AlphaBlendEnabled = True
      'create cols and rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 0
      .DefaultColWidth = _
         .ClientWidth / 12
      .DataColCount = 12
      .DataRowCount = 100

      iStep = 255 / (.DataColCount - 1)
   End With
   'set AlphaLevel for each col
   For Each col In SGGrid1.Columns
      With col.Style
         .BackColor = vbWhite
         .BackColor2 = RGB(128, 128, 128)
         .BkgStyle = sgCellBkgGradientHorizontal
         .AlphaLevel(sgAlphaBackground) = 255 - i
      End With
      i = i + iStep
   Next

End Sub

Back to topic


Appearance Property

Appearance Property
Returns or sets the paint style.

Read/Write at run time and design time.

Syntax

object.Appearance As sgAppearance

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The Appearance settings are:

Name | Value | Description
sgFlat | 0 | Flat appearance.
sg3D | 1 | Standard 3D appearance.
sg3DLight | 2 | Light 3D appearance.

Remarks

The Appearance property is a shortcut to the Appearance member of the "Normal" style. The following lines have the same effect:

SGGrid1.Appearance = sgFlat

- or -

SGGrid1.Styles("Appearance").ForeColor = sgFlat
SGGrid1.Redraw

Show Example
Copy Code [image] Show Me

The following example draws the flat grid without borders. The current cell is red because the focus rect covers the contents of the cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.GridBorderStyle = sgNone
   SGGrid1.Appearance = sgFlat
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.BackColor = SGGrid1.Parent.BackColor
   SGGrid1.CellsBorderVisible = False
   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DataRowCount = 4
   SGGrid1.DataColCount = 4
   SGGrid1.FocusRect = sgFocusRectSolid
   SGGrid1.FocusRectColor = vbRed
   SGGrid1.FocusRectLineWidth = 100
End Sub

Back to topic


Array Property

Array Property
Returns Array object that represents cell data.

Read-only at run time. Not available at design time.

Syntax

object.Array As IsgArray

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Array property returns the SGArray object. The SGArray object enables you to access and set data displayed in the grid. Note that in unbound data mode, grid data is stored in the internal buffer and you can change data in all rows. In other data modes, you can only change current row's data, and changes are transmitted to the data source after the Update method is called.

Use the Value property to read from or write to the data source.

Show Example
Copy Code [image] Show Me

The following example calculates the estimated time required for loading grid array with data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray
   Dim t As Date
   Dim i As Long, j As Long
   'save start time
   t = Time
   'assign grid array to variable
   Set ar = SGGrid1.Array
   'hide group box
   SGGrid1.GroupByBoxVisible = False
   'create rows and columns
   SGGrid1.DataRowCount = 100
   SGGrid1.DataColCount = 20
   'load test data
   For i = 0 To ar.RowCount - 1
      For j = 0 To ar.ColCount - 1
         ar.Value(i, j) = "Row=" & i & " Col=" & j
      Next
   Next

   Set ar = Nothing
   'show estimate time in the grid's caption
   Me.Caption = "Time: " & DateDiff("s", t, Time)
End Sub

Back to topic


AutoFields Property

AutoFields Property
Enables or disables automatic column/field mapping.

Read/Write at run time and design time.

Syntax

object.AutoFields As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

If this property is set to True, the grid will automatically derive new column bindings from the data source during its binding process.
The following column properties will be set:

  • DBField
  • DBIndex
  • Caption
  • TextAlignment
  • Format

This property has effect only if the DataMode property is set to sgBound.


AutoGroup Property

AutoGroup Property
Value indicating whether groupings are refreshed when row data is changed or a new row is added.

Read/Write at run time and design time.

Syntax

object.AutoGroup As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

When the grid is grouped and the user changes data in the grid cells, he can change the value that is used to position specific row into specific group. When the AutoGroup property is set to true, the BeeGrid will automatically reposition such rows.


AutoResize Property

AutoResize Property
Returns or sets a value indicating whether columns and/or rows are automatically resized when grid data is loaded.

Read/Write at run time and design time.

Syntax

object.AutoResize As sgAutoResize

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The AutoResize settings are:

Name | Value | Description
sgNoAutoResize | 0 | No auto resizing.
sgAutoResizeColumns | 1 | Resize only columns.
sgAutoResizeRows | 2 | Resize only rows.
sgAutoResizeRowsAndColumns | 3 | Resize both rows and columns.

Remarks

The AutoResize property controls automatic resizing of the grid columns and rows. If automatic resizing is enabled, grid will resize columns and rows to fit cell's content every time grid is rebounded to the data source.

This property has effect only if the DataMode property is set to sgBound.


AutoResizeHeadings Property

AutoResizeHeadings Property
Returns or sets a value indicating whether column headings are included in the AutoSize operation.
Syntax

object.AutoResizeHeadings As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.


AutoScroll Property

AutoScroll Property
Returns or sets a value indicating whether grid is scrolled as a result of user drag/size mouse operations.

Read/Write at run time and design time.

Syntax

object.AutoScroll As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property has effect only if user dragging is allowed.


AutoSearch Property

AutoSearch Property
Returns or sets a value indicating whether auto-search is enabled.

Read/Write at run time and design time.

Syntax

object.AutoSearch As sgAutoSearch

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The AutoSearch settings are:

Name | Value | Description
sgNoAutoSearch | 0 | Auto-search is disabled.
sgAutoSearchFromTop | 1 | Start searching from the first row.
sgAutoSearchFromCurrentRow | 2 | Start searching from the current row.

Remarks

Use the AutoSearch property to enable incremental search. As the user types, current grid row is moved to the next one that matches typed text. Pressing ESC key cancels the current search. The AutoSearchDelay property can be used to set the time interval after which the auto-search buffer is reset.

If AutoSearch is enabled, user must press F2 or double click the cell to start editing cell.

See Also

AutoSearchDelay


AutoSearchDelay Property

AutoSearchDelay Property
Returns or sets the time interval after which the AutoSearch buffer is reset. In milliseconds.

Read/Write at run time and design time.

Syntax

object.AutoSearchDelay As Integer

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The AutoSearchDelay property is used in conjunction with the AutoSearch property to control the grid's auto-search behavior.

See Also

AutoSearch


BOF Property

BOF Property
Returns true if the current record position is before the first record.

Read-only at run time. Not available at design time.

Syntax

object.BOF As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The BOF property returns True if the current row position is before the first row and False if the current record position is on or after the first record.

You can use this property in all data modes.

Show Example
Copy Code [image] Show Me

Private Sub CheckButtons()

   cmdMoveFirst.Enabled = Not SGGrid1.BOF
   cmdMovePrevious.Enabled = Not SGGrid1.BOF
   cmdMoveNext.Enabled = Not SGGrid1.EOF
   cmdMoveLast.Enabled = Not SGGrid1.EOF

End Sub

Back to topic


BackColor Property

BackColor Property
Returns or sets color for area outside of grid cells.

Read/Write at run time and design time.

Syntax

object.BackColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

After the BackColor property has changed, the grid redraws automatically.

Show Example
Copy Code [image] Show Me

The following example draws the flat grid without borders. The current cell is red because the focus rect covers the contents of the cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.GridBorderStyle = sgNone
   SGGrid1.Appearance = sgFlat
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.BackColor = SGGrid1.Parent.BackColor
   SGGrid1.CellsBorderVisible = False
   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DataRowCount = 4
   SGGrid1.DataColCount = 4
   SGGrid1.FocusRect = sgFocusRectSolid
   SGGrid1.FocusRectColor = vbRed
   SGGrid1.FocusRectLineWidth = 100
End Sub

Back to topic


BkgPicture Property

BkgPicture Property
Returns or sets grid's background picture.

Read/Write at run time and design time.

Syntax

object.BkgPicture As IPictureDisp

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Returns or sets a graphic to be displayed in the grid's background. The BkgPictureAlignment property determines the way a background picture is displayed.

You can load the graphic from the Properties window at design time. At run time, you can also set this property using the LoadPicture function on a bitmap, icon, or metafile.

Show Example
Copy Code [image] Show Me

The following example displays bitmaps from the Windows directory. Double click changes the picture alignment. To try the example, place an SGGrid on a form. Paste the code into the Declarations section and press F5. Change the current row and double click on the grid.

Private Sub Form_Load()
   Dim sFile As String
   Dim sgCol As SGColumn
   Dim sWinDir As String
   Dim i As Integer

   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   'remove all columns and headers
   SGGrid1.Columns.RemoveAll True
   SGGrid1.HeadingRowCount = 0
   SGGrid1.GroupByBoxVisible = False
   'make grid transparent
   SGGrid1.Styles("Normal").BkgStyle = sgCellBkgNone
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.FocusRect = sgFocusRectNone
   SGGrid1.CellsBorderVisible = False
   SGGrid1.BackColor = vbWhite
   SGGrid1.BkgPictureAlignment = sgPicAlignCenterBottom
   SGGrid1.FitLastColumn = True
   SGGrid1.AllowEdit = False
   'Column creations
   SGGrid1.Columns.Add "File"

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.bmp", vbNormal)
   'add files to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i - 1).Cells(0).Value = sFile
      sFile = Dir
   Loop

   'redraw grid
   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_DblClick()

   If SGGrid1.BkgPictureAlignment = sgPicAlignTile Then
      SGGrid1.BkgPictureAlignment = sgPicAlignLeftTop
   Else
      SGGrid1.BkgPictureAlignment = SGGrid1.BkgPictureAlignment + 1
   End If

End Sub

Private Sub SGGrid1_RowColChange(ByVal lastRowKey As Long, ByVal lastColIndex As Long)
   Dim sFileName As String

   sFileName = SGGrid1.Rows.Current.Cells(0).Value

   If Len(sFileName) = 0 Then Exit Sub

   Set SGGrid1.BkgPicture = LoadPicture(Environ("WINDIR") & "\" & sFileName)
End Sub

Back to topic


BkgPictureAlignment Property

BkgPictureAlignment Property
Returns or sets grid's background picture alignment.

Read/Write at run time and design time.

Syntax

object.BkgPictureAlignment As sgPicAlignment

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The BkgPictureAlignment settings are:

Name | Value | Description
sgPicAlignLeftTop | 0 | Align picture to the left-top position.
sgPicAlignCenterTop | 1 | Align picture to the center-top position.
sgPicAlignRightTop | 2 | Align picture to the right-top position.
sgPicAlignLeftCenter | 3 | Align picture to the left-center position.
sgPicAlignCenterCenter | 4 | Align picture to the center-center position.
sgPicAlignRightCenter | 5 | Align picture to the right-center position.
sgPicAlignLeftBottom | 6 | Align picture to the left-bottom position.
sgPicAlignCenterBottom | 7 | Align picture to the center-bottom position.
sgPicAlignRightBottom | 8 | Align picture to the right-bottom position.
sgPicAlignStretch | 9 | Picture is streched to fit cell content.
sgPicAlignTile | 10 | Picture is tiled to fit cell content.

Remarks

Show Example
Copy Code [image] Show Me

The following example displays bitmaps from the Windows directory. Double click changes the picture alignment. To try the example, place an SGGrid on a form. Paste the code into the Declarations section and press F5. Change the current row and double click on the grid.

Private Sub Form_Load()
   Dim sFile As String
   Dim sgCol As SGColumn
   Dim sWinDir As String
   Dim i As Integer

   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   'remove all columns and headers
   SGGrid1.Columns.RemoveAll True
   SGGrid1.HeadingRowCount = 0
   SGGrid1.GroupByBoxVisible = False
   'make grid transparent
   SGGrid1.Styles("Normal").BkgStyle = sgCellBkgNone
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.FocusRect = sgFocusRectNone
   SGGrid1.CellsBorderVisible = False
   SGGrid1.BackColor = vbWhite
   SGGrid1.BkgPictureAlignment = sgPicAlignCenterBottom
   SGGrid1.FitLastColumn = True
   SGGrid1.AllowEdit = False
   'Column creations
   SGGrid1.Columns.Add "File"

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.bmp", vbNormal)
   'add files to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i - 1).Cells(0).Value = sFile
      sFile = Dir
   Loop

   'redraw grid
   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_DblClick()

   If SGGrid1.BkgPictureAlignment = sgPicAlignTile Then
      SGGrid1.BkgPictureAlignment = sgPicAlignLeftTop
   Else
      SGGrid1.BkgPictureAlignment = SGGrid1.BkgPictureAlignment + 1
   End If

End Sub

Private Sub SGGrid1_RowColChange(ByVal lastRowKey As Long, ByVal lastColIndex As Long)
   Dim sFileName As String

   sFileName = SGGrid1.Rows.Current.Cells(0).Value

   If Len(sFileName) = 0 Then Exit Sub

   Set SGGrid1.BkgPicture = LoadPicture(Environ("WINDIR") & "\" & sFileName)
End Sub

Back to topic


BottomRow Property

BottomRow Property
Returns a zero-based index of the last visible row.

Read-only at run time. Not available at design time.

Syntax

object.BottomRow As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Use the At method to reference the last visible row.

The BottomRow property returns a number that represents the position of the last visible row. You can use the At method of the SGRows collection to reference a row by its position.

The following code shows how to reference the bottom row:

   Dim lBottomRowPos As Long
   Dim row As SGRow

   lBottomRowPos = SGGrid1.BottomRow

   Set row = SGGrid1.Rows.At(lBottomRowPos)
Show Example
Copy Code [image] Show Me

The following example scrolls the contents of the grid for all visible rows. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   If SGGrid1.TopRow = SGGrid1.BottomRow Then
      SGGrid1.TopRow = 0
   Else
      SGGrid1.TopRow = SGGrid1.BottomRow
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim col As SGColumn

   SGGrid1.RowNumbering = True

   SGGrid1.DataColCount = 50
   SGGrid1.DataRowCount = 100

   For Each col In SGGrid1.Columns
      col.Caption = col.Key
   Next
End Sub

Back to topic


CacheAllRecords Property

CacheAllRecords Property
Returns or sets a value indicating whether all records are cached in the memory.

Read/Write at run time and design time.

Syntax

object.CacheAllRecords As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

When the BeeGrid control is bound to the external data source, it must keep some records in its internal buffer. The CacheAllRecords controls how many records are cached. If the CacheAllRecords is set to False, the BeeGrid caches only small number of records. If this property is set to True, the BeeGrid caches all records.

The CacheAllRecords property is read/write only in sgBound data mode. In sgUnbound data mode it is read-only and always returns True. Virtual data modes do not support data caching, so the CacheAllRecords property is read-only and returns False.

This property affects following operations:

  • The property ColumnClickSort requires the CacheAllRecords.
  • If you add group to the groups collection, the CacheAllRecords would be automatically set to true
  • The Sort method is much faster if you cashe records.
Show Example
Copy Code [image] Show Me

Private Sub Command1_Click()

   SGGrid1.ColumnClickSort = SGGrid1.CacheAllRecords

End Sub

Back to topic


Caption Property

Caption Property
Returns or sets the text displayed in the grid's caption bar.

Read/Write at run time and design time.

Syntax

object.Caption As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The caption property contains text displayed in the caption bar at the top of the grid. If the Caption property contains zero-length string, the grid's caption bar is not displayed. Change the "Caption" style in the Styles collection to set the caption bar style.

The grid uses font size of the "Caption" style to calculate the caption bar height. It calculates the caption height when you set the caption property.
The following example doesn't change the caption bar height:

   SGGrid1.Caption = "The caption"
   SGGrid1.Styles("Caption").Font.Size = 24

Instead, first set font size and then set the caption text:

   SGGrid1.Styles("Caption").Font.Size = 24
   SGGrid1.Caption = "The caption"

The following code draws the caption bar without text:

   SGGrid1.Caption = " "

Show Example
Copy Code [image] Show Me

The following example changes the grid's caption bar default style. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   With SGGrid1.Styles("Caption")
      .Font.Name = "Tahoma"
      .Font.Bold = True
      .Font.Size = 12
      .TextAlignment = sgAlignLeftCenter
      .ForeColor = vbYellow
      .Padding = 75

      .BackColor = QBColor(1)
      .BackColor2 = RGB(166, 202, 240)
      .BkgStyle = sgCellBkgGradientHorizontal

      .BorderColor = QBColor(4)
      .Borders = sgCellBorderLeft
      .BorderSize = 220
   End With

   SGGrid1.Caption = "The caption"
End Sub

Back to topic


Cell Property

Cell Property
Returns specified cell object.

Read-only at run time. Not available at design time.

Syntax

object.Cell As IsgCell

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The settings for CellKind are:

Name | Value | Description
sgCellStandard | 0 | Standard cell.
sgCellGroupHeader | 2 | Cell is a group header cell.
sgCellGroupFooter | 3 | Cell is a group footer cell.
sgCellPreviewPane | 4 | Cell is a preview pane.
sgCellGroupByBox | 5 | Cell is a group-by box.
sgCellGroupByHeadingCell | 6 | Cell is a column heading inside the group-by box.

Remarks

Arguments
RowKey | A Long that represents the Key of the row.
ColKey | A String expression that represents the Key of the column.
CellKind | A sgCellKind expression that represents the cell's kind.

This property uses row and column keys to return reference to the cell. You can use CellKind parameter instead of the column or row keys.
The following example uses the Cell property to reference a preview pane cell. A row key is omitted:

   Dim sKey As String

   sKey = SGGrid1.Columns.At(1).Key
   SGGrid1.PreviewPaneType = sgPreviewPaneDefault
   SGGrid1.PreviewPaneColumn = sKey
   SGGrid1.PreviewPanePosition = sgPreviewPaneLeft

   With SGGrid1.Cell(0, sKey, sgCellPreviewPane)
      .Style.BackColor = vbGreen
      .Redraw
   End With

Show Example
Copy Code [image] Show Me

The following example paints a cell bellow the mouse pointer. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   Dim lRowKey As Long, sColKey As String
   Dim oCell As SGCell
   Static lOldRowKey As Long
   Static sOldColKey As String

   'check out if mouse pointer is over cells
   If SGGrid1.HitTest(x, y) <> sgHitCell Then Exit Sub
   'get row and col keys
   lRowKey = SGGrid1.Rows.At(SGGrid1.MouseRow).Key
   sColKey = SGGrid1.Columns.At(SGGrid1.MouseCol).Key

   If lOldRowKey = lRowKey And _
      sColKey = sOldColKey Then Exit Sub

   'paint old cell to white
   If Len(sOldColKey) > 0 Then
      Set oCell = SGGrid1.cell(lOldRowKey, sOldColKey)
      oCell.Style.BackColor = vbWhite
      oCell.Redraw
   End If

   Set oCell = SGGrid1.cell(lRowKey, sColKey)
   'paint it red
   oCell.Style.BackColor = vbRed
   Set oCell = Nothing
   'save current keys to static variables
   lOldRowKey = lRowKey
   sOldColKey = sColKey

   SGGrid1.RedrawCell SGGrid1.MouseRow, SGGrid1.MouseCol
End Sub

Back to topic


CellAsPicture Property

CellAsPicture Property
Returns bitmap presentation of a specified grid cell.

Read-only at run time. Not available at design time.

Syntax

object.CellAsPicture As IPictureDisp

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Show Example
Copy Code [image] Show Me

The following example displays a row selector picture on the form. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   'move grid to free place for the form picture
   SGGrid1.Top = 32 * Screen.TwipsPerPixelY

   SGGrid1.DataRowCount = 10
   SGGrid1.RowNumbering = True
End Sub

Private Sub SGGrid1_RowColChange(ByVal lastRowKey As Long, ByVal lastColIndex As Long)
   Dim sRowSelectorKey as String
   'use current for the first time
   If lastRowKey = 0 Then lastRowKey = SGGrid1.CurrentCell.rowKey
   'get a row selector key
   sRowSelectorKey = SGGrid1.Columns.At(0).Key
   'dislay a row selector cell on the form
   Me.Picture = SGGrid1.CellAsPicture(lastRowKey, sRowSelectorKey)
End Sub

Back to topic

See Also

SGGrid


CellAt Property

CellAt Property
Returns specified cell object.

Read-only at run time. Not available at design time.

Syntax

object.CellAt As IsgCell

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Arguments
RowPosition | A Long that identifies the row Position.
ColumnPosition | A Long that identifies the column Position.

This property uses row and column position to return reference to the cell.

The following example paints the upper-left cell with green background color:

   With SGGrid1.CellAt(0, 0)
      .Style.BackColor = vbGreen
      .Redraw
   End With

Show Example
Copy Code [image] Show Me

The following example uses the CellAt property to fill the grid with data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Long, j As Long

   For i = 1 To SGGrid1.DataRowCount
      For j = 1 To SGGrid1.DataColCount
         SGGrid1.CellAt(i, j).Value = "R:" & i & " C:" & j
      Next
   Next
End Sub

Back to topic


CellBackColor Property

CellBackColor Property
Returns or sets cells background color.

Read/Write at run time and design time.

Syntax

object.CellBackColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The CellBackColor property is a shortcut to the BackColor member of the "Normal" style.

The following lines have the same effect

SGGrid1.CellBackColor = vbRed

- or -

SGGrid1.Styles("Normal").BackColor = vbRed
SGGrid1.Redraw

This property has no effect if the CellBkgStyle property is set to sgCellBkgNone or if the EvenOddStyle isn't set to sgNoEvenOdd.


CellBkgStyle Property

CellBkgStyle Property
Returns or sets cells background style.

Read/Write at run time and design time.

Syntax

object.CellBkgStyle As sgCellBkgStyle

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The CellBkgStyle settings are:

Name | Value | Description
sgCellBkgNone | 0 | Do not draw cell border. Cell is transparent.
sgCellBkgSolid | 1 | Draw solid cell background.
sgCellBkgBDiagonal | 2 | Draw backward diagonal pattern in the cell's background.
sgCellBkgFDiagonal | 3 | Draw forward diagonal pattern in the cell's background.
sgCellBkgCross | 4 | Draw cross-hatched pattern in the cell's background.
sgCellBkgDiagCross | 5 | Draw diagonally cross-hatched pattern in the cell's background.
sgCellBkgHorizontal | 6 | Draw horizontal pattern in the cell's background.
sgCellBkgVertical | 7 | Draw vertical pattern in the cell's background.
sgCellBkgGradientVertical | 8 | The background is shaded from top-to-bottom.
sgCellBkgGradientHorizontal | 9 | The background is shaded from left-to-right.

Remarks

The CellBkgStyle property is a shortcut to the BkgStyle member of the "Normal" style.
The following lines have the same effect:

SGGrid1.CellBkgStyle = sgCellBkgCross
- or -

SGGrid1.Styles("Normal").BkgStyle = sgCellBkgCross
SGGrid1.Redraw

Show Example
Copy Code [image] Show Me

The following example loads the background picture and makes grid's cells transparent. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   'find bitmap to show
   If StrComp(Environ("OS"), "Windows_NT", vbTextCompare) = 0 Then
      Set SGGrid1.BkgPicture = LoadPicture(Environ("WINDIR") & "\system32\Setup.bmp")
   Else
      Set SGGrid1.BkgPicture = LoadPicture(Environ("WINDIR") & "\Setup.bmp")
   End If

   SGGrid1.GroupByBoxVisible = False
   'make the grids cell transparent
   SGGrid1.CellBkgStyle = sgCellBkgNone
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.HeadingColCount = 0
   SGGrid1.CellsBorderVisible = False

   SGGrid1.Styles("Heading").BkgStyle = sgCellBkgSolid
   SGGrid1.FitLastColumn = True

End Sub

Back to topic


CellForeColor Property

CellForeColor Property
Returns or sets cells foreground color.

Read/Write at run time and design time.

Syntax

object.CellForeColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The CellForeColor property is a shortcut to the ForeColor member of the "Normal" style.

The following lines have the same effect:

SGGrid1.CellForeColor = vbRed

- or -

SGGrid1.Styles("Normal").ForeColor = vbRed
SGGrid1.Redraw


CellPadding Property

CellPadding Property
Returns or sets the space between the contents and inside edges of cells.

Read/Write at run time and design time.

Syntax

object.CellPadding As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The CellPadding describes how much space to insert between the cell's text and cell's border. The property is specified in the container's scale units. This property is a shortcut to the Padding member of the "Normal" style.
The following lines have the same effect:

SGGrid1.CellPadding = 50

- or -

SGGrid1.Styles("Normal").Padding = 50
SGGrid1.Redraw

Show Example
Copy Code [image] Show Me

The following example sets rows height to twice the text height. It also sets the CellPadding to one third of the text height. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim sngTextHeight As Single

   SGGrid1.Array(0, 0) = "Sample text"

   Set Me.Font = SGGrid1.Styles("Normal").Font
   sngTextHeight = Me.TextHeight("W")
   SGGrid1.EqualRowHeight = True
   SGGrid1.Rows.At(1).Height = sngTextHeight * 2

   SGGrid1.CellPadding = sngTextHeight / 3

End Sub

Back to topic


CellStyleConditions Property

CellStyleConditions Property
Returns the collection of conditional style rules.

Read-only at run time. Not available at design time.

Syntax

object.CellStyleConditions As IsgStyleConditions

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The CellStyleConditions property returns collection of the SGStyleCondition objects. Each object in this collection represents one style and condition when that style can be applied. When the BeeGrid paints a cell, it examines this collection and if condition is met, style is applied to the cell.

You can manipulate members of the SGStyleConditions collection by using standard collection methods. Each object in the collection can be accessed by its index.

Use the Add method to add new condition to collection:

   SGGrid1.CellStyleConditions.Add _
      "Tip", sgConditionCellValue, sgOpEqual, 1

   SGGrid1.Array.Value(0, 0) = 1

For more information, see the SGStyleConditions topic.

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers and creates a StyleCondition for each possible cell value. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sStyleName As String
   Dim i As Long, j As Long
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   'create cols and rows
   SGGrid1.DataRowCount = 20
   SGGrid1.DataColCount = 3
   'create 256 styles
   For i = 0 To 255
      sStyleName = "Style" & Trim$(i)
      With SGGrid1.Styles.Add(sStyleName)
         .CopyFrom SGGrid1.Styles("Normal")
         .BackColor = RGB(255 - i, 255 - i, 255 - i)
         .ForeColor = RGB(255, i, 0)
         .Font.Bold = True
      End With
      'add new style in the StyleConditions collection
      SGGrid1.CellStyleConditions.Add _
         sStyleName, sgConditionCellValue, sgOpEqual, i
   Next

   Set ar = SGGrid1.Array
   'add test data
   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 255)
      Next
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


CellTips Property

CellTips Property
Returns or sets a value indicating whether cell tips are displayed.

Read/Write at run time and design time.

Syntax

object.CellTips As sgCellTip

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The CellTips settings are:

Name | Value | Description
sgCellTipsNone | 0 | Cell tips are not displayed.
sgCellTipsStatic | 1 | Show static cell tip.
sgCellTipsFloat | 2 | Show floating cell tip.

Remarks

The CellTips property determines how a cell tip will be displayed. The grid displays a cell tip when the user pauses with the mouse pointer over the grid for the period of time set by the CellTipsDelay property.

Use the FetchCellTip event to set cell tip's text, picture, size and style.

By default, this property is set to sgCellTipsNone, and cell tips are not displayed.

Show Example
Copy Code [image] Show Me

The following example displays the cell tips for different types of columns. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray

   SGGrid1.DataRowCount = 0
   SGGrid1.DefaultRowHeight = 305
   SGGrid1.DataRowCount = 10
   SGGrid1.DataColCount = 4

   SGGrid1.CellTips = sgCellTipsFloat
   SGGrid1.CellTipsDelay = 500

   SGGrid1.Columns.At(1).Style. _
      DisplayType = sgDisplayTextAndPicture
   SGGrid1.Columns.At(2).Style. _
      DisplayType = sgDisplayPicture
   SGGrid1.Columns.At(3).Style. _
      DisplayType = sgDisplayText

   For i = 1 To 3
      With SGGrid1.Columns.At(i)
         .Control.Type = sgCellDropDown
         For j = 1 To 10
            .ValueItems.Add j, "Item " & Trim(j), sgbipFirst + j
         Next
      End With
   Next

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 9) + 1
      Next
   Next
End Sub

Back to topic


CellTipsDelay Property

CellTipsDelay Property
Returns or sets the amount of time before cell tip is displayed.

Read/Write at run time and design time.

Syntax

object.CellTipsDelay As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The CellTipsDelay property controls the amount of idle time that must elapse before the cell tip is displayed. By default, this property is set to 1000 milliseconds.

The property is ignored if the CellTips property is set to sgCellTipsNone.

Show Example
Copy Code [image] Show Me

The following example displays the cell tips for different types of columns. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray

   SGGrid1.DataRowCount = 0
   SGGrid1.DefaultRowHeight = 305
   SGGrid1.DataRowCount = 10
   SGGrid1.DataColCount = 4

   SGGrid1.CellTips = sgCellTipsFloat
   SGGrid1.CellTipsDelay = 500

   SGGrid1.Columns.At(1).Style. _
      DisplayType = sgDisplayTextAndPicture
   SGGrid1.Columns.At(2).Style. _
      DisplayType = sgDisplayPicture
   SGGrid1.Columns.At(3).Style. _
      DisplayType = sgDisplayText

   For i = 1 To 3
      With SGGrid1.Columns.At(i)
         .Control.Type = sgCellDropDown
         For j = 1 To 10
            .ValueItems.Add j, "Item " & Trim(j), sgbipFirst + j
         Next
      End With
   Next

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 9) + 1
      Next
   Next
End Sub

Back to topic


CellsBorderColor Property

CellsBorderColor Property
Returns or sets the color of the line dividing cells from the grid background.

Read/Write at run time and design time.

Syntax

object.CellsBorderColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The cells border is one pixel wide line that separates cells from the grid background. The default line color is black. If the CellsBorderVisible property is set to False, cells border is not drawn.

Show Example
Copy Code [image] Show Me

The following example paints the grid's lines and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.HeadingBackColor = RGB(174, 168, 217)
   SGGrid1.GridLinesColor = RGB(174, 168, 217)
   SGGrid1.CellsBorderColor = RGB(90, 78, 177)
   SGGrid1.HeadingGridLinesColor = RGB(216, 213, 236)
   SGGrid1.HeadingGridLines = sgGridLineFlat
End Sub

Back to topic


CellsBorderVisible Property

CellsBorderVisible Property
Returns or sets a value indicating whether cells border line is drawn.

Read/Write at run time and design time.

Syntax

object.CellsBorderVisible As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The cells border is one pixel wide line that separates cells from the grid background. By default, this line is black. Use the CellsBorderColor property to change the color of the line.

Show Example
Copy Code [image] Show Me

The following example draws the flat grid without borders. The current cell is red because the focus rect covers the contents of the cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.GridBorderStyle = sgNone
   SGGrid1.Appearance = sgFlat
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.BackColor = SGGrid1.Parent.BackColor
   SGGrid1.CellsBorderVisible = False
   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DataRowCount = 4
   SGGrid1.DataColCount = 4
   SGGrid1.FocusRect = sgFocusRectSolid
   SGGrid1.FocusRectColor = vbRed
   SGGrid1.FocusRectLineWidth = 100
End Sub

Back to topic


ClientHeight Property

ClientHeight Property
Returns height of control's client area.

Read-only at run time. Not available at design time.

Syntax

object.ClientHeight As OLE_YSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The ClientHeight property returns height of the area in which grid cells are displayed. Client height does not include scrollbars, grid's caption, group-by box and preview pane. The ClientHeight property is specified in the container's coordinate system.

Show Example
Copy Code [image] Show Me

The following example creates the grid and resizes the grid's cells. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      'create cols and rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .GroupByBoxVisible = False
      .DataColCount = 8
      .DataRowCount = 8
      .EqualColWidth = True
      .EqualRowHeight = True
      'set grid props
      .GridBorderStyle = sgNone
      .BackColor = .Parent.BackColor
      .ScrollBars = sgSBNone
      .FocusRect = sgFocusRectNone
      .AllowEdit = False
      'apply oddeven style
      .EvenOddStyle = sgEvenOddBoth
      .ColorEven = vbBlack
      .ColorOdd = vbWhite
      'set cell borders
      With .Styles("Normal")
         .BorderSize = 1
         .BorderColor = vbYellow
         .Borders = sgCellBorderLeft + sgCellBorderTop
      End With
      .CellsBorderColor = vbYellow
   End With
End Sub

Private Sub Form_Resize()

   SGGrid1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight

   SGGrid1.Columns.At(0).Width = SGGrid1.ClientWidth \ SGGrid1.ColCount
   SGGrid1.Rows.At(0).Height = SGGrid1.ClientHeight \ SGGrid1.RowCount

End Sub

Back to topic


ClientWidth Property

ClientWidth Property
Returns width of control's client area.

Read-only at run time. Not available at design time.

Syntax

object.ClientWidth As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The ClientWidth property returns width of the area in which grid cells are displayed. The Client width does not include scrollbars and preview pane. The value of the ClientWidth property is specified in the container's coordinate system.

Show Example
Copy Code [image] Show Me

The following example creates the grid and resizes the grid's cells. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      'create cols and rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .GroupByBoxVisible = False
      .DataColCount = 8
      .DataRowCount = 8
      .EqualColWidth = True
      .EqualRowHeight = True
      'set grid props
      .GridBorderStyle = sgNone
      .BackColor = .Parent.BackColor
      .ScrollBars = sgSBNone
      .FocusRect = sgFocusRectNone
      .AllowEdit = False
      'apply oddeven style
      .EvenOddStyle = sgEvenOddBoth
      .ColorEven = vbBlack
      .ColorOdd = vbWhite
      'set cell borders
      With .Styles("Normal")
         .BorderSize = 1
         .BorderColor = vbYellow
         .Borders = sgCellBorderLeft + sgCellBorderTop
      End With
      .CellsBorderColor = vbYellow
   End With
End Sub

Private Sub Form_Resize()

   SGGrid1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight

   SGGrid1.Columns.At(0).Width = SGGrid1.ClientWidth \ SGGrid1.ColCount
   SGGrid1.Rows.At(0).Height = SGGrid1.ClientHeight \ SGGrid1.RowCount

End Sub

Back to topic


Col Property

Col Property
Returns or sets current column position

Read/Write at run time. Not available at design time.

Syntax

object.Col As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Col property can be used to set current column and to find out what column is current.

In addition, you can get the current column position with following code:

SGGrid1.Columns.Current.Position

-or-

SGGrid1.CurrentCell.Column.Position

Use the Row property to get or set the current row position.

Show Example
Copy Code [image] Show Me

The following example changes the current col and row. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()

   If SGGrid1.col = SGGrid1.ColCount - 1 Then
      If SGGrid1.row = SGGrid1.RowCount - 1 Then
         SGGrid1.row = SGGrid1.HeadingRowCount
      Else
         SGGrid1.row = SGGrid1.row + 1
      End If
      SGGrid1.col = SGGrid1.HeadingColCount
   Else
      SGGrid1.col = SGGrid1.col + 1
   End If

End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.Styles("CurrentCell").BackColor = vbBlue
End Sub

Back to topic


ColCount Property

ColCount Property
Returns the total number of columns.

Read-only at run time. Not available at design time.

Syntax

object.ColCount As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The read-only ColCount property returns the total number of columns. It is always the sum of the values returned from the HeadingColCount and the DataColCount properties. To change number of columns, use the DataColCount property, and to change number of heading columns, use the HeadingColCount property.

Here are several ways to get the columns count:

SGGrid1.ColCount

- or -

SGGrid1.Columns.Count

- or -

SGGrid1.DataColCount + SGGrid1.HeadingColCount

Show Example
Copy Code [image] Show Me

The following example changes the current col and row. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()

   If SGGrid1.col = SGGrid1.ColCount - 1 Then
      If SGGrid1.row = SGGrid1.RowCount - 1 Then
         SGGrid1.row = SGGrid1.HeadingRowCount
      Else
         SGGrid1.row = SGGrid1.row + 1
      End If
      SGGrid1.col = SGGrid1.HeadingColCount
   Else
      SGGrid1.col = SGGrid1.col + 1
   End If

End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.Styles("CurrentCell").BackColor = vbBlue
End Sub

Back to topic


ColWidthMax Property

ColWidthMax Property
Returns or sets the maximum column width.

Read/Write at run time and design time.

Syntax

object.ColWidthMax As OLE_YSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The ColWidthMax property determines the maximum column width. The value of the ColWidthMax property is specified in the container's coordinate system.

Show Example
Copy Code [image] Show Me

The following example shows how to set rows and columns dimensions.

Private Sub SGGrid1_OnInit()

   SGGrid1.DefaultColWidth = 305
   SGGrid1.DefaultRowHeight = 305

   SGGrid1.ColWidthMin = 250
   SGGrid1.ColWidthMax = 505

   SGGrid1.RowHeightMin = 250
   SGGrid1.RowHeightMax = 505

   SGGrid1.EqualColWidth = True
   SGGrid1.EqualRowHeight = True
End Sub

Back to topic


ColWidthMin Property

ColWidthMin Property
Returns or sets the minimum column width.

Read/Write at run time and design time.

Syntax

object.ColWidthMin As OLE_YSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The ColWidthMin property determines the minimum column width. The value of the ColWidthMin property is specified in the container's coordinate system.

Show Example
Copy Code [image] Show Me

The following example shows how to set rows and columns dimensions.

Private Sub SGGrid1_OnInit()

   SGGrid1.DefaultColWidth = 305
   SGGrid1.DefaultRowHeight = 305

   SGGrid1.ColWidthMin = 250
   SGGrid1.ColWidthMax = 505

   SGGrid1.RowHeightMin = 250
   SGGrid1.RowHeightMax = 505

   SGGrid1.EqualColWidth = True
   SGGrid1.EqualRowHeight = True
End Sub

Back to topic


ColorEven Property

ColorEven Property
Returns or sets color for even rows and/or columns.

Read/Write at run time and design time.

Syntax

object.ColorEven As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Use the ColorEven property to change background color of the even rows and/or columns. Alternating background colors will be used only if alternating style is enabled by setting EvenOddStyle property.

This property has no effect if the CellBkgStyle property is set to sgCellBkgNone.

Show Example
Copy Code [image] Show Me

The following example creates the black-white grid and fills grid with the sample data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim row As SGRow, cell As SGCell

   With SGGrid1
      .RedrawEnabled = False
      'create cols and rows
      .DataColCount = 10
      .DataRowCount = 10
      .EqualColWidth = True
      .EqualRowHeight = True
      .GroupByBoxVisible = False
      'apply oddeven style
      .EvenOddStyle = sgEvenOddBoth
      .ColorEven = vbBlack
      .ColorOdd = vbWhite
      .Styles("CurrentCell").ForeColor = vbRed
   End With
   'add sample text and change cells forecolor
   For Each row In SGGrid1.Rows
      For Each cell In row.Cells
         'check out if the cell is heading
         If Not (cell.Column.Heading Or row.Heading) Then
            cell.Value = "Row: " & Trim(row.Position) _
               & " Col: " & Trim(cell.Column.Position)
            'change fore color for black cells
            If row.Position Mod 2 Xor cell.Column.Position Mod 2 Then
               cell.Style.ForeColor = vbWhite
            End If
         End If
      Next
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


ColorOdd Property

ColorOdd Property
Returns or sets color for odd rows and/or columns.

Read/Write at run time and design time.

Syntax

object.ColorOdd As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Use the ColorOdd property to change the background color of the odd rows and/or columns. Alternating background colors will be used only if alternating style is enabled by setting EvenOddStyle property.

This property has no effect if the CellBkgStyle property is set to sgCellBkgNone.

Show Example
Copy Code [image] Show Me

The following example creates the black-white grid and fills grid with the sample data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim row As SGRow, cell As SGCell

   With SGGrid1
      .RedrawEnabled = False
      'create cols and rows
      .DataColCount = 10
      .DataRowCount = 10
      .EqualColWidth = True
      .EqualRowHeight = True
      .GroupByBoxVisible = False
      'apply oddeven style
      .EvenOddStyle = sgEvenOddBoth
      .ColorEven = vbBlack
      .ColorOdd = vbWhite
      .Styles("CurrentCell").ForeColor = vbRed
   End With
   'add sample text and change cells forecolor
   For Each row In SGGrid1.Rows
      For Each cell In row.Cells
         'check out if the cell is heading
         If Not (cell.Column.Heading Or row.Heading) Then
            cell.Value = "Row: " & Trim(row.Position) _
               & " Col: " & Trim(cell.Column.Position)
            'change fore color for black cells
            If row.Position Mod 2 Xor cell.Column.Position Mod 2 Then
               cell.Style.ForeColor = vbWhite
            End If
         End If
      Next
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


ColumnClickSort Property

ColumnClickSort Property
Returns or sets a value indicating whether user may sort column by clicking on the column heading.

Read/Write at run time and design time.

Syntax

object.ColumnClickSort As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Set the ColumnClickSort to True to allow the user to sort data by clicking on the column's head. The SGColumn's property SortType determines how the column will be sorted. Note that column-click-sort does not work if data caching is not enabled (the CacheAllRecords property is False).

In addition, note that if column headings are not visible (the HeadingRowCount property is zero), user will not be able to sort columns.

Show Example
Copy Code [image] Show Me

The following example shows how to use the CheckBox to switch on/off the ColumnClickSort property.

Private Sub Check1_Click()
   SGGrid1.CacheAllRecords = Check1.Value
   SGGrid1.ColumnClickSort = Check1.Value
End Sub

Back to topic


Columns Property

Columns Property
Returns a collection of grid columns.

Read-only at run time. Not available at design time.

Syntax

object.Columns As IsgColumns

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Columns property returns SGColumns collection. Each object in this collection represents one grid column. Columns in the SGColumns colletion can be accessed by column index, position or key.

Note: the column key is case sensitive.

For example, if the column key is "Col2" then you can access it with following line:

SGGrid1.Columns("Col2").Caption = "Caption"

but if you try to access the column with a line below, a trappable error occurs.

SGGrid1.Columns("COL2").Caption = "Caption"

For more information, see the SGColumns topic.

Show Example
Copy Code [image] Show Me

The following example sets the column's caption and paints it red. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim col As SGColumn

   For Each col In SGGrid1.Columns
      col.Caption = col.Key
      col.HeadingStyle.ForeColor = vbRed
      col.HeadingStyle.Font.Bold = True
   Next
End Sub

Back to topic


CurBookmark Property

CurBookmark Property
Returns or sets the bookmark identifying the current row.

Read/Write at run time. Not available at design time.

Syntax

object.CurBookmark As Variant

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The CurBookmark property represents current row's bookmark. Setting it to a valid bookmark value associated with some row, makes that row the current row and brings it into the view. Current row's bookmark is also accessible through the SGGrid.Rows.Current.Bookmark property.

The sgVirtualInterface data mode doesn't support bookmarks.


CurrentCell Property

CurrentCell Property
Returns current cell as an SGCell object.

Read-only at run time. Not available at design time.

Syntax

object.CurrentCell As IsgCell

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The CurrentCell property returns the SGCell object that represents current cell. You can use this property to access and change attributes of the current cell.

Show Example
Copy Code [image] Show Me

The following example changes the current cell and paints it red.

Private Sub Command1_Click()
   Dim i As Integer

   If SGGrid1.col = SGGrid1.ColCount - 1 Then
      If SGGrid1.row = SGGrid1.RowCount - 1 Then
         SGGrid1.row = SGGrid1.HeadingRowCount
      Else
         SGGrid1.row = SGGrid1.row + 1
      End If
      SGGrid1.col = SGGrid1.HeadingColCount
   Else
      SGGrid1.col = SGGrid1.col + 1
   End If

   SGGrid1.CurrentCell.Style.BackColor = vbRed
   SGGrid1.CurrentCell.Redraw
End Sub

Back to topic


CustomBkgDraw Property

CustomBkgDraw Property
Value indicating whether custom draw for grid background is enabled.

Read/Write at run time and design time.

Syntax

object.CustomBkgDraw As sgCustomDrawStage

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The CustomBkgDraw settings are:

Name | Value | Description
sgNoCustomDraw | 0 | The grid will draw all stages itself.
sgDrawBeforeGridBkg | 1 | Before the grid's background is drawn.
sgDrawAfterGridBkg | 2 | After the grid's background has been drawn.
sgDrawBeforeGridCaption | 3 | Before the grid's caption is drawn.
sgDrawAfterGridCaption | 4 | After the grid's caption has been drawn.
sgDrawBeforeGridCorner | 5 | Before the grid's corner is drawn.
sgDrawAfterGridCorner | 6 | After the grid's corner has been drawn.
sgDrawBeforePreviewPaneSplitter | 7 | Before the preview pane's splitter bar is drawn.
sgDrawAfterPreviewPaneSplitter | 8 | After the preview pane's splitter bar has been drawn.
sgDrawBeforeFocusRect | 9 | Before the grid's focus rectangle is drawn.
sgDrawAfterFocusRect | 10 | After the grid's focus rectangle has been drawn.
sgDrawBeforeCellBorder | 11 | Before the cell's border (grid lines, border and padding) is drawn.
sgDrawAfterCellBorder | 12 | After the cell's border (grid lines, border and padding) has been drawn.
sgDrawBeforeCellBkg | 13 | Before the cell's background is drawn.
sgDrawAfterCellBkg | 14 | After the cell's background has been drawn.
sgDrawBeforeCellButton | 15 | Before the cell's button is drawn.
sgDrawAfterCellButton | 16 | After the cell's button has been drawn.
sgDrawBeforeCellBkgPicture | 17 | Before the cell's background picture is drawn.
sgDrawAfterCellBkgPicture | 18 | After the cell's background picture has been drawn.
sgDrawBeforeCellContent | 19 | Before the cell's content is drawn.
sgDrawAfterCellContent | 20 | After the cell's content has been drawn.

Remarks

To implement custom draw, create an object that implements the IsgGridCustomDraw interface. Reference this object to the PaintObject.

Show Example
Copy Code [image] Show Me

The following example draws two circles on the grid. It draws one on the caption area and another on the background. It fills the first column with random data. Example uses this data to draw small rectangle on the left corner. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Implements IsgGridCustomDraw

Private Declare Function SelectObject Lib "gdi32" _
   (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
   (ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" _
   (ByVal crColor As Long) As Long
Private Declare Function Ellipse Lib "gdi32" _
   (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _
   ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreatePen Lib "gdi32" _
   (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function Rectangle Lib "gdi32" _
   (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _
   ByVal X2 As Long, ByVal Y2 As Long) As Long

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.Caption = "Custom draw"

   Set SGGrid1.PaintObject = Me
   SGGrid1.CustomBkgDraw = sgDrawBeforeGridBkg

   With SGGrid1.Columns.At(1)
      .Style.CustomDraw = sgDrawAfterCellContent
      .Caption = "Custom draw"
   End With

   SGGrid1.DataRowCount = 100

   For i = 0 To SGGrid1.DataRowCount - 1
      SGGrid1.Array(i, 0) = CLng(Rnd * vbWhite)
   Next
End Sub

Private Sub IsgGridCustomDraw_DrawGridBkg( _
   drawInfo As sgGridCustomDraw, _
   response As sgCustomDrawResponse)
   Dim hBrush As Long
   Dim hOldBrush As Long

   If drawInfo.DrawStage = sgDrawAfterGridCaption Then
      ' Draw caption
      hBrush = CreateSolidBrush(RGB(255, 0, 0))
      hOldBrush = SelectObject(drawInfo.DC, hBrush)

      Ellipse drawInfo.DC, drawInfo.Left + 6, drawInfo.Top + 2, _
                            drawInfo.Left + 20, drawInfo.bottom - 1

      SelectObject drawInfo.DC, hOldBrush
      DeleteObject hBrush
   ElseIf drawInfo.DrawStage = sgDrawAfterGridBkg Then

      hBrush = CreateSolidBrush(RGB(255, 0, 0))
      hOldBrush = SelectObject(drawInfo.DC, hBrush)

      Ellipse drawInfo.DC, drawInfo.right - 70, drawInfo.bottom - 40, _
                            drawInfo.right - 34, drawInfo.bottom - 4

      SelectObject drawInfo.DC, hOldBrush
      DeleteObject hBrush
   End If

   response = sgDoDefault
End Sub

Private Sub IsgGridCustomDraw_DrawCell( _
   drawInfo As sgGridCustomDraw, _
   response As sgCustomDrawResponse)
   Dim hPen As Long
   Dim hOldPen As Long
   Dim sData As String

   response = sgDoDefault

   ' Ignore heading cells
   If drawInfo.Heading <> 0 Then Exit Sub

   If drawInfo.DrawStage = sgDrawAfterCellBkg Then
      If drawInfo.ColIndex = 1 Then
         ' Draw left positioned color box and adjust content rect
         ' so grids default painting will not overwrite our color box
         ' Get color
         Dim clr As Long

         clr = CLng(drawInfo.Data)

         ' Draw rectangle
         DrawRectangle drawInfo.DC, clr, drawInfo.Left + 4, drawInfo.Top + 2, _
                                          drawInfo.Left + (drawInfo.bottom - drawInfo.Top), drawInfo.bottom - 2

         drawInfo.Left = drawInfo.Left + 26
      End If
   End If
End Sub

Private Sub DrawRectangle(hdc&, clr&, Left&, Top&, right&, bottom&)
   Dim hBrush As Long
   Dim hPen As Long
   Dim hOldBrush As Long
   Dim hOldPen As Long

   ' Create pen and brush
   hPen = CreatePen(0, 0, RGB(0, 0, 0))
   hBrush = CreateSolidBrush(clr)
   hOldPen = SelectObject(hdc, hPen)
   hOldBrush = SelectObject(hdc, hBrush)

   ' Draw rectangle
   Rectangle hdc, Left, Top, right, bottom

   ' Release pen and brush
   SelectObject hdc, hOldPen
   SelectObject hdc, hOldBrush
   DeleteObject hPen
   DeleteObject hBrush
End Sub

Back to topic


DataColCount Property

DataColCount Property
Returns or sets the total number of data columns.

Read/Write at run time and design time.

Syntax

object.DataColCount As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The DataColCount property returns or sets the number of data columns. Total column count is a sum of heading columns and data columns. Data columns can be bound or unbound.

You can set number of columns using this property in all data modes.

Show Example
Copy Code [image] Show Me

The following example calculates the estimated time required for loading grid array with data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray
   Dim t As Date
   Dim i As Long, j As Long
   'save start time
   t = Time
   'assign grid array to variable
   Set ar = SGGrid1.Array
   'hide group box
   SGGrid1.GroupByBoxVisible = False
   'create rows and columns
   SGGrid1.DataRowCount = 100
   SGGrid1.DataColCount = 20
   'load test data
   For i = 0 To ar.RowCount - 1
      For j = 0 To ar.ColCount - 1
         ar.Value(i, j) = "Row=" & i & " Col=" & j
      Next
   Next

   Set ar = Nothing
   'show estimate time in the grid's caption
   Me.Caption = "Time: " & DateDiff("s", t, Time)
End Sub

Back to topic


DataEntryLocked Property

DataEntryLocked Property
Disables user update, delete and insert operations.

Read/Write at run time. Not available at design time.

Syntax

object.DataEntryLocked As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The DataEntryLocked property enables or disables editing and updating of the data displayed in the grid. It can be used to temporarily disable user input while preserving navigation capabilities.

Setting the DataEntryLocked property does not change value of the AllowEdit, AllowDelete and AllowAddNew properties.


DataMember Property

DataMember Property
Returns or sets the DataMember for the OLEDB data source.

Read/Write at run time and design time.

Syntax

object.DataMember As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Returns or sets a specified data member from among several offered by the data provider.

A data provider can have multiple sets of data that data consumer can choose to bind to. Each set of data is called "data member," and is identified by a unique string.

It is used only in bound mode and has no effect in other modes.

Note: This property is only supported by the OLEDB version of the BeeGrid control.


DataMode Property

DataMode Property
Returns or sets type of the data source the control is using.

Read/Write at run time and design time.

Syntax

object.DataMode As sgDataMode

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The DataMode settings are:

Name | Value | Description
sgBound | 0 | SGGrid is connected to the external OLEDB data source.
sgUnbound | 1 | SGGrid is not connected to the external data source. It uses internal buffer to store cell data.
sgVirtualEvents | 2 | SGGrid uses events to fetch cell data.
sgVirtualInterface | 3 | SGGrid uses externally implemented interface to fetch cell data.

Remarks

The BeeGrid control can use data from various sources: data controls, OLEDB and ADO recordsets, custom databases and data structures or grid's internal buffer. The DataMode property determines what kind of data source grid will use.

When set to sgBound, grid displays data obtained from the data source attached to its DataSource property. This can be data control or OLEDB recordset.

When set to sgUnbound, grid displays data from its internal buffer. You can use Array property to read from and write to this buffer. In addition, you can use ImportData and ImportDataString methods to fill internal buffer with data.

When set to sgVirtualEvents, grid displays data that you supply by responding to VirtualReadData, VirtualWriteData, VirtualAddRow and VirtualDeleteRow events.

When set to sgVirtualInterface, grid displays data that you supply by implementing simple IsgGridDataSource COM interface. To bound grid to the IsgGridDataSource, you must assign object that implements this interface to the SimpleDataSource property.

Unbound columns are available in all data modes. Columns with the DBField property set to a zero-length string ("") are unbound and you can use FetchColumnData event to provide data for them.

Each data mode uses following properties, methods and events:

  • Bound: - the grid is connected to the external OLEDB data source.
    • DataSource - returns or sets a data source. Usually it's ADO recordset or data control used to bind a grid to a database.
    • DataMember - returns or sets the DataMember for the OLEDB data source.
    • LoadAllRecords - loads all records from the data source.
    • AutoFields - enables or disables automatic column/field mapping.
    • AutoResize - returns or sets value indicating whether columns and/or rows are automatically resized when grid data is loaded.
    These properties and methods are not available in other data modes.
  • Unbound: the grid uses the SGArray object as a data source. This is the simplest way to use the grid.
    • Array - returns the Array object that represents cell data. The Array is read only in other data modes.
    • ExportData and ExportDataString - exports grid data to a file or string. Exports are also available in other data modes.
    • ImportData and ImportDataString - imports data from a file or string. Imports are available in unbound mode only

    Note: the property CacheAllRecords is always true in the unbound mode.
  • Virtual Events: the grid uses events to fetch cell data. Usually, data is stored in a two-dimensional array.
    • VirtualReadData - fired when the grid needs data for a row.
    • VirtualAddRow - fired when a new row is added to the grid.
    • VirtualWriteData - fired when the grid needs to modify data.
    • VirtualDeleteRow - fired when a row is deleted from the grid.
    These events are not available in other data modes.
  • Virtual Interface: - the grid uses custom COM interface as data source. This mode is useful when you have large amounts of data stored in custom structures or objects.
    • SimpleDataSource - implements the IsgGridDataSource interface. It's not available in other data modes.
      The IsgGridDataSource implements following functions:
      • GetRowData - this method providing data to the grid's row.
      • GetRowCount - returns rows count.
      • AddRow - returns true if the new row is added.
      • SetRowData - updates the data when the user changes them.
      • DeleteRow - returns true if a row is deleted.
    Note: this mode doesn't use bookmarks.


DataRowCount Property

DataRowCount Property
Returns or sets the number of data rows.

Read/Write at run time and design time.

Syntax

object.DataRowCount As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The DataRowCount property returns the number of data rows. Total row count is a sum of heading rows and data rows. This property is writable only in the sgUnbound data mode.

Show Example
Copy Code [image] Show Me

The following example calculates the estimated time required for loading grid array with data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray
   Dim t As Date
   Dim i As Long, j As Long
   'save start time
   t = Time
   'assign grid array to variable
   Set ar = SGGrid1.Array
   'hide group box
   SGGrid1.GroupByBoxVisible = False
   'create rows and columns
   SGGrid1.DataRowCount = 100
   SGGrid1.DataColCount = 20
   'load test data
   For i = 0 To ar.RowCount - 1
      For j = 0 To ar.ColCount - 1
         ar.Value(i, j) = "Row=" & i & " Col=" & j
      Next
   Next

   Set ar = Nothing
   'show estimate time in the grid's caption
   Me.Caption = "Time: " & DateDiff("s", t, Time)
End Sub

Back to topic


DataSource Property

DataSource Property
Returns or sets data source.

Read/Write at run time and design time.

Syntax

object.DataSource As DataSource

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Returns or sets a data source through which the BeeGrid is bound to a database. The data source can be OLEDB or ADO recordset or data control. The BeeGrid supports two types of data controls: older ICursor based and new OLEDB based. In the ICursor version, you can change the DataSource property at design time only.

Note: The SGGrid OLEDB version can bind to a recordset without bookmarks.

Show Example
Copy Code [image] Show Me

The following example bounds the grid to an ADO recordset.

Private Sub Form_Load()
   Dim rs As New ADODB.Recordset

   rs.Open "Products", "NorthWind", adOpenDynamic, adLockReadOnly

   SGGrid1.DataMode = sgBound
   Set SGGrid1.DataSource = rs
   Set rs = Nothing
End Sub

Back to topic


DefaultColWidth Property

DefaultColWidth Property
Returns or sets the default column width.

Read/Write at run time and design time.

Syntax

object.DefaultColWidth As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The DefaultColWidth property contains default width for the newly created columns. It is specified in the container's coordinate system. Setting this property at run time does not affect existing columns.

Note: this property doesn't affect the heading column.

Show Example
Copy Code [image] Show Me

The following example shows how to set rows and columns dimensions.

Private Sub SGGrid1_OnInit()

   SGGrid1.DefaultColWidth = 305
   SGGrid1.DefaultRowHeight = 305

   SGGrid1.ColWidthMin = 250
   SGGrid1.ColWidthMax = 505

   SGGrid1.RowHeightMin = 250
   SGGrid1.RowHeightMax = 505

   SGGrid1.EqualColWidth = True
   SGGrid1.EqualRowHeight = True
End Sub

Back to topic


DefaultRowHeight Property

DefaultRowHeight Property
Returns or sets the default row height.

Read/Write at run time and design time.

Syntax

object.DefaultRowHeight As OLE_YSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The DefaultRowHeight property contains default height for the newly created rows. It is specified in the container's coordinate system. Setting this property at run time does not affect existing rows.

Note: this property doesn't affect the heading row.

Show Example
Copy Code [image] Show Me

The following example shows how to set rows and columns dimensions.

Private Sub SGGrid1_OnInit()

   SGGrid1.DefaultColWidth = 305
   SGGrid1.DefaultRowHeight = 305

   SGGrid1.ColWidthMin = 250
   SGGrid1.ColWidthMax = 505

   SGGrid1.RowHeightMin = 250
   SGGrid1.RowHeightMax = 505

   SGGrid1.EqualColWidth = True
   SGGrid1.EqualRowHeight = True
End Sub

Back to topic


DragAlphaLevel Property

DragAlphaLevel Property
Returns or sets an alpha transparency value to be used on the dragged image.
Syntax

object.DragAlphaLevel As Integer

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property has effect only if the UserDragging property is set to sgAllowColDrag or sgAllowRowColDrag.

Note: Alpha blending is not supported by Windows 95. In addition, it requires video device in a high-color or true-color mode.

Show Example
Copy Code [image] Show Me

The following example demonstrates the DragAlphaLevel property. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .DataColCount = 5
      .DataRowCount = 10
      .Columns(1).Caption = "DragAlphaLevel"
      .Array.Value(0, 0) = .DragAlphaLevel
   End With
End Sub

Private Sub Command1_Click()
   Dim iAlphaLevel As Integer

   iAlphaLevel = SGGrid1.DragAlphaLevel
   iAlphaLevel = Val(InputBox( _
      "Please enter a new DragAlphaLevel. Number from 0 to 255.", _
      "DragAlphaLevel", iAlphaLevel))

   If iAlphaLevel >= 0 And iAlphaLevel <= 255 Then
      SGGrid1.Array.Value(0, 0) = iAlphaLevel
      SGGrid1.DragAlphaLevel = iAlphaLevel
   Else
      MsgBox "The DragAlphaLevel is number from 0 to 255.", vbInformation
   End If
End Sub

Back to topic


Editing Property

Editing Property
Returns or sets flag indicating whether the current cell is currently being edited.

Read/Write at run time. Not available at design time.

Syntax

object.Editing As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Editing property returns True if the grid is in a cell-edit mode. Changing this property from code, starts and stops cell-editing mode. Setting Editing property to False while cell-edit mode is active, transfers current row's content to the underlying data source.

If editing is disabled (the AllowEdit is False or the bound data source is read-only), the Editing property is always False and can not be changed to True.

Show Example
Copy Code [image] Show Me

The following code changes the editing mode after editing.

Private Sub SGGrid1_AfterEdit(ByVal RowKey As Long, ByVal ColIndex As Long)
   SGGrid1.Editing = False
End Sub

Back to topic


EditSelLength Property

EditSelLength Property
Returns or sets the number of characters selected in the cell editor.

Read/Write at run time. Not available at design time.

Syntax

object.EditSelLength As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Properties EditSelStart, EditSelLenght and EditSelStart work in conjunction.

Use these properties for tasks such as setting the insertion point, establishing an insertion range, selecting substrings in a control, or clearing text. Used in conjunction with the Clipboard object, these properties are useful for copy, cut and paste operations.

You can use these properties only while the grid is in cell-editing mode.

Show Example
Copy Code [image] Show Me

The following example searches the grid's array for a value beginning with the data you entered. If it finds such data, it fills current cell with it. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.AllowAddNew = True
   SGGrid1.EnterKeyBehavior = sgEnterKeyRows
End Sub

Private Sub SGGrid1_KeyUpEdit(ByVal rowKey As Long, _
   ByVal ColIndex As Long, _
   keyCode As Integer, shift As Integer)
   Dim sText$, i%
   Dim lDBIndex As Long, lDataRow As Long
   Dim ar As SGArray

   On Error Resume Next

   If (keyCode < vbKeyA Or keyCode > vbKeyZ) Then Exit Sub

   If IsEmpty(SGGrid1.Value) Then Exit Sub

   sText = SGGrid1.Value

   Set ar = SGGrid1.Array

   lDBIndex = SGGrid1.Columns.Current.DBIndex
   lDataRow = SGGrid1.Rows.Current.DataIndex

   For i = 0 To SGGrid1.DataRowCount - 1
      If lDataRow = i Then Exit For
      If StrComp((Left$(ar.Value(i, lDBIndex), Len(sText))), sText, vbTextCompare) = 0 Then
         SGGrid1.Value = ar.Value(i, lDBIndex)
         SGGrid1.EditSelStart = Len(sText)
         SGGrid1.EditSelLength = Len(ar.Value(i, lDBIndex)) - Len(sText)
         Exit For
      End If
   Next

   Set ar = Nothing

End Sub

Back to topic


EditSelStart Property

EditSelStart Property
Returns or sets the starting point of the text selected in the cell editor.

Read/Write at run time. Not available at design time.

Syntax

object.EditSelStart As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The EditSelStart property returns or sets the starting point of the selected text. If there is no selection, it returns position of the text insertion point.

Properties EditSelStart, EditSelLenght and EditSelStart work in conjunction.

Use these properties for tasks such as setting the insertion point, establishing an insertion range, selecting substrings in a control, or clearing text. Used in conjunction with the Clipboard object, these properties are useful for copy, cut and paste operations.

You can use these properties only while the grid is in cell-editing mode.

Show Example
Copy Code [image] Show Me

The following example searches the grid's array for a value beginning with the data you entered. If it finds such data, it fills current cell with it. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.AllowAddNew = True
   SGGrid1.EnterKeyBehavior = sgEnterKeyRows
End Sub

Private Sub SGGrid1_KeyUpEdit(ByVal rowKey As Long, _
   ByVal ColIndex As Long, _
   keyCode As Integer, shift As Integer)
   Dim sText$, i%
   Dim lDBIndex As Long, lDataRow As Long
   Dim ar As SGArray

   On Error Resume Next

   If (keyCode < vbKeyA Or keyCode > vbKeyZ) Then Exit Sub

   If IsEmpty(SGGrid1.Value) Then Exit Sub

   sText = SGGrid1.Value

   Set ar = SGGrid1.Array

   lDBIndex = SGGrid1.Columns.Current.DBIndex
   lDataRow = SGGrid1.Rows.Current.DataIndex

   For i = 0 To SGGrid1.DataRowCount - 1
      If lDataRow = i Then Exit For
      If StrComp((Left$(ar.Value(i, lDBIndex), Len(sText))), sText, vbTextCompare) = 0 Then
         SGGrid1.Value = ar.Value(i, lDBIndex)
         SGGrid1.EditSelStart = Len(sText)
         SGGrid1.EditSelLength = Len(ar.Value(i, lDBIndex)) - Len(sText)
         Exit For
      End If
   Next

   Set ar = Nothing

End Sub

Back to topic


EditSelText Property

EditSelText Property
Returns or sets currently selected text in the cell editor.

Read/Write at run time. Not available at design time.

Syntax

object.EditSelText As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The EditSelText returns or sets the string containing the currently selected text. It consists of a zero-length string if no characters are selected.

Properties EditSelStart, EditSelLenght and EditSelStart work in conjunction.

Use these properties for tasks such as setting the insertion point, establishing an insertion range, selecting substrings in a control, or clearing text. Used in conjunction with the Clipboard object, these properties are useful for copy, cut and paste operations.

You can use these properties only while the grid is in cell-editing mode.

Show Example
Copy Code [image] Show Me

The following example searches the grid's array for a value beginning with the data you entered. If it finds such data, it fills current cell with it. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.AllowAddNew = True
   SGGrid1.EnterKeyBehavior = sgEnterKeyRows
End Sub

Private Sub SGGrid1_KeyUpEdit(ByVal rowKey As Long, _
   ByVal ColIndex As Long, _
   keyCode As Integer, shift As Integer)
   Dim sText$, i%
   Dim lDBIndex As Long, lDataRow As Long
   Dim ar As SGArray

   On Error Resume Next

   If (keyCode < vbKeyA Or keyCode > vbKeyZ) Then Exit Sub

   If IsEmpty(SGGrid1.Value) Then Exit Sub

   sText = SGGrid1.Value

   Set ar = SGGrid1.Array

   lDBIndex = SGGrid1.Columns.Current.DBIndex
   lDataRow = SGGrid1.Rows.Current.DataIndex

   For i = 0 To SGGrid1.DataRowCount - 1
      If lDataRow = i Then Exit For
      If StrComp((Left$(ar.Value(i, lDBIndex), Len(sText))), sText, vbTextCompare) = 0 Then
         SGGrid1.Value = ar.Value(i, lDBIndex)
         SGGrid1.EditSelStart = Len(sText)
         SGGrid1.EditSelLength = Len(ar.Value(i, lDBIndex)) - Len(sText)
         Exit For
      End If
   Next

   Set ar = Nothing

End Sub

Back to topic


EditText Property

EditText Property
Returns or sets the text in the cell editor.

Read/Write at run time. Not available at design time.

Syntax

object.EditText As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The EditText property contains the text that user currently sees in the active cell editor. If there is no active cell editor or an active cell editor is a checkbox control, this property returns an empty string.


Ellipsis Property

Ellipsis Property
Truncates text that does not fit in the cell and adds ellipses (...).

Read/Write at run time and design time.

Syntax

object.Ellipsis As sgEllipsis

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The Ellipsis settings are:

Name | Value | Description
sgNoEllipsis | 0 | Do not draw ellipses. Text is clipped.
sgEllipsisEnd | 1 | Replace part at the end of the text with ellipses.
sgEllipsisPath | 2 | Replace part in the middle of the text with ellipses.

Remarks

The Ellipsis property is a shortcut to the Ellipsis member of the "Normal" style. This property has no effect if the WordWrap property is set to True.

Show Example
Copy Code [image] Show Me

The following example shows how the Ellipsis style works. To try the example, place BeeGrid on a form. Paste the code into the Declarations section ,press F5 and click the columns header.

Private Sub Form_Load()

   SGGrid1.Array.Value(0, 0) = _
      "F:\Documents and Settings\All Users\" & _
      "Application Data\Microsoft\" & _
      "Machine Debug Manager\mdm.ini"
   SGGrid1.Columns.At(1).Style.WordWrap = False
   SGGrid1.Columns.At(2).Caption = SGGrid1.Array.Value(0, 0)
End Sub

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   If SGGrid1.Ellipsis = sgEllipsisPath Then
      SGGrid1.Ellipsis = sgNoEllipsis
   Else
      SGGrid1.Ellipsis = SGGrid1.Ellipsis + 1
   End If

   SGGrid1.HeadingEllipsis = SGGrid1.Ellipsis
   SGGrid1.Columns(1).Caption = _
      Choose(SGGrid1.Ellipsis + 1, "No Ellipsis", _
      "Ellipsis End", "Ellipsis Path")
End Sub

Back to topic


Enabled Property

Enabled Property
Returns or sets a value that indicates whether a grid responds to user-generated events.

Read/Write at run time and design time.

Syntax

object.Enabled As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

If set to True, the grid control can receive focus and the user can manipulate it with the keyboard or mouse. If the Enabled is False, the user cannot manipulate control directly.

See Also

SGGrid


EnterKeyBehavior Property

EnterKeyBehavior Property
Returns or sets ENTER key behavior.

Read/Write at run time and design time.

Syntax

object.EnterKeyBehavior As sgEnterKeyBehavior

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The EnterKeyBehavior settings are:

Name | Value | Description
sgEnterKeyDefault | 0 | Default ENTER key behavior.
sgEnterKeyColumns | 1 | ENTER key jumps to next focusable column.
sgEnterKeyRows | 2 | ENTER key jumps to next focusable row.

Remarks

The EnterKeyBehavior property determines how grid will respond when the user presses the ENTER key. The grid can take one of these actions: pass a key to the container (default), move focus to the next column or move focus to the next row.

Use the NavigationWrapMode property to determine behavior of the enter key at row/col boundaries.

Show Example
Copy Code [image] Show Me

The following example moves focus to the first cell when the user presses the enter key in the last cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
End Sub

Private Sub SGGrid1_KeyUp(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyReturn Then
      If SGGrid1.Col = SGGrid1.ColCount - 1 And _
         SGGrid1.Row = SGGrid1.RowCount - 1 Then
         SGGrid1.Col = 1
         SGGrid1.Row = 1
      End If
   End If
End Sub

Back to topic


EOF Property

EOF Property
Returns true if the current record position is after the last record.

Read-only at run time. Not available at design time.

Syntax

object.EOF As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The EOF property returns True if the current record position is after the last row and False if the current record position is on or before the last record.

You can use this property in all data modes.

Show Example
Copy Code [image] Show Me

Private Sub CheckButtons()

   cmdMoveFirst.Enabled = Not SGGrid1.BOF
   cmdMovePrevious.Enabled = Not SGGrid1.BOF
   cmdMoveNext.Enabled = Not SGGrid1.EOF
   cmdMoveLast.Enabled = Not SGGrid1.EOF

End Sub

Back to topic


EqualColWidth Property

EqualColWidth Property
Returns or sets whether all columns have same width.

Read/Write at run time and design time.

Syntax

object.EqualColWidth As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The EqualColWidth property indicates whether all columns should have same width.


EqualRowHeight Property

EqualRowHeight Property
Returns or sets whether all rows have same height.

Read/Write at run time and design time.

Syntax

object.EqualRowHeight As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The EqualRowHeight property indicates whether all rows should have same height.


ErrorText Property

ErrorText Property
Returns the error message string.

Read-only at run time. Not available at design time.

Syntax

object.ErrorText As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The ErrorText property contains description of the last error. It is only valid within Error event handler.

Show Example
Copy Code [image] Show Me

The following code displays an error message in the grid's caption instead of in a message box.

Private Sub SGGrid1_Error(ByVal errorCode As Long, _
   showMessage As Boolean)
   SGGrid1.Caption = SGGrid1.ErrorText
   showMessage = False
End Sub

Back to topic


EvenOddStyle Property

EvenOddStyle Property
Enables or disables even/odd formatting.

Read/Write at run time and design time.

Syntax

object.EvenOddStyle As sgEvenOddStyle

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The EvenOddStyle settings are:

Name | Value | Description
sgNoEvenOdd | 0 | Do not alternate colors.
sgEvenOddRows | 1 | Apply alternate colors for rows only.
sgEvenOddCols | 2 | Apply alternate colors for columns only.
sgEvenOddBoth | 3 | Apply alternate colors for both rows and columns.

Remarks

The BeeGrid can alternate background colors for its rows and/or columns. The EvenOddStyle property controls how is this alternating applied.

Use the ColorOdd and the ColorEven properties to set odd/even colors. If you apply odd/even style then the property CellBackColor has no effect.

This property has no effect if the CellBkgStyle property set to sgCellBkgNone.

Show Example
Copy Code [image] Show Me

The following example creates the black-white grid and fills grid with the sample data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim row As SGRow, cell As SGCell

   With SGGrid1
      .RedrawEnabled = False
      'create cols and rows
      .DataColCount = 10
      .DataRowCount = 10
      .EqualColWidth = True
      .EqualRowHeight = True
      .GroupByBoxVisible = False
      'apply oddeven style
      .EvenOddStyle = sgEvenOddBoth
      .ColorEven = vbBlack
      .ColorOdd = vbWhite
      .Styles("CurrentCell").ForeColor = vbRed
   End With
   'add sample text and change cells forecolor
   For Each row In SGGrid1.Rows
      For Each cell In row.Cells
         'check out if the cell is heading
         If Not (cell.Column.Heading Or row.Heading) Then
            cell.Value = "Row: " & Trim(row.Position) _
               & " Col: " & Trim(cell.Column.Position)
            'change fore color for black cells
            If row.Position Mod 2 Xor cell.Column.Position Mod 2 Then
               cell.Style.ForeColor = vbWhite
            End If
         End If
      Next
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


FitLastColumn Property

FitLastColumn Property
Returns or sets flag indicating whether the last column should be adjusted to fit the control's width.

Read/Write at run time and design time.

Syntax

object.FitLastColumn As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

If set to True, the last grid's column will be resized to fill the empty space between cells and the grid's right border. Setting the FitLastColumn property to True does not change column's original width.

See Also

SGGrid


FlatScrollBars Property

FlatScrollBars Property
Enables or disables flat scroll bars.

Read/Write at run time and design time.

Syntax

object.FlatScrollBars As sgScrollBarMode

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The FlatScrollBars settings are:

Name | Value | Description
sgSBRegularMode | 0 | Show standard (3D) scrollbars.
sgSBEncartaMode | 1 | Show flat scrollbars.
sgSBFlatMode | 2 | Show flat scrollbars.

Remarks

The FlatScrollBars is a mouse-sensitive version of the standard Windows scroll bar that offers two-dimensional formatting options. It can also replace the standard Windows three-dimensional scroll bar. The FlatScrollBar provides increased interactivity when using the scroll arrows and the scroll box.

A two-dimensional appearance that duplicates the look of the scroll bar found in Internet Explorer 4.0. The scroll arrows and the scroll bar thumb are mouse sensitive; they change color in response to the mouse pointer passing over them.

A two-dimensional appearance that becomes three-dimensional in response to the mouse pointer. The scroll arrows and thumb are beveled when the pointer passes over them. This reproduces the look of the scrollbar seen in Microsoft Encarta Encyclopedia.

See Also

SGGrid


FocusRect Property

FocusRect Property
Returns or sets focus rectangle type.

Read/Write at run time and design time.

Syntax

object.FocusRect As sgFocusRect

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The FocusRect settings are:

Name | Value | Description
sgFocusRectNone | 0 | Do not draw focus rectangle.
sgFocusRectDotted | 1 | Draw dotted focus rectangle.
sgFocusRectSolid | 2 | Draw solid focus rectangle.
sgFocusRectOwnerDraw | 3 | Custom drawn focus rectangle.

Remarks

If you set this property to sgFocusRectOwnerDraw you should implement the IsgGridCustomDraw interface.

Show Example
Copy Code [image] Show Me

The following example uses the PaintObject to draw the focus rect in four different colors. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Implements IsgGridCustomDraw

Private Type POINTAPI
   x As Long
   y As Long
End Type

Private Declare Function CreatePen Lib "gdi32" _
   (ByVal nPenStyle As Long, ByVal nWidth As Long, _
   ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" _
   (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
   (ByVal hObject As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" _
   (ByVal hdc As Long, ByVal x As Long, _
   ByVal y As Long, lpPoint As POINTAPI) As Long
Private Declare Function LineTo Lib "gdi32" _
   (ByVal hdc As Long, ByVal x As Long, _
   ByVal y As Long) As Long

Private Sub SGGrid1_OnInit()
   Set SGGrid1.PaintObject = Me
   SGGrid1.CustomBkgDraw = sgDrawAfterFocusRect
   SGGrid1.FocusRect = sgFocusRectOwnerDraw
End Sub

Private Sub IsgGridCustomDraw_DrawCell( _
   DrawInfo As sgGridCustomDraw, _
   Response As sgCustomDrawResponse)
End Sub

Private Sub IsgGridCustomDraw_DrawGridBkg _
   (DrawInfo As sgGridCustomDraw, _
   Response As sgCustomDrawResponse)

   If DrawInfo.DrawStage = sgDrawAfterFocusRect Then
      Dim pt As POINTAPI

      MoveToEx DrawInfo.DC, DrawInfo.left, DrawInfo.top, pt

      DrawLine DrawInfo.DC, vbRed, DrawInfo.right, DrawInfo.top
      DrawLine DrawInfo.DC, vbBlue, DrawInfo.right, DrawInfo.bottom
      DrawLine DrawInfo.DC, vbGreen, DrawInfo.left, DrawInfo.bottom
      DrawLine DrawInfo.DC, vbYellow, DrawInfo.left, DrawInfo.top
   End If
End Sub

Private Sub DrawLine(hdc As Long, clr As Long, x As Long, y As Long)
   Dim hPen As Long
   Dim hOldPen As Long
   ' Create pen
   hPen = CreatePen(0, 1, clr)
   hOldPen = SelectObject(hdc, hPen)
   LineTo hdc, x, y
   ' Release pen
   SelectObject hdc, hOldPen
   DeleteObject hPen
End Sub

Back to topic


FocusRectColor Property

FocusRectColor Property
Returns or sets focus rectangle color.

Read/Write at run time and design time.

Syntax

object.FocusRectColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The FocusRectColor property determines the color used for drawing solid focus rectangle. It has effect only if the FocusRect property is set to sgFocusRectSolid.

Show Example
Copy Code [image] Show Me

The following example shows how the focus rect property works. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   SGGrid1.FocusRect = sgFocusRectSolid
   SGGrid1.FocusRectColor = vbRed
   SGGrid1.FocusRectLineWidth = 2
End Sub

Back to topic


FocusRectLineWidth Property

FocusRectLineWidth Property
Returns or sets focus rectangle line width. In pixels.

Read/Write at run time and design time.

Syntax

object.FocusRectLineWidth As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The FocusRectLineWidth property represents the width (in pixels) of the line used to draw focus rectangle. It has effect if the FocusRect property is set to sgFocusRectSolid. In addition, if running on Windows NT or Windows 2000, it has effect for other FocusRect settings.

Show Example
Copy Code [image] Show Me

The following example shows how the focus rect property works. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   SGGrid1.FocusRect = sgFocusRectSolid
   SGGrid1.FocusRectColor = vbRed
   SGGrid1.FocusRectLineWidth = 2
End Sub

Back to topic


Font Property

Font Property
Returns or sets font used in standard cells.

Read/Write at run time and design time.

Syntax

object.Font As IFontDisp

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property is a shortcut to the Font object of the "Normal" style.

Show Example
Copy Code [image] Show Me

The following example shows how to use the font object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section ,press F5

Private Sub Form_Load()
   Dim fnt As StdFont

   SGGrid1.Columns(1).Caption = "The caption"
   SGGrid1.Array.Value(0, 0) = "Sample Text"

   Set fnt = SGGrid1.Font

   fnt.Name = "Times New Roman"
   fnt.Bold = True
   fnt.Underline = True

   Set SGGrid1.Styles("CurrentCell").Font = fnt
   Set SGGrid1.Styles("Heading").Font = fnt
   Set fnt = Nothing
End Sub

Back to topic


Format Property

Format Property
Specifies the format for displaying numbers, dates, times and text.

Read/Write at run time and design time.

Syntax

object.Format As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Format property contains data formatting string. The Format string is used to format cell's data. See the Visual Basic Format function for information about valid format strings.

Note: BeeGrid formatting uses Visual Basic formatting capabilities. If container does not provide this functionality, cell's data will not be formatted. In such cases you can set the Format property to "FormatText Event" and grid will fire the FormatText event when cell's data needs formatting.

Show Example
Copy Code [image] Show Me

The following example fills the grid with sample data and with some of standard formats. The code in the RowColChange event changes the grid's format. To try the example, place BeeGrid on a form. Paste the code into the Declarations section ,press F5

Private Sub Form_Load()
   Dim ar As SGArray
   Dim i As Long

   SGGrid1.DataRowCount = 10
   SGGrid1.DataColCount = 2
   SGGrid1.FitLastColumn = True

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 1) = i * Rnd * 1000000
   Next

   ar.Value(0, 0) = "General"
   ar.Value(1, 0) = "Standard"
   ar.Value(2, 0) = "Currency"
   ar.Value(3, 0) = "Percent"
   ar.Value(4, 0) = "#0.00"
   ar.Value(5, 0) = "#,###0.00"
   ar.Value(6, 0) = "Short Date"
   ar.Value(7, 0) = "Long Date"
   ar.Value(8, 0) = "Short Time"
   ar.Value(9, 0) = "Long Time"

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_RowColChange(ByVal lastRowKey As Long, ByVal lastColIndex As Long)
   SGGrid1.Format = SGGrid1.Array(SGGrid1.Rows.Current.DataIndex, 0)
End Sub

Back to topic


FrozenColCount Property

FrozenColCount Property
Returns the number of frozen columns.

Read-only at run time. Not available at design time.

Syntax

object.FrozenColCount As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The FrozenColCount property returns number of frozen columns. A frozen column appears as a leftmost visible column and can not be scrolled out of the view.

To "freeze" a column, set it's Frozen property to True.

Show Example
Copy Code [image] Show Me

The following example fills the grid with test data, freezes the first row and col and applies the heading style to them. Press the command button to freeze additional rows and cols. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   If SGGrid1.FrozenColCount > 3 Then
      SGGrid1.Columns.At(SGGrid1.FrozenColCount).Frozen = False
      SGGrid1.Rows.At(SGGrid1.FrozenRowCount).Frozen = False
   Else
      SGGrid1.Columns.At(SGGrid1.FrozenColCount + 1).Frozen = True
      SGGrid1.Rows.At(SGGrid1.FrozenRowCount + 1).Frozen = True
   End If
End Sub

Private Sub Form_Load()
   Dim ar As SGArray
   Dim i&, j&

   'assign grid array to variable
   Set ar = SGGrid1.Array

   SGGrid1.RowNumbering = True

   SGGrid1.DataColCount = 20
   SGGrid1.DataRowCount = 100
   'load test data
   For i = 0 To SGGrid1.DataColCount - 1
      SGGrid1.Columns.At(i).Caption = "Col " & Trim(i)
      For j = 0 To SGGrid1.DataRowCount - 1
         ar.Value(j, i) = "Row=" & j & " Col=" & i
      Next
   Next

   'make two first cols and rows frozen and
   'apply the Heading to them
   SGGrid1.GridLines = SGGrid1.HeadingGridLines
   SGGrid1.Styles("Frozen").CopyFrom SGGrid1.Styles("Heading")

   SGGrid1.Columns.At(1).Frozen = True
   SGGrid1.Rows.At(1).Frozen = True

   Set ar = Nothing
End Sub

Back to topic


FrozenRowCount Property

FrozenRowCount Property
Returns the number of frozen rows.

Read-only at run time. Not available at design time.

Syntax

object.FrozenRowCount As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The FrozenRowCount property returns number of frozen rows. A frozen row appears as a first visible row under the heading row and can not be scrolled out of the view.

To "freeze" a row, set its Frozen property to True.

Show Example
Copy Code [image] Show Me

The following example fills the grid with test data, freezes the first row and col and applies the heading style to them. Press the command button to freeze additional rows and cols. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   If SGGrid1.FrozenColCount > 3 Then
      SGGrid1.Columns.At(SGGrid1.FrozenColCount).Frozen = False
      SGGrid1.Rows.At(SGGrid1.FrozenRowCount).Frozen = False
   Else
      SGGrid1.Columns.At(SGGrid1.FrozenColCount + 1).Frozen = True
      SGGrid1.Rows.At(SGGrid1.FrozenRowCount + 1).Frozen = True
   End If
End Sub

Private Sub Form_Load()
   Dim ar As SGArray
   Dim i&, j&

   'assign grid array to variable
   Set ar = SGGrid1.Array

   SGGrid1.RowNumbering = True

   SGGrid1.DataColCount = 20
   SGGrid1.DataRowCount = 100
   'load test data
   For i = 0 To SGGrid1.DataColCount - 1
      SGGrid1.Columns.At(i).Caption = "Col " & Trim(i)
      For j = 0 To SGGrid1.DataRowCount - 1
         ar.Value(j, i) = "Row=" & j & " Col=" & i
      Next
   Next

   'make two first cols and rows frozen and
   'apply the Heading to them
   SGGrid1.GridLines = SGGrid1.HeadingGridLines
   SGGrid1.Styles("Frozen").CopyFrom SGGrid1.Styles("Heading")

   SGGrid1.Columns.At(1).Frozen = True
   SGGrid1.Rows.At(1).Frozen = True

   Set ar = Nothing
End Sub

Back to topic


GridBorderStyle Property

GridBorderStyle Property
Returns or sets the grid border style.

Read/Write at run time and design time.

Syntax

object.GridBorderStyle As sgGridBorderStyle

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The GridBorderStyle settings are:

Name | Value | Description
sgNone | 0 | No border.
sgFixed | 1 | Fixed border.

Remarks

Returns or sets the border style for the grid. The default value is sgFixed.


GridLines Property

GridLines Property
Returns or sets grid line style.

Read/Write at run time and design time.

Syntax

object.GridLines As sgGridLineStyle

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The GridLines settings are:

Name | Value | Description
sgGridLineNone | 0 | Do not draw grid lines.
sgGridLineFlat | 1 | Draw flat grid lines.
sgGridLineInset | 2 | Inset.
sgGridLineRaised | 3 | Raised.
sgGridLineFlatHorz | 4 | Draw only horizontal flat grid lines.
sgGridLineInsetHorz | 5 | Draw only horizontal inset grid lines.
sgGridLineRaisedHorz | 6 | Draw only horizontal raised grid lines.
sgGridLineFlatVert | 7 | Draw only vertical flat grid lines.
sgGridLineInsetVert | 8 | Draw only vertical inset grid lines.
sgGridLineRaisedVert | 9 | Draw only vertical raised grid lines.

Remarks

The GridLines, GridLinesColor and CellBackColor properties determine the appearance of the lines between the grid cells. The GridLinesColor has no effect unless the GridLines is set to sgGridLineFlat, sgGridLineFlatHorz or sgGridLineFlatVert.

Show Example
Copy Code [image] Show Me

The following example shows how to implement 3D effect into the grid's cells.

Private Sub Form_Load()

   SGGrid1.CellBackColor = vbButtonFace
   SGGrid1.GridLines = sgGridLineInset

End Sub

Back to topic


GridLinesColor Property

GridLinesColor Property
Returns or sets color for flat grid lines.

Read/Write at run time and design time.

Syntax

object.GridLinesColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The GridLines, GridLinesColor and CellBackColor properties determine the appearance of the lines between the grid cells. The GridLinesColor has effect only if the GridLines is set to sgGridLineFlat, sgGridLineFlatHorz or sgGridLineFlatVert.


GroupByBoxText Property

GroupByBoxText Property
Returns or sets the text dispalyed in the group-by box.

Read/Write at run time and design time.

Syntax

object.GroupByBoxText As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates how to customize the GroupByBox's appearance. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1.Styles("GroupByBox")
      .BackColor = vbYellow
      .BorderColor = vbRed
      .BorderSize = 30
      .BorderStyle = sgCellBorderSolid
      .Font.Size = 15
      .Font.Bold = True
      .ForeColor = vbBlack
   End With

   With SGGrid1
      'by default it's true
      .GroupByBoxVisible = True
      .GroupByBoxText = "This is GroupByBoxText"
      .RedrawEnabled = True
   End With
End Sub

Back to topic


GroupByBoxVisible Property

GroupByBoxVisible Property
Returns or sets a value indicating whether group-by box is visible.

Read/Write at run time and design time.

Syntax

object.GroupByBoxVisible As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates how to customize the GroupByBox's appearance. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1.Styles("GroupByBox")
      .BackColor = vbYellow
      .BorderColor = vbRed
      .BorderSize = 30
      .BorderStyle = sgCellBorderSolid
      .Font.Size = 15
      .Font.Bold = True
      .ForeColor = vbBlack
   End With

   With SGGrid1
      'by default it's true
      .GroupByBoxVisible = True
      .GroupByBoxText = "This is GroupByBoxText"
      .RedrawEnabled = True
   End With
End Sub

Back to topic


GroupHeadings Property

GroupHeadings Property
Returns the collection of group heading objects.

Read-only at run time. Not available at design time.

Syntax

object.GroupHeadings As IsgGroupHeadings

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The GroupHeadings property returns a collection of SGGroupHeading objects. Each object in this collection represents one first level group-heading row. You can use collection returned from the GroupHeadings property to enumerate all first level groups.

For more information, see the SGGroupHeadings topic.

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers, groups odd and even numbers. It uses the GroupHeadings property to create the group header caption. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then
      Text = "There are " & _
         SGGrid1.GroupHeadings(1).ChildRows.Count & " even numbers"
   Else
      Text = "There are " & _
         SGGrid1.GroupHeadings(2).ChildRows.Count & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupIndentation = 0
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 20

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrFireFetchText

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic


GroupIndentation Property

GroupIndentation Property
Returns or sets grid's hierarchy indentation size.

Read/Write at run time and design time.

Syntax

object.GroupIndentation As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Returns or sets the width of the single group indentation. It is expressed in the container's coordinate system.

This property has effect only if the grid is grouped.

Show Example
Copy Code [image] Show Me

The following example adds random numbers to the grid and groups odd/even ones. The group is drawn without indentation and lines. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupIndentation = 0

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .Style.TextAlignment = sgAlignRightCenter
      .Style.Format = "Standard"
   End With

   SGGrid1.DataRowCount = 20

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
    sgSortTypeNumber, False, True

   Set ar = Nothing
End Sub

Back to topic


Groups Property

Groups Property
Returns the collection of the grid groups.

Read-only at run time. Not available at design time.

Syntax

object.Groups As IsgGroups

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Groups property returns a collection of the SGGroup objects. Each SGGroup object represents rules and definitions used to group rows. Use methods and properties of the SGGroups collection to add, remove and modify groupings.

For more information, see the SGGroups topic.

Show Example
Copy Code [image] Show Me

The following example groups all files from the windows directory. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim sFile As String
   Dim sgCol As SGColumn
   Dim SGGroup As SGGroup
   Dim sWinDir As String
   Dim dtFileDate As Date
   Dim i As Integer
   'change default groups style
   With SGGrid1
      .Styles("Heading").BackColor = RGB(165, 142, 107)
      .Styles("Selection").BackColor = RGB(181, 154, 115)
      .Styles("InactiveSelection").BackColor = RGB(132, 190, 173)
      .Styles("GroupHeader").BackColor = RGB(231, 203, 123)
      .BackColor = RGB(214, 207, 189)
      .SpecialMode = sgModeListBox
   End With
   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   'ColumnClickSort needs CacheAllRecords
   SGGrid1.CacheAllRecords = True
   SGGrid1.ColumnClickSort = True
   SGGrid1.GroupByBoxVisible = False
   'Column creations
   Set sgCol = SGGrid1.Columns.Add("File")
   sgCol.Caption = "File name"
   sgCol.Width = 2200
   Set sgCol = SGGrid1.Columns.Add("FileDate")
   sgCol.Caption = "File date"
   sgCol.Width = 2200
   sgCol.DataType = sgtDateTime
   sgCol.SortType = sgSortTypeDateTime
   Set sgCol = SGGrid1.Columns.Add("Size")
   sgCol.Caption = "Size"
   sgCol.DataType = sgtLong

   Set sgCol = SGGrid1.Columns.Add("FileYear")
   sgCol.Hidden = True
   sgCol.Caption = "File year"
   Set sgCol = SGGrid1.Columns.Add("FileMonth")
   sgCol.Hidden = True
   sgCol.Caption = "File month"

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.*", vbNormal)
   'add files to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      dtFileDate = FormatDateTime(FileDateTime(sWinDir & sFile), vbShortDate)
      SGGrid1.Rows.At(i).Cells(1).Value = dtFileDate
      SGGrid1.Rows.At(i).Cells(2).Value = FileLen(sWinDir & sFile)
      SGGrid1.Rows.At(i).Cells(3).Value = Year(dtFileDate)
      SGGrid1.Rows.At(i).Cells(4).Value = Month(dtFileDate)
      sFile = Dir
   Loop
   'group grid by year and month
   Set SGGroup = SGGrid1.Groups.Add("FileYear", sgSortAscending, _
      sgSortTypeNumber, True, False)
   Call SGGrid1.Groups.Add("FileMonth", sgSortAscending, _
      sgSortTypeNumber, False, False)
   'show formula result in header and footer
   SGGroup.HeaderTextSource = sgGrpHdrFormula
   SGGroup.FooterTextSource = sgGrpFooterFormula
   'create calculations for header and footer
   SGGroup.Calculations.Add sgCalcSum, "Size"
   SGGroup.Calculations.Add sgCalcAverage, "Size"
   'create formula
   SGGroup.HeaderFormula = "'Total size for ' & GroupingValue & ' is ' & Format((GroupCalc(1) / 1024),'Standard') & ' KB (' & TotalChildCount & ' files)'"
   SGGroup.FooterFormula = "'The average file size for ' & GroupingValue & ' is ' & Format((GroupCalc(2) / 1024),'Standard') & ' KB'"

   Set SGGroup = Nothing
   'the argument doRefresh in the Groups.Add method is false so
   'grouping need refresh
   SGGrid1.RefreshGroups
   'redrow grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


HScrollHeight Property

HScrollHeight Property
Returns or sets height of the horizontal scroll bar.

Read/Write at run time and design time.

Syntax

object.HScrollHeight As OLE_YSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Setting HScrollHeight property to zero, indicates that grid should use windows default height. Height is expressed in the container's coordinate system.

The default value for this property is zero.

Show Example
Copy Code [image] Show Me

The following example makes the grid look like the ListBox. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim i As Integer
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False

   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0

   SGGrid1.Move 0, 0, 1515, 3000
   SGGrid1.Appearance = sgFlat
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.BackColor = SGGrid1.CellBackColor
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.AllowEdit = False
   'fill grid with test data
   SGGrid1.DataColCount = 1
   SGGrid1.DataRowCount = 100

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 0) = "Item nr. " & Trim(i)
   Next
   'set scroll bar properties
   SGGrid1.ScrollBarTrack = True
   SGGrid1.ScrollBarTips = sgScrollTipsVertical
   SGGrid1.ScrollTipColumn = SGGrid1.Columns(1).Key
   SGGrid1.VScrollWidth = SGGrid1.ClientWidth / 8
   SGGrid1.ScrollBars = sgSBVertical

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True

End Sub

Back to topic


HeadingBackColor Property

HeadingBackColor Property
Returns or sets background color for header rows and columns.

Read/Write at run time and design time.

Syntax

object.HeadingBackColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The CellBackColor property is a shortcut to the BackColor member of the "Heading" style.
The following lines have the same effect:

SGGrid1.HeadingBackColor = vbRed

- or -

SGGrid1.Styles("Heading").BackColor = vbRed
SGGrid1.Redraw

This property has no effect if the BkgStyle property of the "Heading" style is set to sgCellBkgNone.


HeadingColCount Property

HeadingColCount Property
Returns or sets the total number of heading columns.

Read/Write at run time and design time.

Syntax

object.HeadingColCount As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The HeadingColCount property shows/hides the heading column. In this version, grid cannot have more than one heading column.

Setting the HeadingColCount to 0 or any negative value, hides the heading column. Setting the HeadingColCount to 1 or any positive value, shows one heading column.


HeadingEllipsis Property

HeadingEllipsis Property
Truncates text that does not fit in the cell and adds ellipses (...).

Read/Write at run time and design time.

Syntax

object.HeadingEllipsis As sgEllipsis

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The HeadingEllipsis property settings are:

Name | Value | Description
sgNoEllipsis | 0 | Do not draw ellipses. Text is clipped.
sgEllipsisEnd | 1 | Replace part at the end of the text with ellipses.
sgEllipsisPath | 2 | Replace part in the middle of the text with ellipses.

Remarks

The Ellipsis property is a shortcut to the Ellipsis member of the "Heading" style.

This property has effect only if the WordWrap property of the "Heading" style set to False.

Show Example
Copy Code [image] Show Me

The following example shows how the Ellipsis style works. To try the example, place BeeGrid on a form. Paste the code into the Declarations section ,press F5 and click the columns header.

Private Sub Form_Load()

   SGGrid1.Array.Value(0, 0) = _
      "F:\Documents and Settings\All Users\" & _
      "Application Data\Microsoft\" & _
      "Machine Debug Manager\mdm.ini"
   SGGrid1.Columns.At(1).Style.WordWrap = False
   SGGrid1.Columns.At(2).Caption = SGGrid1.Array.Value(0, 0)
End Sub

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   If SGGrid1.Ellipsis = sgEllipsisPath Then
      SGGrid1.Ellipsis = sgNoEllipsis
   Else
      SGGrid1.Ellipsis = SGGrid1.Ellipsis + 1
   End If

   SGGrid1.HeadingEllipsis = SGGrid1.Ellipsis
   SGGrid1.Columns(1).Caption = _
      Choose(SGGrid1.Ellipsis + 1, "No Ellipsis", _
      "Ellipsis End", "Ellipsis Path")
End Sub

Back to topic


HeadingFont Property

HeadingFont Property
Returns or sets font for header rows and columns.

Read/Write at run time and design time.

Syntax

object.HeadingFont As IFontDisp

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property is a shortcut to the Font object of the "Heading" style.

Show Example
Copy Code [image] Show Me

The following example shows how to use the font object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section ,press F5

Private Sub Form_Load()
   Dim fnt As StdFont

   SGGrid1.Columns(1).Caption = "The caption"
   SGGrid1.Array.Value(0, 0) = "Sample Text"

   Set fnt = SGGrid1.Font

   fnt.Name = "Times New Roman"
   fnt.Bold = True
   fnt.Underline = True

   Set SGGrid1.Styles("CurrentCell").Font = fnt
   Set SGGrid1.Styles("Heading").Font = fnt
   Set fnt = Nothing
End Sub

Back to topic


HeadingForeColor Property

HeadingForeColor Property
Returns or sets foreground color for header rows and columns.

Read/Write at run time and design time.

Syntax

object.HeadingForeColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The HeadingForeColor property is a shortcut to the ForeColor member of the "Heading" style.
The following lines have the same effect:

SGGrid1.HeadingForeColor = vbRed

- or -

SGGrid1.Styles("Heading").ForeColor = vbRed
SGGrid1.Redraw


HeadingGridLines Property

HeadingGridLines Property
Returns or sets grid line style for header rows and columns.

Read/Write at run time and design time.

Syntax

object.HeadingGridLines As sgGridLineStyle

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The HeadingGridLines property settings are:

Name | Value | Description
sgGridLineNone | 0 | Do not draw grid lines.
sgGridLineFlat | 1 | Draw flat grid lines.
sgGridLineInset | 2 | Inset.
sgGridLineRaised | 3 | Raised.
sgGridLineFlatHorz | 4 | Draw only horizontal flat grid lines.
sgGridLineInsetHorz | 5 | Draw only horizontal inset grid lines.
sgGridLineRaisedHorz | 6 | Draw only horizontal raised grid lines.
sgGridLineFlatVert | 7 | Draw only vertical flat grid lines.
sgGridLineInsetVert | 8 | Draw only vertical inset grid lines.
sgGridLineRaisedVert | 9 | Draw only vertical raised grid lines.

Remarks

The HeadingGridLines, the HeadingGridLinesColor and the HeadingBackColor properties determine the appearance of the lines between the heading cells. The HeadingGridLinesColor has effect only if the HeadingGridLines is set to sgGridLineFlat, sgGridLineFlatHorz or sgGridLineFlatVert.

Show Example
Copy Code [image] Show Me

The following example draws dark blue header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   SGGrid1.HeadingBackColor = RGB(0, 0, 128)
   SGGrid1.HeadingForeColor = vbWhite
   SGGrid1.HeadingFont.Bold = True
   SGGrid1.HeadingGridLines = sgGridLineFlat
   SGGrid1.HeadingGridLinesColor = vbWhite
End Sub

Back to topic


HeadingGridLinesColor Property

HeadingGridLinesColor Property
Returns or sets color for flat grid lines of header rows and columns.

Read/Write at run time and design time.

Syntax

object.HeadingGridLinesColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The HeadingGridLines, the HeadingGridLinesColor and the HeadingBackColor properties determine the appearance of the lines between the heading cells. The HeadingGridLinesColor has effect only if the HeadingGridLines is set to sgGridLineFlat, sgGridLineFlatHorz or sgGridLineFlatVert.

Show Example
Copy Code [image] Show Me

The following example draws dark blue header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   SGGrid1.HeadingBackColor = RGB(0, 0, 128)
   SGGrid1.HeadingForeColor = vbWhite
   SGGrid1.HeadingFont.Bold = True
   SGGrid1.HeadingGridLines = sgGridLineFlat
   SGGrid1.HeadingGridLinesColor = vbWhite
End Sub

Back to topic


HeadingRowCount Property

HeadingRowCount Property
Returns or sets the total number of heading rows.

Read/Write at run time and design time.

Syntax

object.HeadingRowCount As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The HeadingRowCount property shows/hides the heading row. In this version, grid cannot have more than one heading row.

Setting the HeadingRowCount to 0 or any negative value, hides the heading row. Setting the HeadingRowCount to 1 or any positive value, shows one heading row.


HeadingTextAlignment Property

HeadingTextAlignment Property
Returns or sets text alignment style for header rows and columns.

Read/Write at run time and design time.

Syntax

object.HeadingTextAlignment As sgAlignment

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The HeadingTextAlignment property settings are:

Name | Value | Description
sgAlignGeneral | 0 | Alignment is based on the underlying data type.
sgAlignLeftTop | 1 | Align to the left-top position.
sgAlignCenterTop | 2 | Align to the center-top position.
sgAlignRightTop | 3 | Align to the right-top position.
sgAlignLeftCenter | 4 | Align to the left-center position.
sgAlignCenterCenter | 5 | Align to the center-center position.
sgAlignRightCenter | 6 | Align to the right-center position.
sgAlignLeftBottom | 7 | Align to the left-bottom position.
sgAlignCenterBottom | 8 | Align to the center-bottom position.
sgAlignRightBottom | 9 | Align to the right-bottom position.

Remarks

This property is a shortcut to the TextAlignment member of the "Heading" style.
The following lines have the same effect:

SGGrid1.HeadingTextAlignment = sgAlignCenterCenter

- or -

SGGrid1.Styles("Heading").TextAlignment = sgAlignCenterCenter
SGGrid1.Redraw

If the property WordWrap is set to true then the vertical alignment is always top. For example, values sgAlignLeftTop, sgAlignLeftCenter and sgAlignLeftBottom have same effect (as sgAlignLeftTop).

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the TextAlignment property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.HeadingTextAlignment = sgAlignCenterCenter
   SGGrid1.TextAlignment = sgAlignRightTop

   SGGrid1.CurrentCell.Column.Caption = "Caption"
   SGGrid1.CurrentCell.Value = "Text"

End Sub

Back to topic


HeadingWordWrap Property

HeadingWordWrap Property
Enables or disables word wrapping for header rows and columns.

Read/Write at run time and design time.

Syntax

object.HeadingWordWrap As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property is a shortcut to the WordWrap object of the "Heading" style.

Show Example
Copy Code [image] Show Me

The following example sets the WordWrap property to the grid and heading. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   SGGrid1.WordWrap = True
   SGGrid1.HeadingWordWrap = True

   SGGrid1.Columns.At(1).Caption = "The little red caption"

   SGGrid1.Rows.At(0).Height = 505
   SGGrid1.Rows.At(1).Height = 505

   SGGrid1.Array.Value(0, 0) = "This is long dong text."
End Sub

Back to topic


hWnd Property

hWnd Property

Read-only at run time. Not available at design time.

Syntax

object.hWnd As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The hWnd property is used with Windows API calls. Because the value of this property can change while a program is running, never store the window handle in a variable.

See Also

Window


Images Property

Images Property
Sets a user defined image list handle.
Write only at run time. Syntax

object.Images As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

When you assign a handle of the image list to the Images property, the BeeGrid control creates a copy of the specified image list. Later on, when drawing pictures inside grid cells, grid can use images from that image list. All properties, methods and events that accept pictures as parameters can also accept image list's one-based index.
The following is a list of those properties, methods and events:

  • The ValueItems Add method
  • A Column's HeadingPicture property
  • A Group's PictureExpanded property
  • A Group's PictureCollapsed property
  • The Picture argument in the FetchCellTip event
  • The Picture argument in the FetchScrollTip event
  • The PictureExpanded and the PictureCollapsed arguments in the FetchGroupHeaderData event

In addition, the BeeGrid control contains one internal image list. To specify image from the internal image list, use values between these predefined constants:

Name | Value | Description
sgbipFirst | 32768 | Index of the first built-in picture.
sgbipLast | 33023 | Index of the last built-in picture.

Show Example
Copy Code [image] Show Me

The following example uses the system image list to display pictures in the grid's heading. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Type SHFILEINFO
    hIcon As Long
    iIcon As Long
    dwAttributes As Long
    szDisplayName As String * 260
    szTypeName As String * 80
End Type

Private Declare Function SHGetFileInfo Lib "shell32" Alias "SHGetFileInfoA" _
                              (ByVal pszPath As Long, _
                              ByVal dwFileAttributes As Long, _
                              psfi As SHFILEINFO, _
                              ByVal cbFileInfo As Long, _
                              ByVal uFlags As Long) As Long

Private Sub Form_Load()
   Dim arPath() As Byte
   Dim lPath As Long
   Dim sfi As SHFILEINFO
   Dim i As Integer
   Const SHGFI_ICON = &H100
   Const SHGFI_SYSICONINDEX = &H4000
   Const SHGFI_SMALLICON = &H1

   'Any valid file system path can be used to retrieve system image list handles.
   arPath = StrConv("C:\" & vbNullChar, vbFromUnicode)
   lPath = StrPtr(arPath())

   SGGrid1.Images = SHGetFileInfo(lPath, 0&, sfi, Len(sfi), _
      ByVal SHGFI_SYSICONINDEX Or SHGFI_ICON Or SHGFI_SMALLICON)

   SGGrid1.DataColCount = 10
   SGGrid1.Rows.At(0).Height = 325

   With SGGrid1.Styles("Heading")
      .PictureAlignment = sgPicAlignLeftTop
      .TextAlignment = sgAlignLeftCenter
   End With

   For i = 1 To 10
      SGGrid1.Columns.At(i).HeadingPicture = i
   Next
End Sub

Back to topic


InactiveSelection Property

InactiveSelection Property
Returns or sets a value indicating how to draw selection when grid does not have focus.

Read/Write at run time and design time.

Syntax

object.InactiveSelection As sgInactiveSelection

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The InactiveSelection settings are:

Name | Value | Description
sgHideSelection | 0 | Selected cells are displayed as not selected when grid does not have focus.
sgShowAsInactive | 1 | Selected cells are displayed with inactive colors.
sgShowAsNormal | 2 | Selected cells are displayed using same colors as when the grid has the focus.

Remarks

This property determines how a selection will be drawn when grid does not have focus.

Show Example
Copy Code [image] Show Me

The following example shows how the InactiveSelection works. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Form_Load()
   SGGrid1.SpecialMode = sgModeListBox
End Sub

Private Sub Command1_Click()
   If SGGrid1.InactiveSelection = sgShowAsNormal Then
      SGGrid1.InactiveSelection = sgHideSelection
   Else
      SGGrid1.InactiveSelection = SGGrid1.InactiveSelection + 1
   End If
End Sub

Back to topic


IsColVisible Property

IsColVisible Property
Returns True if column is visible.

Read-only at run time. Not available at design time.

Syntax

object.IsColVisible As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Use EnsureCellVisible to make a specific column visible.

Show Example
Copy Code [image] Show Me

The following example scrolls the grid until the 22th column is visible. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim col As SGColumn

   SGGrid1.DataColCount = 50

   For Each col In SGGrid1.Columns
      col.Caption = col.Key
   Next

   While Not SGGrid1.IsColVisible(22)
      SGGrid1.Scroll 0, 1
   Wend

   Set col = Nothing
End Sub

Back to topic


IsRowVisible Property

IsRowVisible Property
Returns True if row is visible.

Read-only at run time. Not available at design time.

Syntax

object.IsRowVisible As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Use EnsureCellVisible to make specific row visible.

This property is read only.

Show Example
Copy Code [image] Show Me

The following example scrolls the grid until the 122th row is visible. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   SGGrid1.RowNumbering = True
   SGGrid1.DataRowCount = 250

   While Not SGGrid1.IsRowVisible(122)
      SGGrid1.Scroll 1, 0
   Wend

End Sub

Back to topic


LeftCol Property

LeftCol Property
Returns or sets left-most visible column (zero-based).

Read/Write at run time. Not available at design time.

Syntax

object.LeftCol As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The LeftCol property uses column position to specify left most column.

Show Example
Copy Code [image] Show Me

The following example scrolls the contents of the grid for all visible columns. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()

   If SGGrid1.LeftCol = SGGrid1.RightCol Then
      SGGrid1.LeftCol = 0
   Else
      SGGrid1.LeftCol = SGGrid1.RightCol
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim col As SGColumn

   SGGrid1.RowNumbering = True

   SGGrid1.DataColCount = 50
   SGGrid1.DataRowCount = 100

   For Each col In SGGrid1.Columns
      col.Caption = col.Key
   Next
End Sub

Back to topic


License Property

License Property
Returns license description.

Read-only at run time. Not available at design time.

Syntax

object.License As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property returns license description text.

Show Example
Copy Code [image] Show Me

The following example shows the license and the grid's version in to the message box.

Private Sub SGGrid1_OnInit()
   Dim sVersion  As String
   Dim sLic As String

   sVersion = "Version: " & SGGrid1.Version
   sLic = "License: " & SGGrid1.License

   MsgBox sVersion & vbCrLf & sLic, vbInformation
End Sub

Back to topic


MaxColumns Property

MaxColumns Property
Returns or sets the maximum number of columns.

Read/Write at run time and design time.

Syntax

object.MaxColumns As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The MaxColCount property limits the number of columns a grid can contain. The default values for this property are 8192 in Pro Edition and 16 in Free Edition. These limits can be changed in future versions.

Setting this property to a value smaller than current column count will remove appropriate number of columns.

You can use this property in all data modes.

If you want to limit the number of columns in the bound data mode, set the MaxColumns property before the grid is bound.

The following two examples are not the same:

SGGrid1.DataColCount = 50
SGGrid1.MaxColumns = 22
- and -

SGGrid1.MaxColumns = 22
SGGrid1.DataColCount = 50

In the first example the grid has 50 columns but, in second 22.

Show Example
Copy Code [image] Show Me

The following example limits number of columns when the grid is bounded to the database. Note than you should call MaxColumns before the grid is bounded.

Private Sub Form_Load()

   SGGrid1.MaxColumns = 4
   SGGrid1.DataMode = sgBound
   Set SGGrid1.DataSource = Adodc1

End Sub

Back to topic


MaxRows Property

MaxRows Property
Returns or sets the maximum number of rows.

Read/Write at run time and design time.

Syntax

object.MaxRows As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The MaxRowCount property limits the number of rows a grid can contain. The default values for this property are 4194304 (4 millions) in Pro Edition and 1024 in Free Edition. These limits can be changed in future versions.

Setting this property to a value smaller than current row count will remove appropriate number of rows.

You can use this property in all data modes.

If you want to limit number of rows in the bound data mode, set the MaxRows property before the grid is bound.

The following two examples are not the same:

SGGrid1.DataRowCount = 50
SGGrid1.MaxRows = 22

- and -

SGGrid1.MaxRows = 22
SGGrid1.DataRowCount = 50

In the first example the grid has 50 rows, but in second 22.

Show Example
Copy Code [image] Show Me

The following example uses the MaxRows property to limit number of rows in the VirtualEvents data mode. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.RowNumbering = True
   SGGrid1.MaxRows = 250
   SGGrid1.DataMode = sgVirtualEvents
End Sub

Private Sub SGGrid1_VirtualReadData(ByVal rowBuffer As IsgRowBuffer)
   Dim i As Integer

   For i = 0 To rowBuffer.ColumnCount - 1
      rowBuffer.Value(i) = "Row: " & rowBuffer.RowIndex & " Col: " & (i + 1)
   Next

End Sub

Back to topic


MouseCol Property

MouseCol Property
Returns position of the column under the mouse pointer (zero-based).

Read-only at run time. Not available at design time.

Syntax

object.MouseCol As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The MouseCol property returns the position of the column that is under the mouse pointer. If there is no column under the mouse pointer, this property returns -1.

Show Example
Copy Code [image] Show Me

The following example paints a cell bellow the mouse pointer. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   Dim lRowKey As Long, sColKey As String
   Dim oCell As SGCell
   Static lOldRowKey As Long
   Static sOldColKey As String

   'check out if mouse pointer is over cells
   If SGGrid1.HitTest(x, y) <> sgHitCell Then Exit Sub
   'get row and col keys
   lRowKey = SGGrid1.Rows.At(SGGrid1.MouseRow).Key
   sColKey = SGGrid1.Columns.At(SGGrid1.MouseCol).Key

   If lOldRowKey = lRowKey And _
      sColKey = sOldColKey Then Exit Sub

   'paint old cell to white
   If Len(sOldColKey) > 0 Then
      Set oCell = SGGrid1.cell(lOldRowKey, sOldColKey)
      oCell.Style.BackColor = vbWhite
      oCell.Redraw
   End If

   Set oCell = SGGrid1.cell(lRowKey, sColKey)
   'paint it red
   oCell.Style.BackColor = vbRed
   Set oCell = Nothing
   'save current keys to static variables
   lOldRowKey = lRowKey
   sOldColKey = sColKey

   SGGrid1.RedrawCell SGGrid1.MouseRow, SGGrid1.MouseCol
End Sub

Back to topic


MouseRow Property

MouseRow Property
Returns position of the row under the mouse pointer (zero-based).

Read-only at run time. Not available at design time.

Syntax

object.MouseRow As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The MouseRow property returns the position of the row that is under the mouse pointer. If there is no row under the mouse pointer, this property returns -1.

Show Example
Copy Code [image] Show Me

The following example paints a cell bellow the mouse pointer. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   Dim lRowKey As Long, sColKey As String
   Dim oCell As SGCell
   Static lOldRowKey As Long
   Static sOldColKey As String

   'check out if mouse pointer is over cells
   If SGGrid1.HitTest(x, y) <> sgHitCell Then Exit Sub
   'get row and col keys
   lRowKey = SGGrid1.Rows.At(SGGrid1.MouseRow).Key
   sColKey = SGGrid1.Columns.At(SGGrid1.MouseCol).Key

   If lOldRowKey = lRowKey And _
      sColKey = sOldColKey Then Exit Sub

   'paint old cell to white
   If Len(sOldColKey) > 0 Then
      Set oCell = SGGrid1.cell(lOldRowKey, sOldColKey)
      oCell.Style.BackColor = vbWhite
      oCell.Redraw
   End If

   Set oCell = SGGrid1.cell(lRowKey, sColKey)
   'paint it red
   oCell.Style.BackColor = vbRed
   Set oCell = Nothing
   'save current keys to static variables
   lOldRowKey = lRowKey
   sOldColKey = sColKey

   SGGrid1.RedrawCell SGGrid1.MouseRow, SGGrid1.MouseCol
End Sub

Back to topic


MultiSelect Property

MultiSelect Property
Controls multiple selection mode.

Read/Write at run time and design time.

Syntax

object.MultiSelect As sgMultiSelect

The object placeholder represents an object expression that evaluates to SGSelection and SGGrid objects.

Settings

The MultiSelect settings are:
Name | Value | Description
sgMultiSelectNone | 0 | No multiple selections.
sgMultiSelectSimple | 1 | All selected rows, cols or cells are adjacent.
sgMultiSelectExtended | 2 | Can select ranges of non-adjacent rows, cols or cells.

Remarks

Returns or sets a value indicating whether a user can select multiple rows, columns or cells and how the multiple selections can be made.

This property has no effect if the SelectionMode is set to sgSelectionNone.

Show Example
Copy Code [image] Show Me

Private Sub Form_Load()
   SGGrid1.SelectionMode = sgSelectionByRow
   SGGrid1.MultiSelect = sgMultiSelectExtended
   SGGrid1.SpecialMode = sgModeListBox
End Sub

Back to topic


NavigationWrapMode Property

NavigationWrapMode Property
Returns or sets wrapping mode used for grid navigation.

Read/Write at run time and design time.

Syntax

object.NavigationWrapMode As sgNavigationWrapMode

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The NavigationWrapMode settings are:

Name | Value | Description
sgNavigationWrapNone | 0 | Do not wrap to the next row.
sgNavigationWrapNext | 1 | Wrap to the first focusable column of the next focusable row.
sgNavigationWrapSame | 2 | Wrap to the first focusable column of the same row.

Remarks

The NavigationWrapMode property determines the behavior of the arrow keys when focus is on the last focusable cell in a row.

When set to sgNavigationWrapNone, focus is not moved to the next cell.

When set to sgNavigationWrapNext, focus is moved to the first focusable cell in the next focusable row.

When set to sgNavigationWrapSame, focus is moved to the first focusable cell in the same row.

Note that the same rules apply to the TAB and the ENTER keys if their behavior is modified (with TabKeyBehavior or EnterKeyBehavior properties), so that pressing them moves focus to the next column.

Show Example
Copy Code [image] Show Me

The following example shows how to set some properties important for data input.

Private Sub SGGrid1_OnInit()
   'allow full editing
   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True
   SGGrid1.AllowEdit = True
   'set keys behavior
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.NavigationWrapMode = sgNavigationWrapNext
   'skip read only columns to speed up data entering
   SGGrid1.SkipReadOnly = True
End Sub

Back to topic


NewRowPos Property

NewRowPos Property
Returns or sets position of the row used to add new records.

Read/Write at run time and design time.

Syntax

object.NewRowPos As sgNewRowPos

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The NewRowPos settings are:

Name | Value | Description
sgNewRowTop | 0 | The row for adding new records is the first row below the heading rows.
sgNewRowBottom | 1 | The row for adding new records is the last grid row.

Remarks

Returns or sets position of the add new row

This property has effect only if the AllowAddNew property is set to true.

Show Example
Copy Code [image] Show Me

Private Sub Form_Load()

   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.AllowAddNew = True
   SGGrid1.NewRowPos = sgNewRowTop

End Sub

Back to topic


OLEDragMode Property

OLEDragMode Property
Returns or sets whether the control can act as an OLE drag source, either automatically or under program control.

Read/Write at run time and design time.

Syntax

object.OLEDragMode As sgOLEDragMode

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The OLEDragMode settings are:

Name | Value | Description
sgOLEDragModeManual | 0 | Manual.
sgOLEDragModeAutomatic | 1 | Automatic.

Remarks

When OLEDragMode is set to Manual, you must call the OLEDrag method to start dragging. When OLEDragMode is set to Automatic, the source component fills the SGDataObject object with the data and sets the effects parameter before initiating the OLEStartDrag event (as well as the OLESetData and other source-level OLE drag/drop events) when the user attempts to drag out of the control. This gives you control over the drag/drop operation and allows you to intercede by adding other formats, or by overriding or disabling the automatic data and formats using the Clear or SetData methods.

If the Visual Basic's DragMode property is set to Automatic, the setting of OLEDragMode is ignored, because regular Visual Basic drag and drop events take precedence.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to start drag-and-drop operations from the code.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   'start drag-drop operations
   If button = vbLeftButton Then SGGrid1.OLEDrag
End Sub

Private Sub SGGrid1_OLEStartDrag( _
   ByVal data As IsgDataObject, _
   allowedEffects As Long)
   'drag contents of the current cell
   data.SetData SGGrid1.CurrentCell.Value, vbCFText
End Sub

Back to topic


OLEDropMode Property

OLEDropMode Property
Returns or sets whether the control can act as an OLE drop target, either automatically or under program control.

Read/Write at run time and design time.

Syntax

object.OLEDropMode As sgOLEDropMode

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The OLEDropMode settings are:

Name | Value | Description
sgOLEDropModeNone | 0 | None.
sgOLEDropModeManual | 1 | Manual.
sgOLEDropModeAutomatic | 2 | Automatic.

Remarks

If you want to format dropped data use the sgOLEDropModeManual mode. This mode triggers the OLEDragDrop events, allowing you to handle the OLE drop operation in code.

Show Example
Copy Code [image] Show Me

The following example formats droped data in the OLEDragDrop event. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Drop some text from any application that supports OLE Drag-Drop to the grid.

Private Sub SGGrid1_OnInit()
   SGGrid1.OLEDropMode = sgOLEDropModeManual
   SGGrid1.RowNumbering = True
End Sub

Private Sub SGGrid1_OLEDragDrop( _
   ByVal Data As IsgDataObject, Effect As Long, _
   ByVal Button As Integer, ByVal Shift As Integer, _
   ByVal X As Single, ByVal Y As Single)

   If Data.GetFormat(vbCFText) Then
      Dim arText() As String
      Dim i As Integer, lRowKey As Long
      Dim iCol As Integer, lRowPos As Long

      SGGrid1.RedrawEnabled = False

      arText = Split(Data.GetData(vbCFText), Chr(13))
      lRowPos = SGGrid1.MouseRow
      lRowKey = SGGrid1.Rows.At(lRowPos).Key

      For i = 0 To UBound(arText)
         arText(i) = Replace(arText(i), Chr(10), "")
         arText(i) = Replace(arText(i), Chr(8), "")
         SGGrid1.Rows(lRowKey).Cells(iCol + 1).Value = Trim(arText(i))
         iCol = iCol + 1
         If i Mod SGGrid1.DataColCount = 0 Then
            lRowPos = lRowPos + 1
            If lRowPos > SGGrid1.DataRowCount Then
               SGGrid1.DataRowCount = SGGrid1.DataRowCount + 1
            End If
            lRowKey = SGGrid1.Rows.At(lRowPos).Key
            iCol = 0
         End If
      Next

      SGGrid1.RedrawEnabled = True
   End If
End Sub

Back to topic


OutlineLines Property

OutlineLines Property
Returns or sets a value indicating what type of lines to draw in outline mode.

Read/Write at run time and design time.

Syntax

object.OutlineLines As sgOutlineLines

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The OutlineLines settings are:

Name | Value | Description
sgNoOutlineLines | 0 | Do not draw any lines.
sgGroupLines | 1 | Draw grouping lines.

Remarks

This property has effect only if the grid is grouped.

Show Example
Copy Code [image] Show Me

The following example adds random numbers to the grid and groups odd/even ones. The group is drawn without indentation and lines. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupIndentation = 0

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .Style.TextAlignment = sgAlignRightCenter
      .Style.Format = "Standard"
   End With

   SGGrid1.DataRowCount = 20

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
    sgSortTypeNumber, False, True

   Set ar = Nothing
End Sub

Back to topic


PaintObject Property

PaintObject Property
Sets an object that implements custom draw interface (IsgGridCustomDraw).

Read/Write at run time. Not available at design time.

Syntax

object.PaintObject As IsgGridCustomDraw

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The grid control draws its content in several stages and object that implements the IsgGridCustomDraw interface can intercept and/or replace those drawing stages with its own drawing methods. To enable custom drawing in the BeeGrid control, you must assign an object that implements the IsgGridCustomDraw COM interface to the PaintObject property.

Generally, to support custom drawing, you must do following:

  • Implement the IsgGridCustomDraw interface.
  • Assign an object that implements interface to the PaintObject property.
  • Set SGGrid's CustomBkgDraw and/or SGStyle's CustomDraw properties to the drawing stage you want to intercept.

Note that Free Edition does not support custom drawing.

Show Example
Copy Code [image] Show Me

The following example draws two circles on the grid. It draws one on the caption area and another on the background. It fills the first column with random data. Example uses this data to draw small rectangle on the left corner. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Implements IsgGridCustomDraw

Private Declare Function SelectObject Lib "gdi32" _
   (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
   (ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" _
   (ByVal crColor As Long) As Long
Private Declare Function Ellipse Lib "gdi32" _
   (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _
   ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreatePen Lib "gdi32" _
   (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function Rectangle Lib "gdi32" _
   (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _
   ByVal X2 As Long, ByVal Y2 As Long) As Long

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.Caption = "Custom draw"

   Set SGGrid1.PaintObject = Me
   SGGrid1.CustomBkgDraw = sgDrawBeforeGridBkg

   With SGGrid1.Columns.At(1)
      .Style.CustomDraw = sgDrawAfterCellContent
      .Caption = "Custom draw"
   End With

   SGGrid1.DataRowCount = 100

   For i = 0 To SGGrid1.DataRowCount - 1
      SGGrid1.Array(i, 0) = CLng(Rnd * vbWhite)
   Next
End Sub

Private Sub IsgGridCustomDraw_DrawGridBkg( _
   drawInfo As sgGridCustomDraw, _
   response As sgCustomDrawResponse)
   Dim hBrush As Long
   Dim hOldBrush As Long

   If drawInfo.DrawStage = sgDrawAfterGridCaption Then
      ' Draw caption
      hBrush = CreateSolidBrush(RGB(255, 0, 0))
      hOldBrush = SelectObject(drawInfo.DC, hBrush)

      Ellipse drawInfo.DC, drawInfo.Left + 6, drawInfo.Top + 2, _
                            drawInfo.Left + 20, drawInfo.bottom - 1

      SelectObject drawInfo.DC, hOldBrush
      DeleteObject hBrush
   ElseIf drawInfo.DrawStage = sgDrawAfterGridBkg Then

      hBrush = CreateSolidBrush(RGB(255, 0, 0))
      hOldBrush = SelectObject(drawInfo.DC, hBrush)

      Ellipse drawInfo.DC, drawInfo.right - 70, drawInfo.bottom - 40, _
                            drawInfo.right - 34, drawInfo.bottom - 4

      SelectObject drawInfo.DC, hOldBrush
      DeleteObject hBrush
   End If

   response = sgDoDefault
End Sub

Private Sub IsgGridCustomDraw_DrawCell( _
   drawInfo As sgGridCustomDraw, _
   response As sgCustomDrawResponse)
   Dim hPen As Long
   Dim hOldPen As Long
   Dim sData As String

   response = sgDoDefault

   ' Ignore heading cells
   If drawInfo.Heading <> 0 Then Exit Sub

   If drawInfo.DrawStage = sgDrawAfterCellBkg Then
      If drawInfo.ColIndex = 1 Then
         ' Draw left positioned color box and adjust content rect
         ' so grids default painting will not overwrite our color box
         ' Get color
         Dim clr As Long

         clr = CLng(drawInfo.Data)

         ' Draw rectangle
         DrawRectangle drawInfo.DC, clr, drawInfo.Left + 4, drawInfo.Top + 2, _
                                          drawInfo.Left + (drawInfo.bottom - drawInfo.Top), drawInfo.bottom - 2

         drawInfo.Left = drawInfo.Left + 26
      End If
   End If
End Sub

Private Sub DrawRectangle(hdc&, clr&, Left&, Top&, right&, bottom&)
   Dim hBrush As Long
   Dim hPen As Long
   Dim hOldBrush As Long
   Dim hOldPen As Long

   ' Create pen and brush
   hPen = CreatePen(0, 0, RGB(0, 0, 0))
   hBrush = CreateSolidBrush(clr)
   hOldPen = SelectObject(hdc, hPen)
   hOldBrush = SelectObject(hdc, hBrush)

   ' Draw rectangle
   Rectangle hdc, Left, Top, right, bottom

   ' Release pen and brush
   SelectObject hdc, hOldPen
   SelectObject hdc, hOldBrush
   DeleteObject hPen
   DeleteObject hBrush
End Sub

Back to topic


PreviewPaneColumn Property

PreviewPaneColumn Property
Returns or sets key of the column displayed in the preview pane.

Read/Write at run time and design time.

Syntax

object.PreviewPaneColumn As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Preview Pane is an area inside the grid control that displays contents of one cell in the current row. The PreviewPaneColumn property contains key of the column that will be displayed inside this area.

Not available in the Free Edition.

Show Example
Copy Code [image] Show Me

The following example reads ini files from the Windows directory and displays them in the Preview pane. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Change the current row to see effects.

Private Sub SGGrid1_OnInit()
   Dim sFile As String, iFreeFile As Integer
   Dim sWinDir As String
   Dim i As Integer

   'disable redraw to speed up process
   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   'Column creations
   With SGGrid1.Columns.Add("File")
      .Caption = "File name"
      .Width = 2200
   End With

   With SGGrid1.Columns.Add("FileData")
      .Caption = "File data"
      .DataType = sgtDateTime
      .Hidden = True
   End With

   SGGrid1.FitLastColumn = True
   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.ini", vbNormal)
   'add ini files and files contents to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      iFreeFile = FreeFile

      Open sWinDir & sFile For Input As iFreeFile

      SGGrid1.Rows.At(i).Cells(1).Value = _
         StrConv(InputB(LOF(iFreeFile), iFreeFile), vbUnicode)
      Close #iFreeFile
      sFile = Dir
   Loop
   'create Preview pane
   With SGGrid1
      .PreviewPaneColumn = SGGrid1.Columns("FileData").Key
      .PreviewPanePosition = sgPreviewPaneBottom
      .PreviewPaneType = sgPreviewPaneDefault
        'define the preview panes style
      With .Styles("PreviewPane")
         .WordWrap = True
         .TextAlignment = sgAlignLeftTop
         .BackColor = vbBlack
         .ForeColor = vbGreen
         .Font.Name = "Courier New"
         .Font.Size = 10
      End With
   End With
   'redraw grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


PreviewPanePosition Property

PreviewPanePosition Property
Returns or sets a value indicating preview pane position.

Read/Write at run time and design time.

Syntax

object.PreviewPanePosition As sgPreviewPanePosition

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The PreviewPanePosition settings are:

Name | Value | Description
sgPreviewPaneLeft | 0 | Preview pane is aligned with left grid border.
sgPreviewPaneTop | 1 | Preview pane is aligned with top grid border.
sgPreviewPaneRight | 2 | Preview pane is aligned with right grid border.
sgPreviewPaneBottom | 3 | Preview pane is aligned with bottom grid border.

Remarks

Returns or sets the Preview pane position. Use this property with the PreviewPaneSize property and the "PreviewPane" style to define the pane look.

This property has effect only if the PreviewPaneType is set to sgPreviewPaneDefault.

Show Example
Copy Code [image] Show Me

The following example reads ini files from the Windows directory and displays them in the Preview pane. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Change the current row to see effects.

Private Sub SGGrid1_OnInit()
   Dim sFile As String, iFreeFile As Integer
   Dim sWinDir As String
   Dim i As Integer

   'disable redraw to speed up process
   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   'Column creations
   With SGGrid1.Columns.Add("File")
      .Caption = "File name"
      .Width = 2200
   End With

   With SGGrid1.Columns.Add("FileData")
      .Caption = "File data"
      .DataType = sgtDateTime
      .Hidden = True
   End With

   SGGrid1.FitLastColumn = True
   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.ini", vbNormal)
   'add ini files and files contents to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      iFreeFile = FreeFile

      Open sWinDir & sFile For Input As iFreeFile

      SGGrid1.Rows.At(i).Cells(1).Value = _
         StrConv(InputB(LOF(iFreeFile), iFreeFile), vbUnicode)
      Close #iFreeFile
      sFile = Dir
   Loop
   'create Preview pane
   With SGGrid1
      .PreviewPaneColumn = SGGrid1.Columns("FileData").Key
      .PreviewPanePosition = sgPreviewPaneBottom
      .PreviewPaneType = sgPreviewPaneDefault
        'define the preview panes style
      With .Styles("PreviewPane")
         .WordWrap = True
         .TextAlignment = sgAlignLeftTop
         .BackColor = vbBlack
         .ForeColor = vbGreen
         .Font.Name = "Courier New"
         .Font.Size = 10
      End With
   End With
   'redraw grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


PreviewPaneSize Property

PreviewPaneSize Property
Returns or sets preview pane size (width or height). In twips.

Read/Write at run time and design time.

Syntax

object.PreviewPaneSize As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Returns or sets the Preview pane size (in twips). Use this property together with the PreviewPanePosition property and the "PreviewPane" style to define the pane look.

This property has effect only if the PreviewPaneType is set to sgPreviewPaneDefault.

Doubleclick on the preview pane splitter sets the preview pane size to zero.

Show Example
Copy Code [image] Show Me

The following example reads ini files from the Windows directory and displays them in the Preview pane. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Change the current row to see effects.

Private Sub SGGrid1_OnInit()
   Dim sFile As String, iFreeFile As Integer
   Dim sWinDir As String
   Dim i As Integer

   'disable redraw to speed up process
   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   'Column creations
   With SGGrid1.Columns.Add("File")
      .Caption = "File name"
      .Width = 2200
   End With

   With SGGrid1.Columns.Add("FileData")
      .Caption = "File data"
      .DataType = sgtDateTime
      .Hidden = True
   End With

   SGGrid1.FitLastColumn = True
   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.ini", vbNormal)
   'add ini files and files contents to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      iFreeFile = FreeFile

      Open sWinDir & sFile For Input As iFreeFile

      SGGrid1.Rows.At(i).Cells(1).Value = _
         StrConv(InputB(LOF(iFreeFile), iFreeFile), vbUnicode)
      Close #iFreeFile
      sFile = Dir
   Loop
   'create Preview pane
   With SGGrid1
      .PreviewPaneColumn = SGGrid1.Columns("FileData").Key
      .PreviewPanePosition = sgPreviewPaneBottom
      .PreviewPaneType = sgPreviewPaneDefault
        'define the preview panes style
      With .Styles("PreviewPane")
         .WordWrap = True
         .TextAlignment = sgAlignLeftTop
         .BackColor = vbBlack
         .ForeColor = vbGreen
         .Font.Name = "Courier New"
         .Font.Size = 10
      End With
   End With
   'redraw grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


PreviewPaneType Property

PreviewPaneType Property
Returns or sets key of the column displayed in the preview pane.

Read/Write at run time and design time.

Syntax

object.PreviewPaneType As sgPreviewPaneType

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The PreviewPaneType settings are:

Name | Value | Description
sgNoPreviewPane | 0 | Grid does not show preview pane.
sgPreviewPaneDefault | 1 | Preview pane is drawn with standard cell drawing.

Remarks

This property determines whether the Preview pane is displayed.

Use the "PreviewPane" style to define the pane style. Modify the CustomDraw member of the "PreviewPane" style to customize preview pane drawing.

Show Example
Copy Code [image] Show Me

The following example reads ini files from the Windows directory and displays them in the Preview pane. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Change the current row to see effects.

Private Sub SGGrid1_OnInit()
   Dim sFile As String, iFreeFile As Integer
   Dim sWinDir As String
   Dim i As Integer

   'disable redraw to speed up process
   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   'Column creations
   With SGGrid1.Columns.Add("File")
      .Caption = "File name"
      .Width = 2200
   End With

   With SGGrid1.Columns.Add("FileData")
      .Caption = "File data"
      .DataType = sgtDateTime
      .Hidden = True
   End With

   SGGrid1.FitLastColumn = True
   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.ini", vbNormal)
   'add ini files and files contents to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      iFreeFile = FreeFile

      Open sWinDir & sFile For Input As iFreeFile

      SGGrid1.Rows.At(i).Cells(1).Value = _
         StrConv(InputB(LOF(iFreeFile), iFreeFile), vbUnicode)
      Close #iFreeFile
      sFile = Dir
   Loop
   'create Preview pane
   With SGGrid1
      .PreviewPaneColumn = SGGrid1.Columns("FileData").Key
      .PreviewPanePosition = sgPreviewPaneBottom
      .PreviewPaneType = sgPreviewPaneDefault
        'define the preview panes style
      With .Styles("PreviewPane")
         .WordWrap = True
         .TextAlignment = sgAlignLeftTop
         .BackColor = vbBlack
         .ForeColor = vbGreen
         .Font.Name = "Courier New"
         .Font.Size = 10
      End With
   End With
   'redraw grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


RedrawEnabled Property

RedrawEnabled Property
Enables or disables redrawing of the control.

Read/Write at run time. Not available at design time.

Syntax

object.RedrawEnabled As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Use the RedrawEnabled property to reduce flickering when some BeeGrid properties are changed. Set this property to False when you want to stop automatic redrawing. It is important to set the RedrawEnabled property back to True in order to enable normal grid repainting.

Show Example
Copy Code [image] Show Me

The following example shows how to use the RedrawEnabled property to reduce flicker and increase speed. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim cell As SGCell
   Dim row As SGRow
   'add columns
   SGGrid1.DataColCount = 10
   SGGrid1.DataRowCount = 100
   'comment this line to notice
   'difference
   SGGrid1.RedrawEnabled = False

   For Each row In SGGrid1.Rows
      If Not row.Heading Then
         For Each cell In row.Cells
            If Not cell.Column.Heading Then
               cell.Value = FormatDateTime(Now, vbLongTime)
               cell.Style.BackColor = vbBlack
               cell.Style.ForeColor = vbGreen
            End If
         Next
      End If
   Next

   SGGrid1.RedrawEnabled = True
   'get time
   MsgBox "From " & SGGrid1.Array(0, 0) & " to " & SGGrid1.Array(99, 9)

End Sub

Back to topic


RightCol Property

RightCol Property
Returns a zero-based index of the last visible column.

Read-only at run time. Not available at design time.

Syntax

object.RightCol As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Show Example
Copy Code [image] Show Me

The following example scrolls the contents of the grid for all visible columns. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()

   If SGGrid1.LeftCol = SGGrid1.RightCol Then
      SGGrid1.LeftCol = 0
   Else
      SGGrid1.LeftCol = SGGrid1.RightCol
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim col As SGColumn

   SGGrid1.RowNumbering = True

   SGGrid1.DataColCount = 50
   SGGrid1.DataRowCount = 100

   For Each col In SGGrid1.Columns
      col.Caption = col.Key
   Next
End Sub

Back to topic


Row Property

Row Property
Returns or sets current row position

Read/Write at run time. Not available at design time.

Syntax

object.Row As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Show Example
Copy Code [image] Show Me

The following example changes the current col and row. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()

   If SGGrid1.col = SGGrid1.ColCount - 1 Then
      If SGGrid1.row = SGGrid1.RowCount - 1 Then
         SGGrid1.row = SGGrid1.HeadingRowCount
      Else
         SGGrid1.row = SGGrid1.row + 1
      End If
      SGGrid1.col = SGGrid1.HeadingColCount
   Else
      SGGrid1.col = SGGrid1.col + 1
   End If

End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.Styles("CurrentCell").BackColor = vbBlue
End Sub

Back to topic


RowCount Property

RowCount Property
Returns the total number of rows.

Read-only at run time. Not available at design time.

Syntax

object.RowCount As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The read-only RowCount property returns the total number of rows. It is always the sum of the values returned from the HeadingRowCount and the DataRowCount properties. To change number of rows, use the DataRowCount property (in the sgUnbound data mode only), and to change number of heading rows, use the HeadingRowCount property.

There are several ways to get Rows count:

SGGrid1.RowCount

- or -

SGGrid1.Rows.Count

- or -

SGGrid1.DataRowCount + SGGrid1.HeadingRowCount

Show Example
Copy Code [image] Show Me

The following example changes the current col and row. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()

   If SGGrid1.col = SGGrid1.ColCount - 1 Then
      If SGGrid1.row = SGGrid1.RowCount - 1 Then
         SGGrid1.row = SGGrid1.HeadingRowCount
      Else
         SGGrid1.row = SGGrid1.row + 1
      End If
      SGGrid1.col = SGGrid1.HeadingColCount
   Else
      SGGrid1.col = SGGrid1.col + 1
   End If

End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.Styles("CurrentCell").BackColor = vbBlue
End Sub

Back to topic


RowFilters Property

RowFilters Property
Returns a collection of filter definitions.

Read-only at run time. Not available at design time.

Syntax

object.RowFilters As IsgFilters

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The RowFilters property returns a collection of SGFilter objects. Each SGFilter object is a definition for one filter. You can use filters to assign special (filter) markers to a row that meets the filter condition. When a row is marked with a filter marker, the grid can display it in some special manner. For example, row can be hidden or rendered with "FilteredRow" style. In addition, you can enumerate rows and perform some custom action on filtered rows.

Note that individual filter conditions are connected with logical AND operation. That means that for a row to be marked, all conditions from the SGFilters collection must be satisfied.

Typically, to use row filters you follow these steps:

  • Create new filter by using Add method of the SGFilters collection. In addition, SGFilters collection can be saved and later loaded with GetDefinition and SetDefinition methods, respectively.
  • Apply filters with SGFilters Apply method. This method enumerates all rows and marks rows that satisfy filter conditions with markers that are given as parameter. Applied filters are persistent. That means that filter markers are not removed until ClearMarkers method is called or row itself is deleted. Also, filter is automatically applied after all changes in existing data.

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers and filters rows. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sColKey As String
   Dim i As Long, j As Long
   Dim ar As SGArray

   SGGrid1.DataRowCount = 500

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 1000)
      Next
   Next

   Set ar = Nothing

   With SGGrid1.Styles("FilteredRow")
      .BackColor = &HDDFFFF
      .ForeColor = &H880000
      .Font.Bold = True
      .BorderColor = vbBlack
      .BorderSize = 1
      .Borders = sgCellBorderBottom
   End With

   sColKey = SGGrid1.Columns(1).Key

   Call SGGrid1.RowFilters.Add("Sample Filter", _
      sColKey, sgOpBetween, 300, 600)

   SGGrid1.RowFilters.Apply sgFilterActionSelect

End Sub

Back to topic


RowHeightMax Property

RowHeightMax Property
Returns or sets the maximum row height.

Read/Write at run time and design time.

Syntax

object.RowHeightMax As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The RowHeightMax property determines the maximum row height. The RowHeightMax property is specified in the container's coordinate system.

Show Example
Copy Code [image] Show Me

The following example shows how to set rows and columns dimensions.

Private Sub SGGrid1_OnInit()

   SGGrid1.DefaultColWidth = 305
   SGGrid1.DefaultRowHeight = 305

   SGGrid1.ColWidthMin = 250
   SGGrid1.ColWidthMax = 505

   SGGrid1.RowHeightMin = 250
   SGGrid1.RowHeightMax = 505

   SGGrid1.EqualColWidth = True
   SGGrid1.EqualRowHeight = True
End Sub

Back to topic


RowHeightMin Property

RowHeightMin Property
Returns or sets the minimum row height.

Read/Write at run time and design time.

Syntax

object.RowHeightMin As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The RowHeightMin property determines the minimum row height. The RowHeightMin property is specified in terms of the container's coordinate system.

Show Example
Copy Code [image] Show Me

The following example shows how to set rows and columns dimensions.

Private Sub SGGrid1_OnInit()

   SGGrid1.DefaultColWidth = 305
   SGGrid1.DefaultRowHeight = 305

   SGGrid1.ColWidthMin = 250
   SGGrid1.ColWidthMax = 505

   SGGrid1.RowHeightMin = 250
   SGGrid1.RowHeightMax = 505

   SGGrid1.EqualColWidth = True
   SGGrid1.EqualRowHeight = True
End Sub

Back to topic


RowNumbering Property

RowNumbering Property
Enables or disables row heading numbers.

Read/Write at run time and design time.

Syntax

object.RowNumbering As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The RowNumbering property determines whether the grid displays row numbers inside row heading cells. By default, row number alignment is left-center. You can change style of row numbers by changing style of the first column.
The following code draws row numbering text in a red color:

SGGrid1.Columns.At(0).Style.ForeColor = vbRed

Note that row numbering includes hidden rows, too.

Show Example
Copy Code [image] Show Me

The following example shows how to use the CheckBox to change the RowNumbering property.

Private Sub Check1_Click()
   SGGrid1.RowNumbering = Check1.Value
End Sub

Back to topic


RowStyleConditions Property

RowStyleConditions Property
Returns the collection of conditional style rules that are applied to grid rows.
Syntax

object.RowStyleConditions As IsgStyleConditions

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The RowStyleConditions property returns a collection of the SGStyleCondition objects. Each object in this collection represents one style and condition when that style can be applied. When the BeeGrid paints a row, it examines this collection and if a condition is met, style is applied to the row.

You can manipulate members of the SGStyleConditions collection by using standard collection methods. Each object in the collection can be accessed by its index.

Use the Add method to add a new condition to a collection:

   SGGrid1.RowStyleConditions.Add "Tip", _
      sgConditionCellValue, sgOpGreaterThan, 1000, , "Amount"

Show Example
Copy Code [image] Show Me

The following example uses the RowStyleConditions collection to paint all rows where the value of the Amount column is greater then 1000. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long

   SGGrid1.FitLastColumn = True
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With

   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   'populate grid with sample data
   Set ar = SGGrid1.Array
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 1) = Round((Rnd * 2000), 2)
   Next

   With SGGrid1.Styles.Add("Over1000")
      .BackColor = RGB(255, 255, 240)
      .BkgStyle = sgCellBkgGradientVertical
      .Borders = sgCellBorderBottom
      .BorderColor = RGB(128, 0, 0)
      .BorderSize = 15
   End With

   SGGrid1.RowStyleConditions.Add "Over1000", _
      sgConditionCellValue, sgOpGreaterThan, 1000, , "Amount"

End Sub

Back to topic


Rows Property

Rows Property
Returns the collection of the grid rows.

Read-only at run time. Not available at design time.

Syntax

object.Rows As IsgRows

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Rows property returns a collection of SGRow objects. Each SGRow object in this collection represents one grid row. Using the SGRows collection you can add, remove enumerate and access individual grid rows.

If you have row's key, use the Item property to access individual row. Use the At method to access the row on a particular position.

For more information, see the SGRows topic.

Show Example
Copy Code [image] Show Me

The following example uses the rows Add method to add rows. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim sData As String
   Dim arColors() As String
   Const COLORS16_NAMES = "Black;Blue;Green;Cyan;Red;Magenta;" & _
      "Yellow;Light Gray;Gray;Light Blue;Light Green;Light Cyan;" & _
      "Light Red;Light Magenta;Light Yellow;Bright White"

   'hide GroupByBox
   SGGrid1.GroupByBoxVisible = False
   'remove all rows
   SGGrid1.DataRowCount = 0
   'add columns
   SGGrid1.DataColCount = 3
   'add colors names to array
   arColors = Split(COLORS16_NAMES, ";")

   For i = 0 To 15
      'create delimeted string
      sData = arColors(i) & ";" & "&H" & _
         Hex(QBColor(i)) & "&" & ";" & QBColor(i)
      'add row to the grid
      SGGrid1.Rows.Add sgFormatCharSeparatedValue, sData, ";"
      'paint the rows heading cell
      SGGrid1.Rows.At(SGGrid1.RowCount - 1). _
         Cells(0).Style.BackColor = QBColor(i)
   Next

End Sub

Back to topic


ScrollBarTips Property

ScrollBarTips Property
Returns or sets a value indicating whether tips are displayed while the user operates scroll bars.

Read/Write at run time and design time.

Syntax

object.ScrollBarTips As sgScrollTip

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The ScrollBarTips settings are:

Name | Value | Description
sgScrollTipsNone | 0 | Scroll tips are not displayed.
sgScrollTipsHorizontal | 1 | Show scroll tips for the horizontal scroll bar.
sgScrollTipsVertical | 2 | Show scroll tips for the vertical scroll bar.
sgScrollTipsBoth | 3 | Show scroll tips for both the horizontal and vertical scroll bars.

Remarks

Use the ScrollBarTips property to display a tool tip as the user moves the scroll thumb. This allows the user to see which row or column 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 ScrollBarTrack property is set to False, because then the control will not scroll until the thumb track is released.

Show Example
Copy Code [image] Show Me

The following example makes the grid look like the ListBox. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim i As Integer
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False

   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0

   SGGrid1.Move 0, 0, 1515, 3000
   SGGrid1.Appearance = sgFlat
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.BackColor = SGGrid1.CellBackColor
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.AllowEdit = False
   'fill grid with test data
   SGGrid1.DataColCount = 1
   SGGrid1.DataRowCount = 100

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 0) = "Item nr. " & Trim(i)
   Next
   'set scroll bar properties
   SGGrid1.ScrollBarTrack = True
   SGGrid1.ScrollBarTips = sgScrollTipsVertical
   SGGrid1.ScrollTipColumn = SGGrid1.Columns(1).Key
   SGGrid1.VScrollWidth = SGGrid1.ClientWidth / 8
   SGGrid1.ScrollBars = sgSBVertical

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True

End Sub

Back to topic


ScrollBarTrack Property

ScrollBarTrack Property
Enables or disables scroll bar tracking.

Read/Write at run time and design time.

Syntax

object.ScrollBarTrack As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Enable or disable the grid scrolling while the user moves the scroll thumb.

By default, this property is set to False.

Show Example
Copy Code [image] Show Me

The following example makes the grid look like the ListBox. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim i As Integer
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False

   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0

   SGGrid1.Move 0, 0, 1515, 3000
   SGGrid1.Appearance = sgFlat
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.BackColor = SGGrid1.CellBackColor
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.AllowEdit = False
   'fill grid with test data
   SGGrid1.DataColCount = 1
   SGGrid1.DataRowCount = 100

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 0) = "Item nr. " & Trim(i)
   Next
   'set scroll bar properties
   SGGrid1.ScrollBarTrack = True
   SGGrid1.ScrollBarTips = sgScrollTipsVertical
   SGGrid1.ScrollTipColumn = SGGrid1.Columns(1).Key
   SGGrid1.VScrollWidth = SGGrid1.ClientWidth / 8
   SGGrid1.ScrollBars = sgSBVertical

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True

End Sub

Back to topic


ScrollBars Property

ScrollBars Property
Returns or sets the scroll bar flags.

Read/Write at run time and design time.

Syntax

object.ScrollBars As sgScrollBar

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The ScrollBars settings are:

Name | Value | Description
sgSBNone | 0 | Scrollbars are not displayed.
sgSBVertical | 1 | Show only vertical scroll bar.
sgSBHorizontal | 2 | Show only horizontal scroll bar.
sgSBAll | 3 | Show both vertical and horizontal scroll bars.

Remarks

Returns or sets a value indicating whether the grid shows horizontal or vertical scroll bars.

Show Example
Copy Code [image] Show Me

The following example makes the grid look like the ListBox. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim i As Integer
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False

   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0

   SGGrid1.Move 0, 0, 1515, 3000
   SGGrid1.Appearance = sgFlat
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.BackColor = SGGrid1.CellBackColor
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.AllowEdit = False
   'fill grid with test data
   SGGrid1.DataColCount = 1
   SGGrid1.DataRowCount = 100

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 0) = "Item nr. " & Trim(i)
   Next
   'set scroll bar properties
   SGGrid1.ScrollBarTrack = True
   SGGrid1.ScrollBarTips = sgScrollTipsVertical
   SGGrid1.ScrollTipColumn = SGGrid1.Columns(1).Key
   SGGrid1.VScrollWidth = SGGrid1.ClientWidth / 8
   SGGrid1.ScrollBars = sgSBVertical

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True

End Sub

Back to topic


ScrollTipColumn Property

ScrollTipColumn Property
Returns or sets key of the column that contains values for vertical scroll tips.

Read/Write at run time and design time.

Syntax

object.ScrollTipColumn As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

By default, the row number is displayed inside the scroll bar tip. Use the ScrollTipColumn property to specify column whose content will be displayed inside the scroll bar tip.

If you want to have more control over the scroll bar tips use the FetchScrollTip event.

This property has effect only if the ScrollBarTips is set to sgScrollTipsVertical or sgScrollTipsBoth.

Show Example
Copy Code [image] Show Me

The following example makes the grid look like the ListBox. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim i As Integer
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False

   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0

   SGGrid1.Move 0, 0, 1515, 3000
   SGGrid1.Appearance = sgFlat
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.BackColor = SGGrid1.CellBackColor
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.AllowEdit = False
   'fill grid with test data
   SGGrid1.DataColCount = 1
   SGGrid1.DataRowCount = 100

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 0) = "Item nr. " & Trim(i)
   Next
   'set scroll bar properties
   SGGrid1.ScrollBarTrack = True
   SGGrid1.ScrollBarTips = sgScrollTipsVertical
   SGGrid1.ScrollTipColumn = SGGrid1.Columns(1).Key
   SGGrid1.VScrollWidth = SGGrid1.ClientWidth / 8
   SGGrid1.ScrollBars = sgSBVertical

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True

End Sub

Back to topic


Selection Property

Selection Property
Returns current selection.

Read-only at run time. Not available at design time.

Syntax

object.Selection As IsgSelection

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Selection property returns an SGSelection object. The SGSelection object represents current selection and methods to manipulate selection ranges.

The BeeGrid keeps track of current selection as a collection of rectangular areas (ranges). Each range is represented by one SGRange object. The SGSelection object contains a collection of SGRange objects and implements methods for manipulating and querying that ranges.

Show Example
Copy Code [image] Show Me

Private Sub Form_Load()
   SGGrid1.SelectionMode = sgSelectionByRow
   SGGrid1.MultiSelect = sgMultiSelectExtended
   SGGrid1.SpecialMode = sgModeListBox
End Sub

Back to topic


SelectionMode Property (SGSelection Object)

SelectionMode Property
Returns or sets selection mode.

Read/Write at run time and design time.

Syntax

object.SelectionMode As sgSelectionMode

The object placeholder represents an object expression that evaluates to SGSelection and SGGrid objects.

Settings

The SelectionMode settings are:
Name | Value | Description
sgSelectionNone | 0 | No selections.
sgSelectionFree | 1 | Select only rectangular cell area.
sgSelectionByRow | 2 | Select only rows.
sgSelectionByColumn | 3 | Select only columns.
sgSelectionByRowAndColumn | 4 | Select both rows and columns.
sgSelectionModeAll | 5 | Enable all selection modes.

Remarks

Returns or sets a value indicating whether a user can select rows, columns or cells and how the selections can be made.

This property is a shortcut to the SelectionMode member of the SGSelection object.

Show Example
Copy Code [image] Show Me

Private Sub Form_Load()
   SGGrid1.SelectionMode = sgSelectionByRow
   SGGrid1.MultiSelect = sgMultiSelectExtended
   SGGrid1.SpecialMode = sgModeListBox
End Sub

Back to topic


SimpleDataSource Property

SimpleDataSource Property
Returns or sets custom data source used by VirtualInterface data mode.

Read/Write at run time. Not available at design time.

Syntax

object.SimpleDataSource As IsgGridDataSource

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

When the grid works in sgVirtualInterface mode, the SimpleDataSource property must be assigned to an object that implements IsgGridDataSource interface. The IsgGridDataSource interface has these methods:

  • AddRow Called when a new row should be added the data source.
  • DeleteRow Called when a row should be deleted from the data source.
  • GetRowCount Returns number of rows provided by the data source implementation.
  • GetRowData Called to retrieve data for the specified row.
  • SetRowData Called to modify row's data.

Show Example
Copy Code [image] Show Me

The following example feeds the grid width data through the IsgGridDataSource interface. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Implements IsgGridDataSource

Private mlRowsCount As Long
Private marBuf() As Variant

Private Function IsgGridDataSource_AddRow _
   (ByVal RowIndex As Long, ByVal ColCount As Long, _
   ByVal RowData As Variant) As Boolean
   Dim i As Integer
   'Add new row
   mlRowsCount = mlRowsCount + 1
   If mlRowsCount > UBound(marBuf, 2) Then
      ReDim Preserve marBuf _
         (UBound(marBuf, 1), mlRowsCount + 30) As Variant
   End If

   For i = 0 To ColCount - 1
      marBuf(i, mlRowsCount - 1) = RowData(i)
   Next
   'Row has been added
   IsgGridDataSource_AddRow = True
End Function

Private Function IsgGridDataSource_DeleteRow(ByVal RowIndex As Long) As Boolean
   Dim i As Long, j As Integer
   'Shift rows below deleted one
   For i = RowIndex + 1 To mlRowsCount - 1
      For j = 0 To UBound(marBuf, 1)
         marBuf(j, i - 1) = marBuf(j, i)
      Next
   Next
   'Decrese row count
   mlRowsCount = mlRowsCount - 1
   'Row has been deleted
   IsgGridDataSource_DeleteRow = True
End Function

Private Function IsgGridDataSource_GetRowCount() As Long
   IsgGridDataSource_GetRowCount = mlRowsCount
End Function

Private Sub IsgGridDataSource_GetRowData _
   (ByVal RowIndex As Long, ByVal ColCount As Long, _
   RowData As Variant)
   Dim i As Integer

   For i = 0 To ColCount - 1
      RowData(i) = marBuf(i, RowIndex)
   Next
End Sub

Private Sub IsgGridDataSource_SetRowData _
   (ByVal RowIndex As Long, ByVal ColCount As Long, _
   ByVal RowData As Variant)
   Dim i As Integer

   For i = 0 To ColCount - 1
      marBuf(i, RowIndex) = RowData(i)
   Next
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      mlRowsCount = 0
      .EnterKeyBehavior = sgEnterKeyColumns
      ReDim marBuf(2, 30) As Variant
      .AllowAddNew = True
      .AllowDelete = True
      Set .SimpleDataSource = Me
      .DataMode = sgVirtualInterface
      .DataRowCount = 0
   End With
End Sub

Back to topic


SkipReadOnly Property

SkipReadOnly Property
Returns or sets a value indicating whether read only cells can receive focus.

Read/Write at run time and design time.

Syntax

object.SkipReadOnly As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

If the SkipReadOnly property is set to True, read-only cell can not be focused. Use this property to speed up data input.

Show Example
Copy Code [image] Show Me

The following example uses the FetchColumnData event to multiply first two columns and to display result in the unbound column. The property SkipReadOnly is set to True to speed up data entering. The example uses the KeyPressEdit event to restricts data entry to numeric values. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 3
   SGGrid1.AllowAddNew = True

   With SGGrid1.Columns.At(3)
      .DBField = ""  'unbound column
      .ReadOnly = True
      .Caption = "Col1 * Col2"
   End With
   'add some data
   SGGrid1.Array.Value(0, 0) = 2
   SGGrid1.Array.Value(0, 1) = 3

   SGGrid1.GroupByBoxVisible = False
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.SkipReadOnly = True
End Sub

Private Sub SGGrid1_FetchColumnData _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal RowBookmark As Variant, Value As Variant)
   Dim ar As SGArray
   Dim lRowDataIndex As Long

   Set ar = SGGrid1.Array
   'use first and second cols get value for the unbound col
   lRowDataIndex = SGGrid1.Rows(RowKey).DataIndex
   Value = ar.Value(lRowDataIndex, 0) * ar.Value(lRowDataIndex, 1)
End Sub

Private Sub SGGrid1_KeyPressEdit(ByVal RowKey As Long, _
    ByVal ColIndex As Long, keyASCII As Integer)

    'allow back space
    if keyASCII = vbKeyBack Then Exit Sub

    If keyASCII < vbKey0 Or keyASCII > vbKey9 Then
        keyASCII = 0
    End if
End Sub

Back to topic


SpecialMode Property

SpecialMode Property
Returns or sets special operating mode.

Read/Write at run time and design time.

Syntax

object.SpecialMode As sgSpecialMode

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The SpecialMode settings are:

Name | Value | Description
sgModeNone | 0 | Grid is in the standard mode.
sgModeListBox | 1 | Grid is in the listbox mode.

Remarks

Use the SpecialMode property to simulate standard list box.

Show Example
Copy Code [image] Show Me

Private Sub Form_Load()
   SGGrid1.SelectionMode = sgSelectionByRow
   SGGrid1.MultiSelect = sgMultiSelectExtended
   SGGrid1.SpecialMode = sgModeListBox
End Sub

Back to topic


Styles Property

Styles Property
Returns a collection of SGStyle objects.

Read-only at run time. Not available at design time.

Syntax

object.Styles As IsgStyles

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Styles property returns a collection of named SGStyle objects. Each element in this collection represents one style. The BeeGrid control uses styles to simplify customization of grid's appearance. There are several predefined styles that can not be removed but their properties can be changed. The predefined styles are: Normal, Heading, Selection, InactiveSelection, GroupHeader, GroupFooter, Tip, CurrentRow, CurrentCell, FilteredRow, Caption, Frozen and PreviewPane.

Each style in the collection can be accessed by its name.

For example, to access the "Caption" style use following syntax:

SGGrid.Styles("Caption")

For more information, see the SGStyles object overview.

Show Example
Copy Code [image] Show Me

The following example uses the Styles collection to access each style. It fills the grid with style properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sty As SGStyle, i As Integer
   Dim lRow As Long

   With SGGrid1
      .RedrawEnabled = False

      .Columns.RemoveAll True

      .DataColCount = 22
      .DataRowCount = .Styles.Count
      'create columns with style properties
      .Columns(1).Caption = "Style Name"
      .Columns(2).Caption = "Backcolor"
      .Columns(3).Caption = "Forecolor"
      .Columns(4).Caption = "Base Style"
      .Columns(5).Caption = "Font name"
      .Columns(6).Caption = "Font size"
      .Columns(6).Style.TextAlignment = sgAlignRightCenter
      For i = 7 To 10
         .Columns(i).Caption = _
            Choose(i - 6, "Bold", "Italic", "Underline", "Strikethrough")
         .Columns(i).Control.Type = sgCellCheckBox
         .Columns(i).Style.TextAlignment = sgAlignCenterCenter
         .HeadingTextAlignment = sgAlignCenterCenter
      Next
      .Columns(11).Caption = "Format"
      .Columns(12).Caption = "Appearance"
      With .Columns(12).ValueItems
         .Add 1, "3D"       'sg3D
         .Add 2, "3D Light"  'sg3DLight
      End With
      .Columns(13).Caption = "DisplayType"
      .Columns(13).ValueItems.Add 0, "Text"     'sgDisplayText
      .Columns(14).Caption = "TextAlignment"
      With .Columns(14).ValueItems
         .Add 0, "General"             'sgAlignGeneral
         .Add 4, "Left-Center"       'sgAlignLeftCenter
         .Add 5, "Center-Center"       'sgAlignCenterCenter
      End With
      .Columns(15).Caption = "PictureAlignment"
      .Columns(15).ValueItems.Add 3, "Left-Center"     'sgPicAlignLeftCenter
      .Columns(16).Caption = "Padding"
      .Columns(17).Caption = "WordWrap"
      .Columns(17).Control.Type = sgCellCheckBox
      .Columns(17).Style.TextAlignment = sgAlignCenterCenter
      .Columns(18).Caption = "Ellipsis"
      .Columns(18).ValueItems.Add 1, "Ellipsis End"     'sgEllipsisEnd
      .Columns(19).Caption = "Borders"
      With .Columns(19).ValueItems
         .Add 15, "All"       'sgCellBorderAll
         .Add 0, "No Border"  'sgCellNoBorder
      End With
      .Columns(20).Caption = "Border Color"
      .Columns(21).Caption = "Border Size"
      .Columns(22).Caption = "Border Style"
      With .Columns(22).ValueItems
         .Add 1, "Solid"      'sgCellBorderSolid
      End With
   End With
   'enum styles end show values for each property
   For Each sty In SGGrid1.Styles
      lRow = lRow + 1
      With SGGrid1.Rows.At(lRow)
         .Cells(0).Value = sty.Name
         .Cells(1).Style.BackColor = sty.BackColor
         .Cells(2).Style.BackColor = sty.ForeColor
         .Cells(3).Value = sty.BaseStyle
         .Cells(4).Value = sty.Font.Name
         .Cells(5).Value = sty.Font.Size
         .Cells(6).Value = sty.Font.Bold
         .Cells(7).Value = sty.Font.Italic
         .Cells(8).Value = sty.Font.Underline
         .Cells(9).Value = sty.Font.Strikethrough
         .Cells(10).Value = sty.Format
         .Cells(11).Value = sty.Appearance
         .Cells(12).Value = sty.DisplayType
         .Cells(13).Value = sty.TextAlignment
         .Cells(14).Value = sty.PictureAlignment
         .Cells(15).Value = sty.Padding
         .Cells(16).Value = sty.WordWrap
         .Cells(17).Value = sty.Ellipsis
         .Cells(18).Value = sty.Borders
         .Cells(19).Style.BackColor = sty.BorderColor
         .Cells(20).Value = sty.BorderSize
         .Cells(21).Value = sty.BorderStyle
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


TabKeyBehavior Property

TabKeyBehavior Property
Returns or sets TAB key behavior.

Read/Write at run time and design time.

Syntax

object.TabKeyBehavior As sgTabKeyBehavior

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The TabKeyBehavior settings are:

Name | Value | Description
sgTabControls | 0 | TAB key jumps over controls on the form.
sgTabColumns | 1 | TAB key jumps to next focusable column.
sgTabRows | 2 | TAB key jumps to next focusable row.

Remarks

The TabKeyBehavior property determines how the grid will respond when user presses the TAB key. The grid can take one of these actions: pass key to the container (default), move focus to the next column or move focus to the next row.

Use the NavigationWrapMode property to determine behavior of the tab key at row/col boundaries.

Show Example
Copy Code [image] Show Me

The following example changes the TabKeyBehaviorfocus to sgTabControls when the user press the tab key in the last cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_GotFocus()
   SGGrid1.TabKeyBehavior = sgTabColumns
End Sub

Private Sub SGGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyTab Then
      If SGGrid1.Col = SGGrid1.ColCount - 1 And _
         SGGrid1.Row = SGGrid1.RowCount - 1 Then
         SGGrid1.Col = 1
         SGGrid1.Row = 1
         SGGrid1.TabKeyBehavior = sgTabControls
      End If
   End If
End Sub

Back to topic


Text Property

Text Property
Returns the current cell's underlying data value as formatted text

Read-only at run time. Not available at design time.

Syntax

object.Text As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Show Example
Copy Code [image] Show Me

The following example shows difference between the Text and Value property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   SGGrid1.CurrentCell.Value = 3123
   SGGrid1.CurrentCell.Style.Format = "Currency"
   SGGrid1.Redraw

   MsgBox "This is the Text property: " _
      & SGGrid1.Text & vbCrLf _
      & "This is the Value property: " _
      & SGGrid1.Value
End Sub

Back to topic


TextAlignment Property

TextAlignment Property
Returns or sets text alignment style.

Read/Write at run time and design time.

Syntax

object.TextAlignment As sgAlignment

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The TextAlignment settings are:

Name | Value | Description
sgAlignGeneral | 0 | Alignment is based on the underlying data type.
sgAlignLeftTop | 1 | Align to the left-top position.
sgAlignCenterTop | 2 | Align to the center-top position.
sgAlignRightTop | 3 | Align to the right-top position.
sgAlignLeftCenter | 4 | Align to the left-center position.
sgAlignCenterCenter | 5 | Align to the center-center position.
sgAlignRightCenter | 6 | Align to the right-center position.
sgAlignLeftBottom | 7 | Align to the left-bottom position.
sgAlignCenterBottom | 8 | Align to the center-bottom position.
sgAlignRightBottom | 9 | Align to the right-bottom position.

Remarks

This property is a shortcut to the TextAlignment member of the "Normal" style.

The following lines have the same effect:

SGGrid1.TextAlignment = sgAlignCenterCenter

- or -

SGGrid1.Styles("Normal").TextAlignment = sgAlignCenterCenter
SGGrid1.Redraw

If the property WordWrap is set to true then the vertical alignment is always top. For example, values sgAlignLeftTop, sgAlignLeftCenter and sgAlignLeftBottom have same effect (as sgAlignLeftTop.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the TextAlignment property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.HeadingTextAlignment = sgAlignCenterCenter
   SGGrid1.TextAlignment = sgAlignRightTop

   SGGrid1.CurrentCell.Column.Caption = "Caption"
   SGGrid1.CurrentCell.Value = "Text"

End Sub

Back to topic


TopRow Property

TopRow Property
Returns or sets top-most visible row (zero-based).

Read/Write at run time. Not available at design time.

Syntax

object.TopRow As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Show Example
Copy Code [image] Show Me

The following example scrolls the contents of the grid for all visible rows. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   If SGGrid1.TopRow = SGGrid1.BottomRow Then
      SGGrid1.TopRow = 0
   Else
      SGGrid1.TopRow = SGGrid1.BottomRow
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim col As SGColumn

   SGGrid1.RowNumbering = True

   SGGrid1.DataColCount = 50
   SGGrid1.DataRowCount = 100

   For Each col In SGGrid1.Columns
      col.Caption = col.Key
   Next
End Sub

Back to topic


UserDragging Property

UserDragging Property
Returns or sets a value indicating whether the user is allowed to drag rows and columns with the mouse.

Read/Write at run time and design time.

Syntax

object.UserDragging As sgUserRowColDrag

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The UserDragging settings are:

Name | Value | Description
sgNoRowColDrag | 0 | User can not drag rows and columns.
sgAllowRowDrag | 1 | User can drag rows.
sgAllowColDrag | 2 | User can drag columns.
sgAllowRowColDrag | 3 | User can drag both rows and columns.

Remarks

The UserDragging property allows or disallows the user to drag columns and rows with the mouse.

Show Example
Copy Code [image] Show Me

The following example shows how to use the ComboBox to change the UserDragging property.

Private Sub Combo1_Click()
   If Combo1.ListIndex = -1 Then Exit Sub

   SGGrid1.UserDragging = Combo1.ListIndex
End Sub

Back to topic


UserHiding Property

UserHiding Property
Returns or sets a value indicating whether the user is allowed to hide rows and columns with the mouse.

Read/Write at run time and design time.

Syntax

object.UserHiding As sgUserRowColHide

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The UserHiding settings are:

Name | Value | Description
sgNoRowColHide | 0 | User can not hide rows and columns.
sgAllowRowHide | 1 | User can hide rows.
sgAllowColHide | 2 | User can hide columns.
sgAllowRowColHide | 3 | User can hide both rows and columns.

Remarks

The UserHiding property allows or disallows the user to hide columns and rows with the mouse.

When the user hides column, the ColHide event occurs. Similarly, when the user hides row, the event RowHide occurs.

Show Example
Copy Code [image] Show Me

The following example shows how to use the ComboBox to change the UserHiding property.

Private Sub Combo1_Click()
   If Combo1.ListIndex = -1 Then Exit Sub

   SGGrid1.UserHiding = Combo1.ListIndex
End Sub

Back to topic


UserResizeAnimate Property

UserResizeAnimate Property
Returns or sets a value indicating row/column resize feedback.

Read/Write at run time and design time.

Syntax

object.UserResizeAnimate As sgResizeAnimation

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The UserResizeAnimate settings are:

Name | Value | Description
sgNoResizeAnimation | 0 | No animation while user resizes rows and columns.
sgAnimateHeadings | 1 | Animate headings.
sgAnimateRowsColumns | 2 | Animate headings and cells.

Remarks

This property has no effect if the UserResizing property is set to sgNoUserResizing.

Show Example
Copy Code [image] Show Me

The following example uses the first column header to change the UserResizeAnimate property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Click on the first column header to change the UserResizeAnimate property. Resize rows and columns to see how it works.

Private Sub SGGrid1_OnInit()
   SGGrid1_ColHeadClick 1
End Sub

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   If ColIndex = 1 Then
      If SGGrid1.UserResizeAnimate = _
         sgAnimateRowsColumns Then
         SGGrid1.UserResizeAnimate = sgNoResizeAnimation
      Else
         SGGrid1.UserResizeAnimate = _
            SGGrid1.UserResizeAnimate + 1
      End If

      SGGrid1.Columns(1).Caption = _
         Choose(SGGrid1.UserResizeAnimate + 1, _
            "sgNoResizeAnimation", "sgAnimateHeadings", _
            "sgAnimateRowsColumns")
   End If

End Sub

Back to topic


UserResizing Property

UserResizing Property
Returns or sets whether the user is allowed to resize rows and columns with the mouse.

Read/Write at run time and design time.

Syntax

object.UserResizing As sgUserResizing

The object placeholder represents an object expression that evaluates to the SGGrid object.

Settings

The UserResizing settings are:

Name | Value | Description
sgNoUserResizing | 0 | User can not resize rows and columns.
sgAllowRowResizing | 1 | User can resize rows.
sgAllowColResizing | 2 | User can resize columns.
sgAllowRowColResizing | 3 | User can resize both rows and columns.

Remarks

The UserResizing property allows or disallows the user to resize columns and rows with the mouse.

When the user resizes column, the ColResize event occurs. Similarly, when the user resizes row, the event RowResize occurs.

Show Example
Copy Code [image] Show Me

The following example shows how to use the ComboBox to change the UserResizing property.

Private Sub Combo1_Click()
   If Combo1.ListIndex = -1 Then Exit Sub

   SGGrid1.UserResizing = Combo1.ListIndex
End Sub

Back to topic


VScrollWidth Property

VScrollWidth Property
Returns or sets width of the vertical scroll bar.

Read/Write at run time and design time.

Syntax

object.VScrollWidth As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Setting the VScrollWidth property to zero, indicates that grid should use windows default width. Width is expressed in the container's coordinate system.

Default value for this property is zero.

Show Example
Copy Code [image] Show Me

The following example makes the grid look like the ListBox. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim i As Integer
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False

   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0

   SGGrid1.Move 0, 0, 1515, 3000
   SGGrid1.Appearance = sgFlat
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.BackColor = SGGrid1.CellBackColor
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.AllowEdit = False
   'fill grid with test data
   SGGrid1.DataColCount = 1
   SGGrid1.DataRowCount = 100

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 0) = "Item nr. " & Trim(i)
   Next
   'set scroll bar properties
   SGGrid1.ScrollBarTrack = True
   SGGrid1.ScrollBarTips = sgScrollTipsVertical
   SGGrid1.ScrollTipColumn = SGGrid1.Columns(1).Key
   SGGrid1.VScrollWidth = SGGrid1.ClientWidth / 8
   SGGrid1.ScrollBars = sgSBVertical

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True

End Sub

Back to topic


Value Property

Value Property
Returns or sets the current cell underlying data value.

Read/Write at run time. Not available at design time.

Syntax

object.Value As Variant

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Value property can be used to get and set the current cell's underlying data value.

Use the Text property to get value as formatted text.

Show Example
Copy Code [image] Show Me

The following example shows difference between the Text and Value property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   SGGrid1.CurrentCell.Value = 3123
   SGGrid1.CurrentCell.Style.Format = "Currency"
   SGGrid1.Redraw

   MsgBox "This is the Text property: " _
      & SGGrid1.Text & vbCrLf _
      & "This is the Value property: " _
      & SGGrid1.Value
End Sub

Back to topic


ValueEx Property

ValueEx Property
Returns or sets cell's underlying data value.

Read/Write at run time. Not available at design time.

Syntax

object.ValueEx As Variant

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

See Also

SGGrid


Version Property

Version Property
Returns string representing BeeGrid's version info.
Read-only at run time and design time. Syntax

object.Version As String

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

Show Example
Copy Code [image] Show Me

Private Sub SGGrid1_OnInit()
   SGGrid1.Caption = SGGrid1.Version
End Sub

Back to topic


VisibleCols Property

VisibleCols Property
Returns the number of visible columns.

Read-only at run time. Not available at design time.

Syntax

object.VisibleCols As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property returns the number of visible columns. Heading columns and frozen columns are not counted.

Show Example
Copy Code [image] Show Me

The following example prevents the user from resizing a column if at least 3 columns are not visible. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_ColResize( _
   ByVal ColIndex As Long, cancelResize As Boolean)
   cancelResize = (SGGrid1.VisibleCols < 4)
End Sub

Back to topic


VisibleRows Property

VisibleRows Property
Returns the number of visible rows.

Read-only at run time. Not available at design time.

Syntax

object.VisibleRows As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property returns the number of visible rows. Heading rows and frozen rows are not counted.

Show Example
Copy Code [image] Show Me

The following example prevents the user from resizing a row if at least 3 rows are not visible. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_RowResize( _
   ByVal rowKey As Long, cancelResize As Boolean)
   cancelResize = (SGGrid1.VisibleRows < 7)
End Sub

Back to topic


Window Property

Window Property

Read-only at run time. Not available at design time.

Syntax

object.Window As Long

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

The Window property is used with Windows API calls. Because the value of this property can change while a program is running, never store the window handle in a variable.

Show Example
Copy Code [image] Show Me

The following example draws the small grids inside the grid. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Declare Function GetDC Lib "user32" _
    (ByVal hwnd As Long) As Long

Private Declare Function StretchBlt Lib "gdi32" _
    (ByVal hDC As Long, ByVal x As Long, _
    ByVal y As Long, ByVal nWidth As Long, _
    ByVal nHeight As Long, ByVal hSrcDC As Long, _
    ByVal xSrc As Long, ByVal ySrc As Long, _
    ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, _
    ByVal dwRop As Long) As Long

Private Sub Command1_Click()
   Dim hDC As Long, i As Integer
   Dim lWidth As Long, lHeight As Long
    Const SRCCOPY = &HCC0020

   hDC = GetDC(SGGrid1.Window)

   lWidth = SGGrid1.Width / Screen.TwipsPerPixelX
   lHeight = SGGrid1.Height / Screen.TwipsPerPixelY

   For i = 2 To 10
      StretchBlt hDC, lWidth / 2 - (lWidth / (i * 2)), _
         lHeight / 2 - (lHeight / (i * 2)), lWidth / i, lHeight / i, _
         hDC, 0, 0, lWidth, lHeight, SRCCOPY
   Next
End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 10
   SGGrid1.DataRowCount = 100
End Sub

Back to topic


WordWrap Property

WordWrap Property
Enables or disables word wrapping for cell text.

Read/Write at run time and design time.

Syntax

object.WordWrap As Boolean

The object placeholder represents an object expression that evaluates to the SGGrid object.

Remarks

This property is a shortcut to the WordWrap property of the "Normal" style.

Show Example
Copy Code [image] Show Me

The following example sets the WordWrap property to the grid and heading. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   SGGrid1.WordWrap = True
   SGGrid1.HeadingWordWrap = True

   SGGrid1.Columns.At(1).Caption = "The little red caption"

   SGGrid1.Rows.At(0).Height = 505
   SGGrid1.Rows.At(1).Height = 505

   SGGrid1.Array.Value(0, 0) = "This is long dong text."
End Sub

Back to topic


SGGrid Methods

AboutBox | Displays the version info and copyright notice for the BeeGrid control.
AutoSizeColumns | Resize columns to fit cell content.
AutoSizeRows | Resize rows to fit cell content.
CollapseAll | Collapses all groups.
CollapseRow | Collapses specified row.
CreateRange | Creates new range object and returns a reference to the newly created object.
Delete | Deletes the current record.
EnsureCellVisible | Ensures that specified cell is visible.
ExpandAll | Expands all groups.
ExpandRow | Expands specified row.
ExportDataString | Exports grid data to a string.
ExportData | Exports grid data to a file.
ExportHTMLString | Exports grid as an HTML table to a string.
ExportHTML | Exports grid as an HTML table to a file.
GetLayoutString | Returns grid layout in a string.
HitTestEx | Returns hit test code for given coordinates.
HitTestObject | Returns hit test code for given coordinates and top-most object under that coordinates.
HitTest | Returns hit test code for given coordinates.
ImportDataString | Imports data from a string.
ImportData | Imports data from a file.
KeyBookmark | Returns bookmark for row with specified key.
LoadAllRecords | Loads all records from the data source.
LoadArray | Loads the grid with data from an array.
LoadLayoutFromFile | Loads grid layout from a file.
LoadLayoutFromURL | Loads grid layout from an URL.
LoadLayoutString | Loads grid layout from a string.
MoveFirst | Moves the current record to the first one.
MoveLast | Moves the current record to the last one.
MoveNext | Moves the current record to the next one.
MovePrevious | Moves the current record to the previous one.
MoveRelative | Moves the current record offset rows relative to the current or specified row.
MoveToRowKey | Moves the current record to the specified row.
OLEDrag | Initiates an OLE drag/drop operation.
PostMessage | Posts the message for later processing.
ReBind | Re-establishes the connection with the bound data source.
RedrawCell | Redraws specified cell.
RedrawCol | Redraws specified column.
RedrawRow | Redraws specified row.
Redraw | Redraws specified grid area.
RefetchRow | Reloads specified row from a data source.
RefreshGroups | Forces a recalculation of groups in a grid control.
RowBookmark | Returns bookmark identifying row at specified position.
Scroll | Scrolls grid for a specified number of rows and columns.
Sort | Sorts specified rows and columns.
Update | Write data from the current row to the underlying database.


AboutBox Method

AboutBox Method
Displays the version info and copyright notice for the BeeGrid control.
Syntax | object.AboutBox
Return Value | None
Arguments | None

Remarks

In design time, you can run the AboutBox from the Property window. Use the AboutBox to order BeeGrid, send bug report or suggest a new feature.


AutoSizeColumns Method

AutoSizeColumns Method
Resize columns to fit cell content.
Syntax

object.AutoSizeColumns(FirstColPos As Long, LastColPos As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
FirstColPos | A Long expression that represents the position of the first column in a range.
LastColPos | A Long expression that represents the position of the last column in a range.

Remarks

The AutoSizeColumns method resizes columns widths to fit cell content.

Show Example
Copy Code [image] Show Me

The following example automatically sizes all columns in the grid.

Private Sub Command1_Click()

   SGGrid1.AutoSizeColumns SGGrid1.HeadingColCount, SGGrid1.Columns.Count - 1

End Sub

Back to topic


CancelEdit Method

CancelEdit Method
Cancels current row editing and restores its original values.
Syntax | object.CancelEdit
Return Value | None
Arguments | None

Remarks

Use the CancelEdit method to cancel current row edit operation. When this method is called, all changes to the current row are canceled and row data is restored to its original values. Note that underlying data source is not queried for the row data. Instead, values from the grid's internal cache are used.


AutoSizeRows Method

AutoSizeRows Method
Resize rows to fit cell content.
Syntax

object.AutoSizeRows(FirstRowPos As Long, LastRowPos As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
FirstRowPos | A Long expression that represents the position of the first row in a range.
LastRowPos | A Long expression that represents the position of the last row in a range.

Remarks

The AutoSizeRows method resizes rows heights to fit cell content.


CollapseAll Method

CollapseAll Method
Collapses all groups.
Syntax | object.CollapseAll
Return Value | None
Arguments | None

Remarks

The CollapseAll method has effect only if the grid is grouped.

Show Example
Copy Code [image] Show Me

The following example shows how to use the CollapseAll method.

Private Sub Command1_Click()

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


CollapseRow Method

CollapseRow Method
Collapses specified row.
Syntax

object.CollapseRow(RowKey As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowKey | Key of the group header row that will be collapsed.

Remarks

The CollapseRow method works only for the group heading rows. You can use the SGRow object's Type property to check out row's type.

Show Example
Copy Code [image] Show Me

The following example collapses the even Group Headers.

Private Sub Command1_Click()
   Dim gh As SGGroupHeading
   Dim i As Integer

   SGGrid1.RedrawEnabled = False

   For Each gh In SGGrid1.GroupHeadings
      If i Mod 2 Then SGGrid1.CollapseRow gh.row.Key
      i = i + 1
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


CreateRange Method

CreateRange Method
Creates new range object and returns a reference to the newly created object.
Syntax

object.CreateRange(Type As sgRangeType, Left As Long, Top As Long, Right As Long, Bottom As Long)

Return Value A SGRange object.
Arguments
object | An object expression that evaluates to the SGGrid object.
Type | An sgRangeType expression that specifies type of the range. The possible values are listed in Settings.
Left | A Long expression that sets the zero-based position of the leftmost column in the range. This argument is ignored if argument Type is set to sgRangeRow.
Top | A Long expression that sets the zero-based position of the top row in the range. This argument is ignored if argument Type is set to sgRangeColumn.
Right | A Long expression that sets the zero-based position of the right column in the range. This argument is ignored if argument Type is set to sgRangeRow.
Bottom | A Long expression that sets the zero-based position of the bottom row in the range. This argument is ignored if argument Type is set to sgRangeColumn.

Settings

The settings for Type are:

Name | Value | Description
sgRangeFree | 0 | Range contains one rectangular cell area.
sgRangeRow | 1 | Range contains one or more successive rows.
sgRangeColumn | 2 | Range contains one or more successive columns.

Remarks

This method returns a reference to the newly created SGRange object.

Show Example
Copy Code [image] Show Me

The following example fills grid with the sample data. It creates regions of four cells and applies different styles to them. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False

   SGGrid1.DataColCount = 20
   SGGrid1.DataRowCount = 20
   SGGrid1.GroupByBoxVisible = False

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataColCount - 1
      For j = 0 To SGGrid1.DataRowCount - 1
         ar.Value(j, i) = "Row: " & Trim(j + 1) & " Col: " & Trim(i + 1)
      Next
   Next

   Set ar = Nothing

   With SGGrid1.Styles.Add("Black")
      .BaseStyle = "Normal"
      .BackColor = vbBlack
      .ForeColor = vbWhite
   End With

   For i = 1 To SGGrid1.DataColCount / 2
      For j = 1 To SGGrid1.DataRowCount / 2
         With SGGrid1.CreateRange _
            (sgRangeFree, i * 2 - 1, j * 2 - 1, i * 2, j * 2)
            If i Mod 2 Xor j Mod 2 Then
               .ApplyStyle "Black"
            Else
               .ApplyStyle "Normal"
            End If
         End With
      Next
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


Delete Method

Delete Method
Deletes the current record.
Syntax | object.Delete
Return Value | None
Arguments | None

Remarks

The method Delete deletes the current record.

See Also

SGGrid


EnsureCellVisible Method

EnsureCellVisible Method
Ensures that specified cell is visible.
Syntax

object.EnsureCellVisible(RowKey As Long, ColKey As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowKey | A Long that represents the Key of the row.
ColKey | A String expression that represents the Key of the column.

Remarks

Typically, use this method after searching.

Show Example
Copy Code [image] Show Me

The following example uses the first row as Filter Bar. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Enter the criteria in the first row, then press the Enter key or click a column's header.

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   Dim sColKey As String, lRowKey As Long
   Dim vValue As Variant, row As SGRow
   Dim lStartRowPos As Long
   'get coland row keys
   sColKey = SGGrid1.Columns(ColIndex).Key
   lRowKey = SGGrid1.Rows.At(1).Key
   'get the first row value
   vValue = SGGrid1.Cell(lRowKey, sColKey).Value
   'check out if the top row is the last one
   If SGGrid1.TopRow + 1 = SGGrid1.RowCount Then
      lStartRowPos = 1
   Else
      lStartRowPos = SGGrid1.TopRow + 1
   End If
   'try to find row using value from the first row
   If ColIndex = 1 Then
      Set row = SGGrid1.Rows.Find(sColKey, sgOpContains, vValue, , lStartRowPos)
   Else
      Set row = SGGrid1.Rows.Find(sColKey, sgOpEqual, vValue, , lStartRowPos)
   End If

   If row Is Nothing Then
      'there is not row meets the criteria
      SGGrid1.TopRow = 1
   Else
      'there is row meets the criteria so move it on the top
      SGGrid1.TopRow = row.Position
      Set row = Nothing
   End If
End Sub

Private Sub SGGrid1_KeyPressEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   KeyASCII As Integer)
   'exit cell-editing mode on the return key
   If KeyASCII = vbKeyReturn And SGGrid1.row = 1 Then _
      SGGrid1.Editing = False
End Sub

Private Sub SGGrid1_KeyUp(KeyCode As Integer, Shift As Integer)
   'use the return key to find row
   If KeyCode = vbKeyReturn And SGGrid1.row = 1 Then _
      SGGrid1_ColHeadClick SGGrid1.Columns.Current.ColIndex
End Sub

Private Sub SGGrid1_OnInit()
   Dim sFile As String
   Dim sgCol As SGColumn
   Dim sWinDir As String
   Dim i As Integer
   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   'remove all columns
   SGGrid1.Columns.RemoveAll False
   SGGrid1.RowNumbering = True
   'use tab key to navigate columns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.NavigationWrapMode = sgNavigationWrapSame
   'Column creations
   SGGrid1.Columns.Add "File"
   Set sgCol = SGGrid1.Columns.Add("FileDate")
   sgCol.DataType = sgtDateTime
   sgCol.SortType = sgSortTypeDateTime
   Set sgCol = SGGrid1.Columns.Add("Size")
   sgCol.DataType = sgtLong

   sWinDir = Environ("WINDIR") & "\"
   i = 1
   sFile = Dir(sWinDir & "*.*", vbNormal)
   'add files to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(1).Value = sFile
      SGGrid1.Rows.At(i).Cells(2).Value = _
         FormatDateTime(FileDateTime(sWinDir & sFile), vbShortDate)
      SGGrid1.Rows.At(i).Cells(3).Value = FileLen(sWinDir & sFile)
      sFile = Dir
   Loop

   SGGrid1.Rows.At(1).Frozen = True
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

See Also

SGGrid


ExpandAll Method

ExpandAll Method
Expands all groups.
Syntax

object.ExpandAll([Levels = -1] As Integer)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
Levels | Optional. An Integer expression that specifies the number of levels to expand. Default value is -1 which expands all levels.

Remarks

The ExpandAll method has effect only if the grid is grouped.

Show Example
Copy Code [image] Show Me

The following example collapses all groups and then expands the first group.

Private Sub Command1_Click()

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll
   SGGrid1.ExpandAll 1

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


ExpandRow Method

ExpandRow Method
Expands specified row.
Syntax

object.ExpandRow(RowKey As Long, [Levels = -1] As Integer)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowKey | A Long that represents the Key of the row.
Levels | Optional. An Integer expression that specifies the number of levels to expand. Default value is -1, which expands all levels.

Remarks

The ExpandAll method has effect only if the grid is grouped.

Show Example
Copy Code [image] Show Me

The following example expands the odd Group Headers.

Private Sub Command1_Click()
   Dim gh As SGGroupHeading
   Dim i As Integer

   SGGrid1.RedrawEnabled = False

   SGGrid1.CollapseAll

   For Each gh In SGGrid1.GroupHeadings
      i = i + 1
      If i Mod 2 Then SGGrid1.ExpandRow gh.row.Key, 1
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


ExportData Method

ExportData Method
Exports grid data to a file.
Syntax

object.ExportData(FilePath As String, DataFormat As sgDataFormat, [Flags = sgExportDefault] As sgExportFlag, [CellSeparator = ","] As String, [RowSeparator = ""] As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
FilePath | A String expression that indicates the name of the file to be saved.
DataFormat | An sgDataFormat expression that specifies the data format. The possible values are listed in Settings.
Flags | Optional. An sgExportFlag expression that sets options for a data export. Default value is sgExportDefault. The possible values are listed in Settings.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Default value is ",". Used only if the DataFormat is sgFormatCharSeparatedValue.
RowSeparator | Optional. A String expression that sets delimiter used between rows. Default value is an empty string which is interpreted as a line separator (vbCrLf). Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for Flags are:

Name | Value | Description
sgExportDefault | 0 | Use default export flags.
sgExportCurrentRowOnly | 1 | Export current row only.
sgExportFieldNames | 2 | Export field names.
sgExportRowsOnly | 4 | Export only data rows.
sgExportHidden | 8 | Hidden columns will appear in exported data.
sgExportOverwrite | 16 | Replace file if it already exists.
sgExportAppend | 32 | Append to file if it already exists.
The settings for DataFormat are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

If DataFormat is sgFormatXML, columns that do not have the DBField specified are not exported.

See Also

SGGrid


ExportDataString Method

ExportDataString Method
Exports grid data to a string.
Syntax

object.ExportDataString(DataFormat As sgDataFormat, [Flags = sgExportDefault] As sgExportFlag, [CellSeparator = ","] As String, [RowSeparator = ""] As String)

Return Value A String value containing the grid's data.
Arguments
object | An object expression that evaluates to the SGGrid object.
DataFormat | An sgDataFormat expression that specifies the data format. The possible values are listed in Settings.
Flags | Optional. An sgExportFlag expression that sets options for a data export. Default value is sgExportDefault. The possible values are listed in Settings. Optional.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Default value is ",". Used only if the DataFormat is sgFormatCharSeparatedValue.
RowSeparator | Optional. A String expression that sets delimiter used between rows. Default value is an empty string which is interpreted as a line separator (vbCrLf). Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for Flags are:

Name | Value | Description
sgExportDefault | 0 | Use default export flags.
sgExportCurrentRowOnly | 1 | Export current row only.
sgExportFieldNames | 2 | Export field names.
sgExportRowsOnly | 4 | Export only data rows.
sgExportHidden | 8 | Hidden columns will appear in exported data.
sgExportOverwrite | 16 | Replace file if it already exists.
sgExportAppend | 32 | Append to file if it already exists.
The settings for DataFormat are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

If DataFormat is sgFormatXML, columns that do not have the DBField specified are not exported.


ExportHTML Method

ExportHTML Method
Exports grid as an HTML table to a file.
Syntax

object.ExportHTML(FilePath As String, [FirstRowPos = -1] As Long, [RowCount = -1] As Long, [Flags = sgExportDefault] As sgExportFlag, [HTMLTemplate = ""] As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
FilePath | A String expression that indicates the name of the file to be loaded.
FirstRowPos | Optional. A Long expression that sets the starting row position for export. If omitted or equal to -1, export begins at the first row. Default value is -1.
RowCount | Optional. A Long expression that specifies the number of rows to export. Default value is -1 which exports all rows starting at the FirstRowPos.
Flags | Optional. An sgExportFlag expression that sets options for a data export. Default value is sgExportDefault. The possible values are listed in Settings.
HTMLTemplate | Optional. A String expression that contains the template with instructions for generating an HTML output. If this parameter is an empty string, the BeeGrid will use predefined template described in the Remarks section. Default value for this parameter is an empty string.

Settings

The settings for Flags are:

Name | Value | Description
sgExportDefault | 0 | Use default export flags.
sgExportCurrentRowOnly | 1 | Export current row only.
sgExportFieldNames | 2 | Export field names.
sgExportRowsOnly | 4 | Export only data rows.
sgExportHidden | 8 | Hidden columns will appear in exported data.
sgExportOverwrite | 16 | Replace file if it already exists.
sgExportAppend | 32 | Append to file if it already exists.

Remarks

When exporting HTML, the BeeGrid control uses HTML template to generate HTML output. This template file contains standard HTML tags and special BeeGrid tokens. These tokens are enclosed inside the <% and %> delimiters, so that template file looks similar to the ASP file. When BeeGrid parses template file, it replaces tokens with data. Any other text is simply copied to the HTML output stream.

Here is a list of all tokens:

table | Export rows enclosed into the <TABLE> tag.
rows | Export rows embedded into the <TR></TR> tags but without <TABLE> tag. Template must contain <TABLE> tag (e.g. "<TABLE><%rows%></TABLE>".
fields(parameter) | Export single cell value (without <TD></TD> tags). Parameter can be string representing field name or number representing column position.
css_include | Replaced with style include statement. If exporting to file, styles are saved into a separate file and css_include token is replaced with style include statements. If exporting to a string, css_include is replaced with embedded style definitions.

Tokens can have these attributes:

heading | Export grid's heading row.
groups | Export with group headers and footers.
caption | Export grid's caption.
html_formatting | Export grid's styles as HTML attributes.
css_formatting | Export grid's styles as CSS attributes.
pixel_width | Set width (in pixels) of the generated column to the width of that column in the grid.
percent_width | Set width (in percent) of the generated column to the width of that column in the grid.

When CSS formatting is not active, font size is matched according to this table:

Size | Font size in points
1 | 8.5pt and less
2 | greater than 8.5pt and less than or equal to 10pt
3 | greater than 10pt and less than or equal to 12pt
4 | greater than 12pt and less than or equal to 14pt
5 | greater than 14pt and less than or equal to 18pt
6 | greater than 18pt and less than or equal to 24pt
7 | greater than 24pt

Default template (used when HTMLtemplate parameter is empty string) is:

<HTML>
<HEAD>
  <%=css_include%>
</HEAD>
<BODY>
  <%=table css_formatting groups pixel_width heading caption%>
</BODY>
</HTML>

Note that unrecognized attributes are ignored.

Show Example
Copy Code [image] Show Me

The following example creates a table for each group in the grid.

Private Sub ExportGroupByGroup()
   Dim sFileName As String
   Dim sTemplate As String
   Dim gh As SGGroupHeading
   Const ROWS_FORMAT = "<%=table percent_width  html_formatting%>"
   Dim lFirstRow As Long, lLastRow As Long

   sFileName = App.Path & "\ExportHTMLTest.htm"

   sTemplate = ""

   For Each gh In SGGrid1.GroupHeadings
      lFirstRow = gh.ChildRows(1).Position
      lLastRow = gh.ChildRows(gh.ChildRows.Count).Position
      sTemplate = sTemplate & gh.row.Cells(0).Value
      sTemplate = sTemplate & _
         SGGrid1.ExportHTMLString(lFirstRow, lLastRow, , ROWS_FORMAT)
   Next

   sTemplate = sTemplate & "</BODY></HTML>"

   SGGrid1.ExportHTML sFileName, , , sgExportOverwrite, sTemplate
End Sub

Back to topic


ExportHTMLString Method

ExportHTMLString Method
Exports grid as an HTML table to a string.
Syntax

object.ExportHTMLString([FirstRowPos = -1] As Long, [RowCount = -1] As Long, [Flags = sgExportDefault] As sgExportFlag, [HTMLTemplate = ""] As String)

Return Value A String value containing HTML presentation of the grid's data.
Arguments
object | An object expression that evaluates to the SGGrid object.
FirstRowPos | Optional. A Long expression that sets the starting row position for export. If omitted or equal to -1, export begins at the first row. Default value is -1.
RowCount | Optional. A Long expression that specifies the number of rows to export. Default value is -1 which exports all rows starting at the FirstRowPos.
Flags | Optional. An sgExportFlag expression that sets options for a data export. Default value is sgExportDefault. The possible values are listed in Settings.
HTMLTemplate | Optional. A String expression that contains the template with instructions for generating an HTML output. If this parameter is an empty string, the BeeGrid will use predefined template described in the Remarks section. Default value for this parameter is an empty string.

Settings

The settings for Flags are:

Name | Value | Description
sgExportDefault | 0 | Use default export flags.
sgExportCurrentRowOnly | 1 | Export current row only.
sgExportFieldNames | 2 | Export field names.
sgExportRowsOnly | 4 | Export only data rows.
sgExportHidden | 8 | Hidden columns will appear in exported data.
sgExportOverwrite | 16 | Replace file if it already exists.
sgExportAppend | 32 | Append to file if it already exists.

Remarks

The ExportHTMLString methods exports grid data in HTML format and returns string containing that HTML. For more info see ExportHTML method.

Show Example
Copy Code [image] Show Me

The following example creates a table for each group in the grid.

Private Sub ExportGroupByGroup()
   Dim sFileName As String
   Dim sTemplate As String
   Dim gh As SGGroupHeading
   Const ROWS_FORMAT = "<%=table percent_width  html_formatting%>"
   Dim lFirstRow As Long, lLastRow As Long

   sFileName = App.Path & "\ExportHTMLTest.htm"

   sTemplate = ""

   For Each gh In SGGrid1.GroupHeadings
      lFirstRow = gh.ChildRows(1).Position
      lLastRow = gh.ChildRows(gh.ChildRows.Count).Position
      sTemplate = sTemplate & gh.row.Cells(0).Value
      sTemplate = sTemplate & _
         SGGrid1.ExportHTMLString(lFirstRow, lLastRow, , ROWS_FORMAT)
   Next

   sTemplate = sTemplate & "</BODY></HTML>"

   SGGrid1.ExportHTML sFileName, , , sgExportOverwrite, sTemplate
End Sub

Back to topic


GetLayoutString Method

GetLayoutString Method
Returns grid layout in a string.
Syntax

object.GetLayoutString(Format As sgLayoutFormat)

Return Value A String value containing the grid's layout.
Arguments
object | An object expression that evaluates to the SGGrid object.
Format | An sgLayoutFormat expression that determines format of the exported layout. In this version only sgLayoutXML is supported.

Settings

The settings for Format are:

Name | Value | Description
sgLayoutXML | 1 | Layout is saved in XML format.
sgLayoutIgnoreColumns | 256 | When loading layout, columns are not created or destroyed.

Remarks

The GetLayoutString method returns string that contains complete grid state. You can use this layout string to quickly initialize grid.

The layout returned from the GetLayoutString method contains complete grid state including simple properties, column definitions, group definitions, filters, styles, style conditions and value items. Layout does not contain any data displayed in the grid cells.


HitTest Method

HitTest Method
Returns hit test code for given coordinates.
Syntax

object.HitTest(X As OLE_XPOS_CONTAINER, Y As OLE_YPOS_CONTAINER)

Return Value An sgGridHitTest value indicating area under the specified coordinates.
Arguments
object | An object expression that evaluates to the SGGrid object.
X | A single-precision number that specifies the current x coordinate of the mouse pointer.
Y | A single-precision number that specifies the current y coordinate of the mouse pointer.

Settings

The HitTest settings are:

Name | Value | Description
sgHitNowhere | 0 | Inactive part of a grid control.
sgHitHeadingRow | 1 | At heading row.
sgHitHeadingCol | 2 | At heading column.
sgHitCell | 3 | At grid cell.
sgHitCellButton | 4 | At grid cell's button.
sgHitBkg | 5 | At area outside of grid cells .
sgHitGroupExpandBtn | 6 | At group header expand button.
sgHitGroupIndentation | 7 | At group indentation.
sgHitCaption | 8 | At grid's caption bar.
sgHitPreviewPaneSplitter | 9 | At preview pane's splitter.
sgHitPreviewPane | 10 | At preview pane.
sgHitGridCorner | 11 | At rectangle between vertical and horizontal scroll bars.
sgHitGroupByBox | 12 | At group-by box.
sgHitGroupByBoxCell | 13 | At cell inside group-by box.

Remarks

The HitTest method returns a value indicating the position of the specified coordinates.

Show Example
Copy Code [image] Show Me

The following example paints a cell bellow the mouse pointer. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   Dim lRowKey As Long, sColKey As String
   Dim oCell As SGCell
   Static lOldRowKey As Long
   Static sOldColKey As String

   'check out if mouse pointer is over cells
   If SGGrid1.HitTest(x, y) <> sgHitCell Then Exit Sub
   'get row and col keys
   lRowKey = SGGrid1.Rows.At(SGGrid1.MouseRow).Key
   sColKey = SGGrid1.Columns.At(SGGrid1.MouseCol).Key

   If lOldRowKey = lRowKey And _
      sColKey = sOldColKey Then Exit Sub

   'paint old cell to white
   If Len(sOldColKey) > 0 Then
      Set oCell = SGGrid1.cell(lOldRowKey, sOldColKey)
      oCell.Style.BackColor = vbWhite
      oCell.Redraw
   End If

   Set oCell = SGGrid1.cell(lRowKey, sColKey)
   'paint it red
   oCell.Style.BackColor = vbRed
   Set oCell = Nothing
   'save current keys to static variables
   lOldRowKey = lRowKey
   sOldColKey = sColKey

   SGGrid1.RedrawCell SGGrid1.MouseRow, SGGrid1.MouseCol
End Sub

Back to topic


HitTestEx Method

HitTestEx Method
Returns hit test code for given coordinates.
Syntax

object.HitTestEx(X As OLE_XPOS_CONTAINER, Y As OLE_YPOS_CONTAINER, RowKey As Long, ColKey As String, CellKind As sgCellKind)

Return Value An sgGridHitTest value indicating area under the specified coordinates. Also, if returned code is sgHitCell, parameters RowKey, ColKey and CellKind parameters are initialized with cell's indexes.
Arguments
object | An object expression that evaluates to the SGGrid object.
X | A single-precision number that specifies the current x coordinate of the mouse pointer.
Y | A single-precision number that specifies the current y coordinate of the mouse pointer.
RowKey | A Long variable that will be initialized with row's key if return value is sgHitCell.
ColKey | A String variable that will be initialized with column's key if return value is sgHitCell.
CellKind | An sgCellKind variable that will be initialized with cell's type if return value is sgHitCell.

Settings

The HitTestEx method settings are:

Name | Value | Description
sgHitNowhere | 0 | Inactive part of a grid control.
sgHitHeadingRow | 1 | At heading row.
sgHitHeadingCol | 2 | At heading column.
sgHitCell | 3 | At grid cell.
sgHitCellButton | 4 | At grid cell's button.
sgHitBkg | 5 | At area outside of grid cells .
sgHitGroupExpandBtn | 6 | At group header expand button.
sgHitGroupIndentation | 7 | At group indentation.
sgHitCaption | 8 | At grid's caption bar.
sgHitPreviewPaneSplitter | 9 | At preview pane's splitter.
sgHitPreviewPane | 10 | At preview pane.
sgHitGridCorner | 11 | At rectangle between vertical and horizontal scroll bars.
sgHitGroupByBox | 12 | At group-by box.
sgHitGroupByBoxCell | 13 | At cell inside group-by box.
The settings for CellKind are:

Name | Value | Description
sgCellStandard | 0 | Standard cell.
sgCellGroupHeader | 2 | Cell is a group header cell.
sgCellGroupFooter | 3 | Cell is a group footer cell.
sgCellPreviewPane | 4 | Cell is a preview pane.
sgCellGroupByBox | 5 | Cell is a group-by box.
sgCellGroupByHeadingCell | 6 | Cell is a column heading inside the group-by box.

Remarks

The HitTestEx method can be used to get row key, column index and cell kind of the cell under the specified coordinates. If there is no grid cell under the specified point, this method behaves same as the HitTest method.

Show Example
Copy Code [image] Show Me

The following example increments the cell's value when you move the cursor over the cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove _
   (button As Integer, shift As Integer, _
   x As Single, y As Single)
   Dim lRowKey As Long, sColKey As String
   'use HitTestEx to get row and col keys
   If SGGrid1.HitTestEx(x, y, lRowKey, _
      sColKey, sgCellStandard) = sgHitCell Then
      'increment cells value for 1
      With SGGrid1.cell(lRowKey, sColKey)
         .Value = .Value + 1
         .Redraw
      End With
   End If
End Sub

Private Sub Form_Load()
   'create rows & cols
   SGGrid1.DataColCount = 20
   SGGrid1.DataRowCount = 20
   SGGrid1.GroupByBoxVisible = False
   'formate cells
   SGGrid1.Format = Chr(34) & "Visited: " & Chr(34) & _
      "#0" & Chr(34) & " times" & Chr(34)
End Sub

Back to topic


HitTestObject Method

HitTestObject Method
Returns hit test code for given coordinates and top-most object under that coordinates.
Syntax

object.HitTestObject(X As OLE_XPOS_CONTAINER, Y As OLE_YPOS_CONTAINER, TopMostObject As Variant)

Return Value An sgGridHitTest value indicating area under the specified coordinates. Also, the TopMostObject parameter is initialized with object under the inspected point. For more info see Remarks section.
Arguments
object | An object expression that evaluates to the SGGrid object.
X | A single-precision number that specifies the current x coordinate of the mouse pointer.
Y | A single-precision number that specifies the current y coordinate of the mouse pointer.
TopMostObject | A Variant variable that will be initialized with object under the inspected point. For more info see Remarks section.

Settings

The HitTestObject method settings are:

Name | Value | Description
sgHitNowhere | 0 | Inactive part of a grid control.
sgHitHeadingRow | 1 | At heading row.
sgHitHeadingCol | 2 | At heading column.
sgHitCell | 3 | At grid cell.
sgHitCellButton | 4 | At grid cell's button.
sgHitBkg | 5 | At area outside of grid cells .
sgHitGroupExpandBtn | 6 | At group header expand button.
sgHitGroupIndentation | 7 | At group indentation.
sgHitCaption | 8 | At grid's caption bar.
sgHitPreviewPaneSplitter | 9 | At preview pane's splitter.
sgHitPreviewPane | 10 | At preview pane.
sgHitGridCorner | 11 | At rectangle between vertical and horizontal scroll bars.
sgHitGroupByBox | 12 | At group-by box.
sgHitGroupByBoxCell | 13 | At cell inside group-by box.

Remarks

The HitTestObject method returns a value indicating the position of the specified point. In addition, if area under the specified point can be represented with one of the BeeGrid objects, the TopMostObject parameter is initialized with that object. Following table lists which objects are returned for every possible hit test code:

Hit Test Code | Object
sgHitHeadingRow | SGColumn
sgHitHeadingCol sgHitGroupIndentation | SGRow
sgHitGroupExpandBtn sgHitCell | SGCell
sgHitCaption sgHitBkg sgHitNowhere | SGGrid
Any other hit code | Nothing

Show Example
Copy Code [image] Show Me

The following example uses the grid's caption to record the contents of the cell bellow the mouse pointer. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove _
   (button As Integer, shift As Integer, _
    x As Single, y As Single)
   Dim cell As Variant

   If SGGrid1.HitTestObject(x, y, cell) = sgHitCell Then
      SGGrid1.Caption = cell.Text
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False

   SGGrid1.DataColCount = 20
   SGGrid1.DataRowCount = 20

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataColCount - 1
      For j = 0 To SGGrid1.DataRowCount - 1
         ar.Value(j, i) = "Row: " & Trim(j + 1) _
         & " Col: " & Trim(i + 1)
      Next
   Next

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


ImportData Method

ImportData Method
Imports data from a file.
Syntax

object.ImportData(FilePath As String, DataFormat As sgDataFormat, [CellSeparator = ","] As String, [RowSeparator = ""] As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
FilePath | A String expression that indicates the name of the file to be imported.
DataFormat | An sgDataFormat expression that determines format of data to be imported.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Used only if the DataFormat is sgFormatCharSeparatedValue. Default value is ",".
RowSeparator | Optional. A String expression that sets delimiter used between rows. Default value is an empty string which is interpreted as a line separator (vbCrLf). Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for DataFormat are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

The ImportDataString method imports data from the specified file.

If DataFormat is sgFormatXML, the BeeGrid imports only fields that are specified in the XML file. If a field is specified in the XML file and there is no grid column with exactly the same DBField property, data for that field is not imported.

If DataFormat is sgFormatCharSeparatedValue, the BeeGrid fills all columns starting from left to right. If imported data contains more fields than grid has columns, new columns are created.

Note that grid's XML format is different from the ADO recordset's XML format.


ImportDataString Method

ImportDataString Method
Imports data from a string.
Syntax

object.ImportDataString(Data As String, DataFormat As sgDataFormat, [CellSeparator = ","] As String, [RowSeparator = ""] As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
Data | A String expression that contains data to be imported.
DataFormat | An sgDataFormat expression that determines format of data to be imported.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Used only if the DataFormat is sgFormatCharSeparatedValue. Default value is ",".
RowSeparator | Optional. A String expression that sets delimiter used between rows. Default value is an empty string which is interpreted as a line separator (vbCrLf). Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for DataFormat are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

The ImportDataString method imports data from the specified string.

If the DataFormat is sgFormatXML, the BeeGrid imports only fields specified in the XML data. If a field is specified in the XML data and there is no grid column with exactly the same DBField property, data for that field is not imported.

If the DataFormat is sgFormatCharSeparatedValue, the BeeGrid fills all columns starting from left to right. If imported data contains more fields than grid has columns, new columns are created.

Note that grid's XML format is different from the ADO recordset's XML format.


KeyBookmark Method

KeyBookmark Method
Returns bookmark for row with specified key.
Syntax

object.KeyBookmark(RowKey As Long)

Return Value A Variant containing a bookmark corresponding to the display row.
Arguments
object | An object expression that evaluates to the SGGrid object.
RowKey | A Long that represents the Key of the row.

Remarks

See Also

SGGrid


LoadAllRecords Method

LoadAllRecords Method
Loads all records from the underlying data source.
Syntax | object.LoadAllRecords
Return Value | None
Arguments | None

Remarks

The LoadAllRecords method loads all records into the grid's internal buffer. Before it starts to read data from the underlying data source, grid ensures that the CacheAllRecords property is set to True.

If grid is bound to a large recordset, this method can take a long time to execute and grid can consume large amount of memory.

This method has no effect in unbound data modes.

See Also

CacheAllRecords


LoadArray Method

LoadArray Method
Loads the grid with data from an array.
Syntax

object.LoadArray(Array As Variant, [RowDim = 1] As Long, [ColDim = 0] As Long, [PageDim = -1] As Long, [CurrPage = 0] As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
Array | An array that contains data that will be loaded into the grid's internal buffer.
RowDim | A Long expression that indicates which array dimension binds to grid rows. Default value is 1.
ColDim | A Long expression that indicates which array dimension binds to grid columns. Default value is 0.
PageDim | A Long expression that indicates which array dimension is used as a 'page' dimension. If PageDim is -1, CurrPage parameter is ignored. Default value is -1.
CurrPage | A Long expression that indicates actual data 'page' that is loaded into the grid's internal buffer. Default value is 0.

Remarks

The LoadArray method enables you to copy data from the Visual Basic's array into the grid's internal buffer. If the DataMode property is not sgUnbound, the LoadArray method reports an error.

Show Example
Copy Code

The following example shows how to use the LoadArray method.

' Results in a grid with 5 columns and 7 rows
Dim arr(4, 6)
SGGrid1.LoadArray arr

' Results in a grid with 7 columns and 5 rows
Dim arr(4, 6)
SGGrid1.LoadArray arr, 0, 1

' Results in a grid with 5 columns and 7 rows.
' Data is copied from the arr(x, x, 1) page
Dim arr(4, 6, 2)
SGGrid1.LoadArray arr, 1, 0, 2, 1

Back to topic

See Also

SGGrid


LoadLayoutFromFile Method

LoadLayoutFromFile Method
Loads grid layout from a file.
Syntax

object.LoadLayoutFromFile(FilePath As String, Format As sgLayoutFormat)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
FilePath | A String expression that indicates the name of the file to be loaded.
Format | An sgLayoutFormat expression that determines format of the exported layout. In this version only sgLayoutXML is supported.

Settings

The settings for Format are:

Name | Value | Description
sgLayoutXML | 1 | Layout is saved in XML format.
sgLayoutIgnoreColumns | 256 | When loading layout, columns are not created or destroyed.

Remarks

The LoadLayoutString method initializes grid from the specified file. Format of the file content is specified in the Format parameter (in this version, only XML format is supported). Normally, complete current grid state is lost and replaced with data from the loaded layout. You can preserve column settings if you include sgLayoutIgnoreColumns flag into the Format parameter.

The layout can contain complete grid state including simple properties, column definitions, group definitions, filters, styles, style conditions and value items. Layout does not contain any data displayed in the grid cells.

For performance reasons, row groupings is not automatically restored when grid layout is loaded. To restore row groupings, you should manually call the RefreshGroups method.


LoadLayoutFromURL Method

LoadLayoutFromURL Method
Loads grid layout from an URL.
Syntax

object.LoadLayoutFromURL(FileURL As String, Format As sgLayoutFormat)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
FileURL | A String expression that indicates the URL of the layout to be loaded.
Format | An sgLayoutFormat expression that determines format of the exported layout. In this version only sgLayoutXML is supported.

Settings

The settings for Format are:

Name | Value | Description
sgLayoutXML | 1 | Layout is saved in XML format.
sgLayoutIgnoreColumns | 256 | When loading layout, columns are not created or destroyed.

Remarks

The LoadLayoutString method initializes grid from the specified URL location. Format of the layout is specified in the Format parameter (in this version, only XML format is supported). Normally, complete current grid state is lost and replaced with data from the loaded layout. You can preserve column settings if you include sgLayoutIgnoreColumns flag into the Format parameter.

The layout can contain complete grid state including simple properties, column definitions, group definitions, filters, styles, style conditions and value items. Layout does not contain any data displayed in the grid cells.

For performance reasons, row groupings is not automatically restored when grid layout is loaded. To restore row groupings, you should manually call the RefreshGroups method.

This method is not asynchronous and control is not returned to the caller until complete file is retrieved from the specified URL.


LoadLayoutString Method

LoadLayoutString Method
Loads grid layout from a string.
Syntax

object.LoadLayoutString(LayoutString As String, Format As sgLayoutFormat)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
LayoutString | A String expression that contains the layout to be loaded.
Format | An sgLayoutFormat expression that determines format of the exported layout. In this version only sgLayoutXML is supported.

Settings

The settings for Format are:

Name | Value | Description
sgLayoutXML | 1 | Layout is saved in XML format.
sgLayoutIgnoreColumns | 256 | When loading layout, columns are not created or destroyed.

Remarks

The LoadLayoutString method initializes grid from the specified string. Format of the string is specified in the Format parameter (in this version, only XML format is supported). Normally, complete current grid state is lost and replaced with data from the layout string. You can preserve column settings if you include sgLayoutIgnoreColumns flag into the Format parameter.

The layout can contain complete grid state including simple properties, column definitions, group definitions, filters, styles, style conditions and value items. Layout does not contain any data displayed in the grid cells.

For performance reasons, row groupings is not automatically restored when grid layout is loaded. To restore row groupings, you should manually call the RefreshGroups method.


MoveFirst Method

MoveFirst Method
Moves the current record to the first one.
Syntax | object.MoveFirst
Return Value | None
Arguments | None

Remarks

The MoveFirst method moves the current record to the first one available in the bound recordset.

Show Example
Copy Code [image] Show Me

The following example uses the MoveFirst method to set the first row as the current row.

Private Sub Command1_Click()

   SGGrid1.Rows.At(1).Cells(1).EnsureVisible
   SGGrid1.MoveFirst

End Sub

Back to topic


MoveLast Method

MoveLast Method
Moves the current record to the last one.
Syntax | object.MoveLast
Return Value | None
Arguments | None

Remarks

The MoveLast method moves the current record to the last one available in the bound recordset.

The MoveLast method ignores hidden rows.

Show Example
Copy Code [image] Show Me

The following example ensure the MoveLast method to reach the last row.

Private Sub Command1_Click()
   Dim lLastRow As Long
   Dim sFirstCol As String

   lLastRow = SGGrid1.Rows.At(SGGrid1.Rows.Count - 1).Key
   sFirstCol = SGGrid1.Columns(1).Key

   SGGrid1.EnsureCellVisible lLastRow, sFirstCol
   SGGrid1.MoveLast
End Sub

Back to topic


MoveNext Method

MoveNext Method
Moves the current record to the next one.
Syntax | object.MoveNext
Return Value | None
Arguments | None

Remarks

The MoveNext method moves the current record to the next one available in the bound recordset.

Show Example
Copy Code [image] Show Me

The following example moves the current row to next position but skips the GroupHeaders and GroupFooters.

Private Sub Command1_Click()
   Do
      SGGrid1.MoveNext
      If SGGrid1.Rows.Current.Position + 1 = SGGrid1.Rows.Count Then
         SGGrid1.MovePrevious
         Exit Do
      End If
   Loop Until SGGrid1.Rows.Current.Type = sgSimpleRow
End Sub

Back to topic


MovePrevious Method

MovePrevious Method
Moves the current record to the previous one.
Syntax | object.MovePrevious
Return Value | None
Arguments | None

Remarks

The MoveFirst method moves the current record to the previous one available in the bound recordset.

Show Example
Copy Code [image] Show Me

The following example moves the current row to previous position but skips the GroupHeaders and GroupFooters.

Private Sub Command1_Click()
   Dim i As Integer
   Dim iHeadingRows As Integer

   iHeadingRows = SGGrid1.HeadingRowCount

   Do
      SGGrid1.MovePrevious
      If SGGrid1.Rows.Current.Position = iHeadingRows Then
         For i = 1 To SGGrid1.Groups.Count
            SGGrid1.MoveNext
         Next
         Exit Do
      End If
   Loop Until SGGrid1.Rows.Current.Type = sgSimpleRow
End Sub

Back to topic


MoveRelative Method

MoveRelative Method
Moves the current record offset rows relative to the current or specified row.
Syntax

object.MoveRelative(Rows As Long, Bookmark As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
Rows | A Long expression that evaluates to the number of rows to move. A positive value indicates forward movement; a negative value indicates backward movement.
Bookmark | A Variant that represents the Bookmark of the origin row.

Remarks

The MoveRelative method moves the current row relative to the specified Bookmark.

Show Example
Copy Code [image] Show Me

Private Sub Command1_Click()
    SGGrid1.MoveRelative 2, SGGrid1.CurBookmark
End Sub

Back to topic


MoveToRowKey Method

MoveToRowKey Method
Moves the current record to the specified row.
Syntax

object.MoveToRowKey(RowKey As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowKey | A Long that represents the Key of the row.

Remarks

Show Example
Copy Code [image] Show Me

Private Sub Command1_Click()
   Dim lCol, sMsg

   sMsg = "Please enter row number you want to move! Number have to be beetwen 1 and" & SGGrid1.Rows.Count - 1
   lCol = InputBox(sMsg, "MoveToRowKey", 1)

   If Not IsNumeric(lCol) Then
      MsgBox lCol & " is not valid numer!"
      Exit Sub
   End If

   lCol = CLng(lCol)

   If lCol < 1 Or lCol > (SGGrid1.Rows.Count - 1) Then
      MsgBox "Please enter number beetwen 0 and " & SGGrid1.Rows.Count - 1 & "!"
      Exit Sub
   End If

   SGGrid1.MoveToRowKey SGGrid1.Rows.At(lCol).Key
End Sub

Back to topic


OLEDrag Method

OLEDrag Method
Initiates an OLE drag/drop operation.
Syntax | object.OLEDrag
Return Value | None
Arguments | None

Remarks

The OLEDrag method initiates an OLE drag/drop operation. When the OLEDrag method is called, the event OLEStartDrag is fired, allowing it to supply data to a target component.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to start drag-and-drop operations from the code.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   'start drag-drop operations
   If button = vbLeftButton Then SGGrid1.OLEDrag
End Sub

Private Sub SGGrid1_OLEStartDrag( _
   ByVal data As IsgDataObject, _
   allowedEffects As Long)
   'drag contents of the current cell
   data.SetData SGGrid1.CurrentCell.Value, vbCFText
End Sub

Back to topic


PostMessage Method

See Also [image] Example

Send us your Feedback

PostMessage Method

Posts the message for later processing.

Syntax

object.PostMessage(MessageID As Long, Data1 As Variant, Data2 As Variant)

Return Value

None

Arguments

MessageID | A Long expression that identifies the message being posted.
Data1 | A Variant expression that identifies data associated with the message.
Data2 | A Variant expression that identifies data associated with the message.

Remarks

Use the PostMessage method to perform operation at some later time. You typically need to postpone operation which is illegal within the grid event. When the PostMessage method is called, the grid will fire the PostMessageEvent event after all pending operations are completed.

MessageID, Data1 and Data2 parameters will be passed to the corresponding PostMessageEvent event.

See Also

PostMessageEvent


ReBind Method

ReBind Method
Re-establishes the connection with the bound data source.
Syntax | object.ReBind
Return Value | None
Arguments | None

Remarks

The ReBind method has effect only in the bound mode. It re-establishes the connection with the bound data source. If the property AutoFields is set to True, the ReBind method clears previous columns settings.

See Also

SGGrid


Redraw Method

Redraw Method
Redraws specified grid area.
Syntax

object.Redraw([GridSection = sgRedrawAll] As sgGridRedrawCode)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
GridSection | Optional. An sgGridRedrawCode expression that indicates what portion of the grid control should be redrawn. Default value is sgRedrawAll.

Settings

The settings for GridSection are:

Name | Value | Description
sgRedrawAll | 0 | Redraws grid control.
sgRedrawHeadingRow | 1 | Redraw the heading row.
sgRedrawHeadingCol | 2 | Redraws the heading column.
sgRedrawBkg | 3 | Redraws area outside of grid cells.
sgRedrawCaption | 4 | Redraws the caption bar.
sgRedrawPreviewPaneSplitter | 5 | Redraws the preview pane's splitter.
sgRedrawPreviewPane | 6 | Redraws the preview pane.
sgRedrawGroupByBox | 7 | Redraws the group-by box.
sgRedrawGridCorner | 8 | Redraws the rectangle between vertical and horizontal scroll bars.

Remarks

Show Example
Copy Code [image] Show Me

The following example changes font color when a column's header is clicked. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   Dim Col As SGColumn

   For Each Col In SGGrid1.Columns
      Col.HeadingStyle.Font.Bold = False
      Col.HeadingStyle.ForeColor = vbBlack
   Next

   SGGrid1.Columns(ColIndex).HeadingStyle.Font.Bold = True
   SGGrid1.Columns(ColIndex).HeadingStyle.ForeColor = vbRed
   SGGrid1.Redraw sgHitHeadingRow
End Sub

Back to topic


RedrawCell Method

RedrawCell Method
Redraws specified cell.
Syntax

object.RedrawCell(RowPosition As Long, ColPosition As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowPosition | A Long that identifies the row Position.
ColPosition | A Long that identifies the column Position.

Remarks

The Redraw method has no effect if the control's RedrawEnabled property is set to False.

Show Example
Copy Code [image] Show Me

The following example paints a cell bellow the mouse pointer. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   Dim lRowKey As Long, sColKey As String
   Dim oCell As SGCell
   Static lOldRowKey As Long
   Static sOldColKey As String

   'check out if mouse pointer is over cells
   If SGGrid1.HitTest(x, y) <> sgHitCell Then Exit Sub
   'get row and col keys
   lRowKey = SGGrid1.Rows.At(SGGrid1.MouseRow).Key
   sColKey = SGGrid1.Columns.At(SGGrid1.MouseCol).Key

   If lOldRowKey = lRowKey And _
      sColKey = sOldColKey Then Exit Sub

   'paint old cell to white
   If Len(sOldColKey) > 0 Then
      Set oCell = SGGrid1.cell(lOldRowKey, sOldColKey)
      oCell.Style.BackColor = vbWhite
      oCell.Redraw
   End If

   Set oCell = SGGrid1.cell(lRowKey, sColKey)
   'paint it red
   oCell.Style.BackColor = vbRed
   Set oCell = Nothing
   'save current keys to static variables
   lOldRowKey = lRowKey
   sOldColKey = sColKey

   SGGrid1.RedrawCell SGGrid1.MouseRow, SGGrid1.MouseCol
End Sub

Back to topic


RedrawCol Method

RedrawCol Method
Redraws specified column.
Syntax

object.RedrawCol(ColPosition As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
ColPosition | A Long that identifies the column Position.

Remarks

The Redraw method has no effect if the control's RedrawEnabled property is set to False.

Show Example
Copy Code [image] Show Me

The following example selects and redraws the second column.

Private Sub Command1_Click()

   SGGrid1.Selection.Ranges.Add sgRangeColumn, 2, 0, 2, 0

   SGGrid1.RedrawCol 2
End Sub

Back to topic


RedrawRow Method

RedrawRow Method
Redraws specified row.
Syntax

object.RedrawRow(RowPosition As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowPosition | A Long that identifies the row Position.

Remarks

The Redraw method has no effect if the control's RedrawEnabled property is set to False.

Show Example
Copy Code [image] Show Me

The following example selects and redraws the second row.

Private Sub Command1_Click()
   SGGrid1.Selection.Ranges.Add sgRangeRow, 0, 2, 0, 2

   SGGrid1.RedrawRow 2
End Sub

Back to topic


RefetchRow Method

RefetchRow Method
Reloads specified row from a data source.
Syntax

object.RefetchRow(RowKey As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowKey | A Long that represents the Key of the row.

Remarks

See Also

SGGrid


RefreshGroups Method

RefreshGroups Method
Forces a recalculation of groups in a grid control.
Syntax

object.RefreshGroups([Expand = sgExpandGroups] As sgExpand)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
Expand | Optional. An sgExpand expression indicating whether groups will be expanded or collapsed after refreshing. Default value is sgExpandGroups.

Settings

The settings for Expand are:

Name | Value | Description
sgExpandGroups | 1 | Groups will be expanded.
sgCollapseGroups | 2 | Groups will be collapsed.

Remarks

The RefreshGroups methods clears all groupings and than recalculates groups. When data source changes, you should call this method to regroup rows. You can use the DataSourceChanged event to do this.

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers, groups odd and even numbers. It uses the GroupHeadings property to create the group header caption. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then
      Text = "There are " & _
         SGGrid1.GroupHeadings(1).ChildRows.Count & " even numbers"
   Else
      Text = "There are " & _
         SGGrid1.GroupHeadings(2).ChildRows.Count & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupIndentation = 0
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 20

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrFireFetchText

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic


RowBookmark Method

RowBookmark Method
Returns bookmark identifying row at specified position.
Syntax

object.RowBookmark(RowPosition As Long)

Return Value A Variant expression that represents the row's bookmark.
Arguments
object | An object expression that evaluates to the SGGrid object.
RowPosition | A Long that identifies the row Position.

Remarks

The sgVirtualInterface data mode doesn't support bookmarks.


Scroll Method

Scroll Method
Scrolls grid for a specified number of rows and columns.
Syntax

object.Scroll(RowCount As Long, ColCount As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowCount | A Long denoting the number of rows to scroll.
ColCount | A Long denoting the number of columns to scroll.

Remarks

Positive values scrolls right and down, negative values scrolls left and up.

Show Example
Copy Code [image] Show Me

The following example scrolls the grid's cells every 2 seconds. To try the example, place the SGGrid and Timer control on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ar As SGArray
   Dim i As Integer
   Const TEXT_HEIGHT = 32

   SGGrid1.DataColCount = 2
   SGGrid1.DataRowCount = 100
   SGGrid1.EqualRowHeight = True
   SGGrid1.RowNumbering = True
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.FitLastColumn = True
   'grid inherit scale mode by the patent
   Me.ScaleMode = vbPoints
   SGGrid1.Font.Size = TEXT_HEIGHT
   SGGrid1.Font.Name = "Arial"
   SGGrid1.Rows.At(1).Height = TEXT_HEIGHT + TEXT_HEIGHT / 10
   'set columns
   SGGrid1.Columns(1).Caption = "Home"
   SGGrid1.Columns(1).Width = (SGGrid1.ClientWidth - SGGrid1.Columns(1).Width) / 2
   SGGrid1.Columns(2).Caption = "Visitor"
   'load sample data
   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 0) = "Team " & Trim((i + 1) * 2 - 1)
      ar.Value(i, 1) = "Team " & Trim((i + 1) * 2)
   Next

   Set ar = Nothing
   'enable timer
   Timer1.Interval = 2000
   Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
   Dim iVisibleRows As Integer

   If SGGrid1.BottomRow = SGGrid1.RowCount - 1 Then
      SGGrid1.Scroll -SGGrid1.RowCount, 0
   Else
      iVisibleRows = SGGrid1.BottomRow - SGGrid1.TopRow
      SGGrid1.Scroll iVisibleRows, 0
   End If
End Sub

Private Sub SGGrid1_AfterScroll(ByVal oldTopRow As Long, _
   ByVal oldLeftCol As Long, _
   ByVal newTopRow As Long, _
   ByVal newLeftCol As Long)

   SGGrid1.Caption = "Positions from " & _
      newTopRow & " to " & SGGrid1.BottomRow
End Sub

Back to topic


Sort Method

Sort Method
Sorts specified rows and columns.
Syntax

object.Sort(RowPosStart As Long, RowPosEnd As Long, parameters As ParamArray)

Return Value None
Arguments
object | An object expression that evaluates to the SGGrid object.
RowPosStart | A Long expression that represents position of the first row to be sorted. Set this argument to -1 to sort from the first row.
RowPosEnd | A Long expression that represents position of the last row to be sorted. Set this argument to -1 to sort until the last row.
parameters A ParamArray grouped by tree parameters. Use the following sequence:
  • Column key - a column you want to sort.
  • Sort Order - an sgSortOrder constant.
  • Sort Type - an sgSortType constant.

The ParamArray can also be an array of variants that contains sorting specification. Ordering of array elements should be the same as parameter ordering.

If sorting specification is not given, grid is sorted according to the current column sort specification.

Remarks

Sorting rules:

  • Sorting is enabled when all records are cached i.e. when CacheAllRecords is True or when DataMode property is set to sgUnbound, sgVirtualEvents or sgVirtualInterface.
  • Sort operation must preserve grouping settings.
  • If there is no grouping, Sort method sorts specified columns.
  • If there are groups and no one of the grouped columns is specified in the Sort method parameters, Sort operation is repeated for each row grouping.
  • If there are groups and some of the grouped columns are specified in the Sort method, sequence of the sort columns can be rearranged and other (grouped) columns can be added to sort specification in order to preserve groupings.

Sorting types:

  • sgSortTypeDefault - uses column type in the comparation
  • sgSortTypeNumber - converts to Double before comparation
  • sgSortTypeString - converts to String before comparation
  • sgSortTypeNoCaseString - converts to uppercase String before comparation
  • sgSortTypeDateTime - converts to DateTime before comparation
  • sgSortTypeCustom - fires Compare event

In case that conversion is not possible, Null value is assumed

The sort settings parameters (or elements of the Variant array) must be ordered in the following sequence:

  • Column key - a column you want to sort.
  • Sort Order - an sgSortOrder constant.
  • Sort Type - an sgSortType constant.

You can sort more columns at same time. The parameters arguments have to be grouped tree-by-tree otherwise an error occurs.

Sorting is much faster when the CacheAllRecords is enabled.

Show Example
Copy Code [image] Show Me

The following example fills grid with sample data and uses the Sort method to sort them. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   Dim so(2) As sgSortOrder
   Dim sColKey As String

   Select Case ColIndex
      Case 1
         If SGGrid1.Columns(ColIndex).SortOrder = sgSortAscending Then
            so(0) = sgSortDescending
            so(1) = sgSortAscending
            so(2) = sgSortDescending
         Else
            so(0) = sgSortAscending
            so(1) = sgSortDescending
            so(2) = sgSortAscending
         End If

         SGGrid1.Sort -1, -1, _
            "n1", so(0), sgSortTypeNumber, _
            "n2", so(1), sgSortTypeNumber, _
            "dt", so(2), sgSortTypeDateTime

      Case 2
         ' Prepare sort settings
         Dim sortSettings(0 To 5) As Variant
         sortSettings(0) = "n2"
         sortSettings(1) = sgSortAscending
         sortSettings(2) = sgSortTypeNumber
         sortSettings(3) = "n1"
         sortSettings(4) = sgSortDescending
         sortSettings(5) = sgSortTypeNumber

         ' Sort
         SGGrid1.Sort -1, -1, sortSettings

      Case 3
         sColKey = SGGrid1.Columns(ColIndex).Key

         If SGGrid1.Columns(ColIndex).SortOrder = sgSortAscending Then
            SGGrid1.Sort -1, -1, sColKey, sgSortDescending, sgSortTypeDateTime
         Else
            SGGrid1.Sort -1, -1, sColKey, sgSortAscending, sgSortTypeDateTime
         End If
   End Select
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Long, j As Integer

   With SGGrid1
      .Columns.RemoveAll False
      .CacheAllRecords = True
      .ColumnClickSort = False
      .GroupByBoxVisible = False

      With .Columns.Add("n1")
         .Caption = "Nr 1"
         .DataType = sgtLong
      End With

      With .Columns.Add("n2")
         .Caption = "Nr 2"
         .DataType = sgtLong
      End With

      With .Columns.Add("dt")
         .Caption = "Date"
         .DataType = sgtDateTime
         .SortType = sgSortTypeDateTime
      End With

      .DataRowCount = 50

      For i = 0 To .DataRowCount - 1
         .Array.Value(i, 0) = CLng(Rnd * 20)
         .Array.Value(i, 1) = CLng(Rnd * 10)
         .Array.Value(i, 2) = _
            FormatDateTime(CDate(Rnd * 365 + CLng(Now)), vbShortDate)
      Next
   End With
End Sub

Back to topic


Update Method

Update Method
Write data from the current row to the underlying database.
Syntax | object.Update
Return Value | None
Arguments | None

Remarks

When the user edits a row, grid keeps edited row in the internal buffer. Calling this method forces data from that buffer to be updated to the underlying database. It applies to both a bound grid and an unbound grid.

This method causes BeforeUpdate and AfterUpdate events to be fired.

Show Example
Copy Code [image] Show Me

The following example updates the current cell and returns to the edit mode.

Private Sub Command1_Click()
   SGGrid1.Update
   SGGrid1.Editing = True
End Sub

Back to topic


SGGrid Events

AfterClickSort | Fired after a column is sorted by a click on the column's header.
AfterDelete | Fired after a record has been deleted from the grid.
AfterEdit | Fired after the cell exits edit mode.
AfterGroupChange | Fired after the user has changed, added or removed a group in the BeeGrid control.
AfterGroupCollapse | Fired after the user collapses a group.
AfterGroupExpand | Fired after the user expands a group.
AfterInsert | Fired after the user inserts a new record into the grid.
AfterScroll | Fired after the grid scrolls.
AfterUpdate | Fired after grid data has been written to the database.
BeforeClickSort | Fired before a column is sorted by a click on the column's header.
BeforeDelete | Fired before a record is deleted from the grid.
BeforeEdit | Fired before the cell enters edit mode.
BeforeGroupChange | Fired when the user has changed, added or removed a group in the BeeGrid control.
BeforeInsert | Fired before the user inserts a new record into the grid.
BeforeRowColChange | Fired when the user attempts to move to a different cell.
BeforeUpdate | Fired before data is moved from the grid's buffer to the database.
ButtonClick | Fired when the user clicks an action button on a cell.
Change | Fired after the content of the cell edit control has changed.
Click | Fired when a mouse click occurs.
ColHeadClick | Fired when a column heading is clicked.
ColHide | Fired before a grid column is hidden.
ColMove | Fired before a grid column is dropped to a new position.
ColResize | Fired before a grid column is resized.
CompareCells | Fired when grid needs to compare two cells.
DataSourceChanged | Fired when the data source changes
DblClick | Fired when a mouse double click occurs.
DropDownOpen | Fired when popup part of the cell editor is opened.
Error | Fired when data access error occurs.
FetchCellStyle | Fired to retrieve cell style.
FetchCellTip | Fired to retrieve cell tip size, text, picture and style.
FetchColumnData | Fetches unbound column data when the grid is in DAO or ADO bound mode.
FetchGroupFooterStyle | Fired to retrieve group footer style.
FetchGroupFooterText | Fired to retrieve group footer text.
FetchGroupHeaderData | Fired to retrieve group header text and/or picture.
FetchGroupHeaderStyle | Fired to retrieve group header style.
FetchScrollTip | Fired to retrieve scroll tip size, text, picture and style.
FormatText | Fired to enable custom text formating.
GroupByBoxHeaderClick | Fired when the user clicks on the header for a particular grid column in the group-by box.
KeyDownEdit | Fired when the user presses a key in the cell edit mode.
KeyDown | Fired when the user presses a key.
KeyPressEdit | Fired when the user presses a key in the cell edit mode.
KeyPress | Fired when the user presses a key.
KeyUpEdit | Fired when the user presses a key in the cell edit mode.
KeyUp | Fired when the user presses a key.
MouseDown | Fired when a mouse button is pressed.
MouseMove | Fired when the mouse moves.
MouseUp | Fired when a mouse button is released.
OLECompleteDrag | Fired on the source control after a drop to inform it that a drag/drop operation was either performed or canceled.
OLEDragDrop | Fired when a source component is dropped onto a grid control.
OLEDragOver | Fired when a grid control is the target of the drag/drop operation.
OLEGiveFeedback | Occurs at the source control of an OLE drag/drop operation to give visual feedback to the end user.
OLESetData | Fired on the source control when a target component performs the GetData method on the source’s DataObject object.
OLEStartDrag | Fired after an OLE drag/drop operation is initiated either manually or automatically.
OnInit | Fired when grid is initialized.
PostMessageEvent | Fired when there are messages posted with the PostMessage method.
RowColChange | Fired when current cell changes to a different cell.
RowHeadClick | Fired when a row heading is clicked.
RowHide | Fired before a grid row is hidden.
RowMove | Fired before a grid row is dropped to a new position.
RowResize | Fired before a grid row is resized.
SelChange | Fired when the user selects row, column or range.
ValidateEdit | Fired before the grid exits cell edit mode.
ValueItemError | Fired when user enters a value not included in the ValueItems collection.
VirtualAddRow | Fired when a new row is added to the grid in virtual data mode.
VirtualDeleteRow | Fired when a row is deleted from the grid in virtual data mode.
VirtualReadData | Fired when virtual mode grid needs data for a row.
VirtualWriteData | Fired when virtual mode grid needs to modify data.


AfterClickSort Method

AfterClickSort Event
Fired after a column is sorted by a click on the column's header.
Syntax

SGGrid_AfterClickSort(ColIndex As Long)

Arguments
ColIndex A long that represents the index of the column.

Remarks

The AfterClickSort event occurs after a column has been sorted as a result of clicking on the column's heading. It is not fired after sorting with the Sort method. If sorting was canceled in the BeforeClickSort event, this event will not occur.

Note: event occurs only if properties CacheAllRecords and ColumnClickSort are both set to True.

Show Example
Copy Code [image] Show Me

The following code sets first row on the top after sorting.

Private Sub SGGrid1_AfterClickSort(ByVal ColIndex As Long)

   SGGrid1.TopRow = 0

End Sub

Back to topic


AfterDelete Method

AfterDelete Event
Fired after a record has been deleted from the grid.
Syntax | SGGrid_AfterDelete
Arguments | None

Remarks

Before row is deleted, grid fires the BeforeDelete event and if delete operation is not canceled, grid deletes a row. The AfterDelete event occurs after the row is deleted.

Show Example
Copy Code [image] Show Me

The following code resizes grid depending on the rows count.

Private Sub SGGrid1_AfterDelete()
   If SGGrid1.Rows.Count < 2 Then Exit Sub

   SGGrid1.Height = SGGrid1.Rows.At(1).Height * SGGrid1.Rows.Count
End Sub

Back to topic


AfterEdit Method

AfterEdit Event
Fired after the cell exits edit mode.
Syntax

SGGrid_AfterEdit(RowKey As Long, ColIndex As Long)

Arguments
RowKey | A long that represents the row's key.
ColIndex | A long that represents the index of the column.

Remarks

The AfterEdit event is fired when a cell exits edit mode. It is fired even if no changes were made to the cell. If editing was canceled in the BeforeEdit event, the AfterEdit event will not occur.

Show Example
Copy Code [image] Show Me

The following code changes the editing mode after editing.

Private Sub SGGrid1_AfterEdit(ByVal RowKey As Long, ByVal ColIndex As Long)
   SGGrid1.Editing = False
End Sub

Back to topic


AfterGroupChange Method

AfterGroupChange Event
Fired after the user has changed, added or removed a group in the BeeGrid control.
Syntax

SGGrid_AfterGroupChange(Operation As sgGroupOperation, GroupOrColIndex As Long)

Arguments
Operation | An sgGroupOperation value that represents a grouping action. It can be either the sgGroupAdd (1), sgGroupRemove (2) or sgGroupMove (3).
GroupOrColIndex | A Long value that depends on the Operation value. If Operation is equal to sgGroupRemove, this value is the index of the dragged column. If Operation is equal to sgGroupAdd or sgGroupMove, this value is the index of the dragged group.

Settings

The settings for Operation are:

Name | Value | Description
sgGroupAdd | 1 | A new group is about to be added.
sgGroupRemove | 2 | A group is about to be deleted.
sgGroupMove | 3 | A group is moved from one position to the other position.

Remarks

The AfterGroupChange event occurs when a column header is dropped into the group-by box and if grouping action was not canceled in the BeforeGroupChange event. In this event you can customize attributes of the newly created group, or change attributes of the un-grouped column (e.g. hide it).

If Operation is equal to sgGroupRemove, GroupOrColIndex is the index of the dragged column.
If Operation is equal to sgGroupAdd or sgGroupMove, GroupOrColIndex is the index of the dragged group.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the AfterGroupChange and the BeforeGroupChange events to control a grouping operations. To try the example, place BeeGrid on a form, paste the code into the Declarations section and press F5.

Private Sub SGGrid1_AfterGroupChange _
   (ByVal Operation As sgGroupOperation, ByVal GroupOrColIndex As Long)

   Select Case Operation
      Case sgGroupAdd
         Dim grp As SGGroup

         Set grp = SGGrid1.Groups(GroupOrColIndex)

         If grp.GroupingColumn = "Month" Then
            'create calculations
            grp.Calculations.Add sgCalcMinimum, "Day"
            grp.Calculations.Add sgCalcMaximum, "Day"
            grp.Calculations.Add sgCalcAverage, "Amount"
            grp.Calculations.Add sgCalcSum, "Amount"
            'use formulas for header and footer text
            grp.HeaderTextSource = sgGrpHdrFireFetchText
            grp.FooterTextSource = sgGrpFooterFireFetchText
            SGGrid1.Columns("Month").Hidden = True
         ElseIf grp.GroupingColumn = "Day" Then
            grp.Calculations.Add sgCalcMaximum, "Amount"
            grp.HeaderTextSource = sgGrpHdrFormula
            grp.HeaderFormula = "GroupingValue & '    Total: ' & GroupCalc(1)"
         End If

         Set grp = Nothing
      Case sgGroupRemove
         If SGGrid1.Columns(GroupOrColIndex).Key = "Month" Then
            SGGrid1.Columns(GroupOrColIndex).Hidden = False
         End If
   End Select
End Sub

Private Sub SGGrid1_BeforeGroupChange _
   (ByVal Operation As sgGroupOperation, ByVal GroupOrColIndex As Long, _
   ByVal NewIndex As Long, SortOrder As sgSortOrder, _
   SortType As sgSortType, _
   ShowFooter As Boolean, Cancel As Boolean)

   Select Case Operation
      Case sgGroupAdd
         Dim col As SGColumn

         Set col = SGGrid1.Columns(GroupOrColIndex)

         If col.Key = "Month" Then
            ShowFooter = True
         ElseIf col.Key = "Amount" Then
            Cancel = True
         End If
      Case sgGroupMove
         Dim grp As SGGroup

         Set grp = SGGrid1.Groups(GroupOrColIndex)
         'Month is always the first group
         If grp.GroupingColumn = "Month" Then
            Cancel = (NewIndex = 2)
         ElseIf grp.GroupingColumn = "Day" Then
            Cancel = (NewIndex = 1)
         End If
   End Select
End Sub

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).Parent.Row.GroupHeading

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup

   With SGGrid1
      'create columns and rows
      .DataColCount = 0
      .DataRowCount = 1000
      .FitLastColumn = True
      .ColumnClickSort = True
   End With

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)

   SGGrid1_AfterGroupChange sgGroupAdd, 1

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


AfterGroupCollapse Method

AfterGroupCollapse Event
Fired after the user collapses a group.
Syntax

SGGrid_AfterGroupCollapse(GroupIndex As Integer, RowKey As Long)

Arguments
GroupIndex | An Integer that represents the index of the group being collapsed.
RowKey | A Long that represents the key of the group heading row being collapsed.

Remarks

The AfterGroupCollapse event is fired after a group has been collapsed.


AfterGroupExpand Method

AfterGroupExpand Event
Fired after the user expands a group.
Syntax

SGGrid_AfterGroupExpand(GroupIndex As Integer, RowKey As Long)

Arguments
GroupIndex | An Integer that represents the index of the group being expanded.
RowKey | A Long that represents the key of the group heading row being expanded.

Remarks

The AfterGroupExpand event is fired after a group has been expanded.


AfterInsert Method

AfterInsert Event
Fired after the user inserts a new record into the grid.
Syntax | SGGrid_AfterInsert
Arguments | None

Remarks

The AfterInsert event occurs after the user inserts a new row into the grid. Inserting row from the code doesn't fire the event. Before this event the BeforeInsert event occurs. If insertion was canceled in the BeforeInsert event, the AfterInsert event will not be fired.

The AfterInsert event is fired in all data modes.

If the BeforeUpdate event is canceled, then the AfterUpdate and AfterInsert events will not be fired.

Note: the event occurs only if the AllowAddNew property is set to true.

Show Example
Copy Code [image] Show Me

The following example sets a row tag to New when a new row is added. Click a button to paint new rows to green. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button. Add few rows and press a button.

Private Sub Command1_Click()
   Dim row As SGRow

   For Each row In SGGrid1.Rows
      If row.Tag = "New" Then
         row.Style.BackColor = vbGreen
         row.Redraw
      End If
   Next
End Sub

Private Sub SGGrid1_AfterInsert()
   SGGrid1.Rows.Current.Tag = "New"
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Long, j As Integer

   SGGrid1.AllowAddNew = True

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         SGGrid1.Array.Value(i, j) = "Row ->" & i
      Next j, i
End Sub

Back to topic


AfterScroll Method

AfterScroll Event
Fired after the grid scrolls.
Syntax

SGGrid_AfterScroll(OldTopRow As Long, OldLeftCol As Long, NewTopRow As Long, NewLeftCol As Long)

Arguments
OldTopRow | A Long that represents the position of the former top row.
OldLeftCol | A Long that represents the position of the former left column.
NewTopRow | A Long that represents the position of the current top row.
NewLeftCol | A Long that represents the position of the current left column.

Remarks

The AfterScroll event occurs after the user scrolls the grid's contents or after the Scroll method is applied.

This event isn't fired when the TopRow property is changed.

Show Example
Copy Code [image] Show Me

The following example scrolls the grid's cells every 2 seconds. To try the example, place the SGGrid and Timer control on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ar As SGArray
   Dim i As Integer
   Const TEXT_HEIGHT = 32

   SGGrid1.DataColCount = 2
   SGGrid1.DataRowCount = 100
   SGGrid1.EqualRowHeight = True
   SGGrid1.RowNumbering = True
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.FitLastColumn = True
   'grid inherit scale mode by the patent
   Me.ScaleMode = vbPoints
   SGGrid1.Font.Size = TEXT_HEIGHT
   SGGrid1.Font.Name = "Arial"
   SGGrid1.Rows.At(1).Height = TEXT_HEIGHT + TEXT_HEIGHT / 10
   'set columns
   SGGrid1.Columns(1).Caption = "Home"
   SGGrid1.Columns(1).Width = (SGGrid1.ClientWidth - SGGrid1.Columns(1).Width) / 2
   SGGrid1.Columns(2).Caption = "Visitor"
   'load sample data
   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 0) = "Team " & Trim((i + 1) * 2 - 1)
      ar.Value(i, 1) = "Team " & Trim((i + 1) * 2)
   Next

   Set ar = Nothing
   'enable timer
   Timer1.Interval = 2000
   Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
   Dim iVisibleRows As Integer

   If SGGrid1.BottomRow = SGGrid1.RowCount - 1 Then
      SGGrid1.Scroll -SGGrid1.RowCount, 0
   Else
      iVisibleRows = SGGrid1.BottomRow - SGGrid1.TopRow
      SGGrid1.Scroll iVisibleRows, 0
   End If
End Sub

Private Sub SGGrid1_AfterScroll(ByVal oldTopRow As Long, _
   ByVal oldLeftCol As Long, _
   ByVal newTopRow As Long, _
   ByVal newLeftCol As Long)

   SGGrid1.Caption = "Positions from " & _
      newTopRow & " to " & SGGrid1.BottomRow
End Sub

Back to topic


AfterUpdate Method

AfterUpdate Event
Fired after grid data has been written to the database.
Syntax | SGGrid_AfterUpdate
Arguments | None

Remarks

The AfterUpdate event occurs after the changes have been written to the data source.

The BeforeUpdate event occurs before the AfterUpdate event. If the BeforeUpdate event has been canceled, the AfterUpdate event will not be triggered.

Note: the event occurs only if the AllowEdit property is set to true.

Show Example
Copy Code [image] Show Me

The following example paints the updated cell.

Private Sub SGGrid1_AfterUpdate()

   SGGrid1.CurrentCell.Style.BackColor = vbYellow
   SGGrid1.CurrentCell.Redraw

End Sub

Back to topic


BeforeClickSort Method

BeforeClickSort Event
Fired before a column is sorted by a click on the column's header.
Syntax

SGGrid_BeforeClickSort(ColIndex As Long, CancelSort As Boolean)

Arguments
ColIndex | A long that represents the index of the column.
CancelSort | A boolean that may be set to True to prevent the sort.

Remarks

The BeforeClickSort event occurs before a column is sorted as a result of clicking on the column's heading. It is not fired before sorting with the Sort method. Sorting can be canceled through this event.

Note: event occurs only if properties CacheAllRecords and ColumnClickSort are both set to True.

Show Example
Copy Code [image] Show Me

The following code shows how to prevent sorting of binary columns.

Private Sub SGGrid1_BeforeClickSort(ByVal ColIndex As Long, cancelSort As Boolean)
   If SGGrid1.Columns(ColIndex).DataType = sgtBinary Then
      cancelSort = True
   End If
End Sub

Back to topic


BeforeDelete Method

BeforeDelete Event
Fired before a record is deleted from the grid.
Syntax

SGGrid_BeforeDelete(CancelDelete As Boolean)

Arguments
CancelDelete A boolean that determines whether the row is allowed to be deleted.

Remarks

The BeforeDelete event occurs before the user deletes the current row from the grid. It also occurs when you use the SGRows object's Remove method from code. After a row has been deleted, the grid will fire the AfterDelete event.

If you set the CancelDelete to True, deleting will be canceled and AfterDelete event will not be triggered.

Show Example
Copy Code [image] Show Me

The following code shows how to display confirmation message before deletion.

Private Sub SGGrid1_BeforeDelete(cancelDelete As Boolean)
   cancelDelete = MsgBox("Are you sure you want to delete current row!", _
      vbQuestion + vbYesNo + vbDefaultButton2, "Confirm row delete") = vbNo
End Sub

Back to topic


BeforeEdit Method

BeforeEdit Event
Fired before the cell enters edit mode.
Syntax

SGGrid_BeforeEdit(RowKey As Long, ColIndex As Long, KeyASCII As Integer, Cancel As Boolean)

Arguments
RowKey | A long that represents the row's key.
ColIndex | A long that represents the index of the column.
KeyASCII | An integer that returns a standard numeric ANSI keycode. Keyascii is passed by reference; changing it sends a different character to the grid control. Changing keyascii to 0 cancels the keystroke so the object receives no character.
Cancel | A boolean that may be set to True to prevent the user from editing the cell.

Remarks

The BeforeEdit event occurs before a cell enters editing mode. It allows you to prevent editing by setting the Cancel parameter to True.

Event is triggered in these situations:

  • Grid is not in the editing mode and user types a character.
  • User presses F2 key.
  • User double-clicks an editable cell.
  • Moving from one cell to the other cell while grid is in the edit mode.
  • By setting the SGGrid object's Editing property to True while grid is not in the edit mode.

Show Example
Copy Code [image] Show Me

The following code allows edit mode only for numeric entries.

Private Sub SGGrid1_BeforeEdit(ByVal RowKey As Long, ByVal ColIndex As Long, ByVal keyASCII As Integer, cancel As Boolean)
   If ColIndex < 4 Then
      cancel = Not IsNumeric(Chr(keyASCII))
   End If
End Sub

Back to topic


BeforeGroupChange Method

BeforeGroupChange Event
Fired when the user has changed, added or removed a group in the BeeGrid control.
Syntax

SGGrid_BeforeGroupChange(Operation As sgGroupOperation, GroupOrColIndex As Long, NewIndex As Long, SortOrder As sgSortOrder, SortType As sgSortType, ShowFooter As Boolean, Cancel As Boolean)

Arguments
Operation | An sgGroupOperation value that represents a grouping action. It can be either the sgGroupAdd (1), sgGroupRemove (2) or sgGroupMove (3).
GroupOrColIndex | A Long value that depends on the Operation value. If Operation is equal to sgGroupAdd, this value is the index of the dragged column. If Operation is equal to sgGroupRemove or sgGroupMove, this value is the index of the dragged group.
NewIndex | A Long value that represents the new group index. If the user removes a group, this value is set to -1.
SortOrder | An sgSortOrder expression. Change SortOrder enable or disable sorting. Possible values are listed in Settings.
SortType | An sgSortType expression. Change SortType to change sorting parameters. Possible values are listed in Settings.
ShowFooter | A Boolean expression that indicates whether the group footer is shown.
Cancel | A Boolean that can be set to True, to prevent the user from adding, removing or moving a group.

Settings

The settings for Operation are:

Name | Value | Description
sgGroupAdd | 1 | A new group is about to be added.
sgGroupRemove | 2 | A group is about to be deleted.
sgGroupMove | 3 | A group is moved from one position to the other position.
The settings for SortType are:

Name | Value | Description
sgSortTypeDefault | 0 | Convert values to the column's data type before comparing.
sgSortTypeCustom | 1 | Fire the CompareCell event to compare two values.
sgSortTypeNumber | 2 | Convert to double-precision values before comparing.
sgSortTypeString | 3 | Convert to string values before comparing.
sgSortTypeNoCaseString | 4 | Convert to string values before comparing. Ignore case.
sgSortTypeDateTime | 5 | Convert to date-time values before comparing.
The settings for SortOrder are:

Name | Value | Description
sgNoSorting | 0 | Do not sort.
sgSortAscending | 1 | Sort in ascending order.
sgSortDescending | 2 | Sort in descending order.

Remarks

The BeforeGroupChange event occurs when a column header is dropped into the group-by box, but before a group is added, deleted or moved. In this event's handler, you can enable or disable sorting (if recordset is already sorted), change sorting parameters, show or hide group footer and eventually, cancel user actions.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the AfterGroupChange and the BeforeGroupChange events to control a grouping operations. To try the example, place BeeGrid on a form, paste the code into the Declarations section and press F5.

Private Sub SGGrid1_AfterGroupChange _
   (ByVal Operation As sgGroupOperation, ByVal GroupOrColIndex As Long)

   Select Case Operation
      Case sgGroupAdd
         Dim grp As SGGroup

         Set grp = SGGrid1.Groups(GroupOrColIndex)

         If grp.GroupingColumn = "Month" Then
            'create calculations
            grp.Calculations.Add sgCalcMinimum, "Day"
            grp.Calculations.Add sgCalcMaximum, "Day"
            grp.Calculations.Add sgCalcAverage, "Amount"
            grp.Calculations.Add sgCalcSum, "Amount"
            'use formulas for header and footer text
            grp.HeaderTextSource = sgGrpHdrFireFetchText
            grp.FooterTextSource = sgGrpFooterFireFetchText
            SGGrid1.Columns("Month").Hidden = True
         ElseIf grp.GroupingColumn = "Day" Then
            grp.Calculations.Add sgCalcMaximum, "Amount"
            grp.HeaderTextSource = sgGrpHdrFormula
            grp.HeaderFormula = "GroupingValue & '    Total: ' & GroupCalc(1)"
         End If

         Set grp = Nothing
      Case sgGroupRemove
         If SGGrid1.Columns(GroupOrColIndex).Key = "Month" Then
            SGGrid1.Columns(GroupOrColIndex).Hidden = False
         End If
   End Select
End Sub

Private Sub SGGrid1_BeforeGroupChange _
   (ByVal Operation As sgGroupOperation, ByVal GroupOrColIndex As Long, _
   ByVal NewIndex As Long, SortOrder As sgSortOrder, _
   SortType As sgSortType, _
   ShowFooter As Boolean, Cancel As Boolean)

   Select Case Operation
      Case sgGroupAdd
         Dim col As SGColumn

         Set col = SGGrid1.Columns(GroupOrColIndex)

         If col.Key = "Month" Then
            ShowFooter = True
         ElseIf col.Key = "Amount" Then
            Cancel = True
         End If
      Case sgGroupMove
         Dim grp As SGGroup

         Set grp = SGGrid1.Groups(GroupOrColIndex)
         'Month is always the first group
         If grp.GroupingColumn = "Month" Then
            Cancel = (NewIndex = 2)
         ElseIf grp.GroupingColumn = "Day" Then
            Cancel = (NewIndex = 1)
         End If
   End Select
End Sub

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).Parent.Row.GroupHeading

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup

   With SGGrid1
      'create columns and rows
      .DataColCount = 0
      .DataRowCount = 1000
      .FitLastColumn = True
      .ColumnClickSort = True
   End With

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)

   SGGrid1_AfterGroupChange sgGroupAdd, 1

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


BeforeInsert Method

BeforeInsert Event
Fired before the user inserts a new record into the grid.
Syntax

SGGrid_BeforeInsert(CancelInsert As Boolean)

Arguments
CancelInsert A boolean that may be set to True to prevent the user from inserting the row.

Remarks

The BeforeInsert event occurs when the user initiates editing of the new row. Depending of the NewRowPos property, new row can be positioned at the top or at the bottom of the grid. If the AllowAddNew property is False, the user cannot add a new record and the BeforeInsert event will not be triggered. In addition, if a row is inserted from the code, event will not be fired.

The BeforeInsert Event is fired in all data modes.

Show Example
Copy Code [image] Show Me

The following example prevents the user from inserting a new row if the first cell in the current row is empty.

Private Sub SGGrid1_BeforeInsert(cancelInsert As Boolean)
   If IsEmpty(SGGrid1.Rows.At(SGGrid1.row).Cells(1).Value) Then
      cancelInsert = True
   End If
End Sub

Back to topic


BeforeRowColChange Method

BeforeRowColChange Event
Fired when the user attempts to move to a different cell.
Syntax

SGGrid_BeforeRowColChange(CancelMove As Boolean)

Arguments
CancelMove A boolean that may be set to True to prevent the user from changing the current cell.

Remarks

The BeforeRowColChange event occurs when the user attempts to move to a different cell. The user can move using the navigation keys, enter key, tab key or the mouse. Event will not be triggered if focus has been changed from the code.

Show Example
Copy Code [image] Show Me

The following code prevents user from moving with PageUp and PageDown keys.

Private Const VK_PRIOR = &H21  ' PGUP
Private Const VK_NEXT = &H22   ' PGDN
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Private Sub SGGrid1_BeforeRowColChange(cancelMove As Boolean)

   If GetKeyState(VK_PRIOR) < 0 Or GetKeyState(VK_NEXT) < 0 Then
      cancelMove = True
   End If

End Sub

Back to topic

See Also

SGGrid


BeforeUpdate Method

BeforeUpdate Event
Fired before data is moved from the grid's buffer to the database.
Syntax

SGGrid_BeforeUpdate(CancelUpdate As Boolean)

Arguments
CancelUpdate A boolean that may be set to True to prevent the update from occurring.

Remarks

When the user edits a row, the grid keeps edited row in the internal buffer. The BeforeUpdate event occurs before data is moved from the grid's internal row buffer to the data source.
Data is moved from the grid's internal buffer when:

  • the user moves to another row
  • the grid's Update method is executed
  • the bound recordset Update method is executed

This event gives your application an opportunity to check the individual row cells before they are committed to the data source.

Update can be canceled by setting the CancelUpdate parameter to True. If update is canceled, the user can not move focus to another row and the AfterUpdate and the AfterInsert events will not be triggered.

Note: the event occurs only if the AllowEdit property is set to true.

Show Example
Copy Code [image] Show Me

The following example shows how to use the BeforeUpdate event to validate data.

Private Sub SGGrid1_BeforeUpdate(cancelUpdate As Boolean)
   Dim cell As SGCell

   For Each cell In SGGrid1.Rows.Current.Cells
      Select Case cell.ColKey
         Case "FileDate"
            If Not IsDate(cell.Value) Then
               MsgBox cell.Value & " is not valid date!", vbInformation
               cancelUpdate = True
            End If
         Case "Size"
            If Not IsNumeric(cell.Value) Then
               MsgBox cell.Value & " is not valid number!", vbInformation
               cancelUpdate = True
            End If
      End Select
   Next
End Sub

Back to topic


ButtonClick Method

ButtonClick Event
Fired when the user clicks an action button on a cell.
Syntax

SGGrid_ButtonClick(RowKey As Long, ColIndex As Long, Cancel As Boolean)

Arguments
RowKey | A long that represents the key of the row clicked on.
ColIndex | A long that represents the index of the column clicked on.
Cancel | A boolean that may be set to True to prevent a drop-down window to be shown.

Remarks

The ButtonClick is fired when the current cell's built-in button is clicked. The built-in button is enabled for a column when the column control Type is set to sgCellDropDown or sgCellDropList. In addition, button is enabled when control's ShowButton property is set to sgShowButtonFocused or sgShowButtonAlways.

Show Example
Copy Code [image] Show Me

The following example shows how to use the ButtonClick event for the data input.

Private Sub Form_Load()
   SGGrid1.Columns(1).Control.ShowButton = sgShowButtonFocused
End Sub

Private Sub SGGrid1_ButtonClick(ByVal RowKey As Long, ByVal ColIndex As Long, cancel As Boolean)

   Dim sDir$

   sDir = InputBox("Choose folder", "Folder", "C:\Temp")

   SGGrid1.CurrentCell.Value = sDir

End Sub

Back to topic


Change Method

Change Event
Fired after the content of the cell edit control has changed.
Syntax | SGGrid_Change
Arguments | None

Remarks

The event occurs when the user changes contents of the grid's current cell. It will not occur if cell content is changed from the code.

The Change event will be fired in the following situations:

  • the user enters or deletes a character
  • the user pastes data from the clipboard
  • the user selects a new item in the cell editor's popup

Note: the event occurs only if the AllowEdit property is set to true.

Show Example
Copy Code [image] Show Me

The following example multiplies the "Quantity" and "Price" columns and fills the "Amount" column with results.

Private Sub SGGrid1_Change()
   Dim iColPrice As Integer
   Dim iColAmount As Integer

   If SGGrid1.Col = SGGrid1.Columns("Quantity").Position Then
      iColPrice = SGGrid1.Columns("Price").Position
      iColAmount = SGGrid1.Columns("Amount").Position
      SGGrid1.Rows.Current.Cells(iColAmount).Value = Val(SGGrid1.Value) * _
         Val(SGGrid1.Rows.Current.Cells(iColPrice))
      SGGrid1.Rows.Current.Cells(iColAmount).Redraw
   End If
End Sub

Private Sub Form_Load()
   SGGrid1.Columns.RemoveAll False
   SGGrid1.Columns.Add "Quantity"
   SGGrid1.Columns.Add "Price"
   SGGrid1.Columns.Add "Amount"
End Sub

Back to topic


Click Method

Click Event
Fired when a mouse click occurs.
Syntax | SGGrid_Click
Arguments | None

Remarks

The Click event occurs when the user presses and then releases left mouse button over the grid.

When the user clicks on a grid, following sequence of events is triggered:

  • MouseDown
  • BeforeRowColChange (if the user clicked a non-current cell)
  • RowColChange (if the user clicked a non-current cell)
  • MouseUp
  • Click

Note: the Click event is not fired when the user clicks on the in-cell button. Instead, the ButtonClick event is triggered.

Show Example
Copy Code [image] Show Me

The following code forces editing mode on first click.

Private Sub SGGrid1_Click()
   SGGrid1.Editing = True
End Sub

Back to topic


ColHeadClick Method

ColHeadClick Event
Fired when a column heading is clicked.
Syntax

SGGrid_ColHeadClick(ColIndex As Long)

Arguments
ColIndex A long that represents the index of the column.

Remarks

The ColHeadClick event occurs when the user presses then releases left mouse button over the column's heading.

This event can be fired only if the HeadingRowCount is not set to 0.

When the user clicks on a column heading, following sequence of events is triggered:

  • MouseDown
  • ColHeadClick
  • BeforeClickSort (if the property ColumnClickSort is set to true)
  • AfterClickSort (if the property ColumnClickSort is set to true and sorting isn't canceled through BeforeClickSort event)

Show Example
Copy Code [image] Show Me

The following example changes font color when a column's header is clicked. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   Dim Col As SGColumn

   For Each Col In SGGrid1.Columns
      Col.HeadingStyle.Font.Bold = False
      Col.HeadingStyle.ForeColor = vbBlack
   Next

   SGGrid1.Columns(ColIndex).HeadingStyle.Font.Bold = True
   SGGrid1.Columns(ColIndex).HeadingStyle.ForeColor = vbRed
   SGGrid1.Redraw sgHitHeadingRow
End Sub

Back to topic


ColHide Method

ColHide Event
Fired before a grid column is hidden.
Syntax

SGGrid_ColHide(ColIndex As Long, CancelHide As Boolean)

Arguments
ColIndex | A long that represents the index of the column to be hidden.
CancelHide | A boolean that may be set to True, to prevent the user from hiding a column.

Remarks

The ColHide event occurs if:

  • a column's property Hidden is set to True
  • the user drags a column outside of the grid area

The user can drag a column out of the grid only if the UserDragging property is set to sgAllowColDrag or sgAllowRowColDrag and the UserHiding property is set to sgAllowColHide or sgAllowRowColHide.

Typically, you use this event to prevent the user from hiding a particular column.

Show Example
Copy Code [image] Show Me

The following code prevents the user from hiding column "Country".

Private Sub SGGrid1_ColHide(ByVal ColIndex As Long, cancelHide As Boolean)

   cancelHide = (SGGrid1.Columns("Country").ColIndex = ColIndex)

End Sub

Back to topic


ColMove Method

ColMove Event
Fired before a grid column is dropped to a new position.
Syntax

SGGrid_ColMove(ColIndex As Long, NewPosition As Long, CancelMove As Boolean)

Arguments
ColIndex | A long that represents the ColIndex of the column to be moved.
NewPosition | A long that indicates the new position for the column.
CancelMove | A boolean that may be set to True, to prevent the user from moving the column.

Remarks

The ColMove event occurs if:

  • a column position has been changed from the code
  • the user drops a column into the new position

The following code moves column to the new position:

SGGrid1.Columns.At(1).Position = 5
- or -
SGGrid1.Columns("Invoices").Position = 5
- or -
SGGrid1.Columns(1).Position = 5

The user can drag a column only if the UserDragging property is set to sgAllowColDrag or sgAllowRowColDrag.

Typically, you use this event to prevent the user from moving a particular column.

Show Example
Copy Code [image] Show Me

The folowing example prevents the user from removing the first column from the first position. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_ColMove( _
   ByVal ColIndex As Long, _
   ByVal newPosition As Long, _
   cancelMove As Boolean)

   If newPosition = 1 Or ColIndex = 1 Then
      cancelMove = True
   End If

End Sub

Private Sub Form_Load()
   SGGrid1.DataColCount = 5
End Sub

Back to topic


ColResize Method

ColResize Event
Fired before a grid column is resized.
Syntax

SGGrid_ColResize(ColIndex As Long, CancelResize As Boolean)

Arguments
ColIndex | A long that represents the index of the column to be resized.
CancelResize | A boolean that may be set to True, to prevent the user from resizing the column.

Remarks

The event occurs when the user has resized a column. If you change column width from the code, the event is not fired.

The user can resize a column only if the UserResizing property is set to sgAllowColResizing or sgAllowRowColResizing and column's AllowSizing property is set to False.

Typically, you use this event to prevent the user from resizing a particular column.

Show Example
Copy Code [image] Show Me

The folowing code prevents the user from resizing the first column outside given range.

Private Sub SGGrid1_ColResize(ByVal ColIndex As Long, cancelResize As Boolean)

   If ColIndex = 1 Then
      Dim sinWidth As Single

      sinWidth = SGGrid1.Columns(ColIndex).Width
      cancelResize = (sinWidth < 305 Or sinWidth > 1200)
   End If
End Sub

Back to topic


CompareCells Method

CompareCells Event
Fired when grid needs to compare two cells.
Syntax

SGGrid_CompareCells(RowKey1 As Long, ColIndex1 As Long, RowKey2 As Long, ColIndex2 As Long, Result As Integer)

Arguments
RowKey1 | A long that represents the key of the first cell's row.
ColIndex1 | A long that represents the index of the first cell's column.
RowKey2 | A long that represents the key of the second cell's row.
ColIndex2 | A long that represents the index of the second cell's column.
Result | An integer that must be initialized with the comparation result. It can be one of these values: 1 if the value in the first cell is bigger than the value in the second cell 0 if values in the first and second cells are equal -1 if the value in the first cell is smaller than the value in the second cell

Remarks

The CompareCells event occurs when the grid needs to compare two cells. It will be fired when sorting a column and sorting type is set to sgSortTypeCustom.

Show Example
Copy Code [image] Show Me

The following example sorts the first column by the last digit. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_CompareCells _
   (ByVal RowKey1 As Long, ByVal ColIndex1 As Long, _
   ByVal RowKey2 As Long, ByVal ColIndex2 As Long, _
   Result As Integer)
   Dim cell1 As SGCell, cell2 As SGCell
   Dim iMod1 As Integer, iMod2 As Integer

   Set cell1 = SGGrid1.Cell(RowKey1, SGGrid1.Columns(ColIndex1).Key)
   Set cell2 = SGGrid1.Cell(RowKey2, SGGrid1.Columns(ColIndex2).Key)
   'get the last digit
   iMod1 = CLng(cell1.Value) Mod 10
   iMod2 = CLng(cell2.Value) Mod 10
   'sort by the last digit
   If iMod1 = iMod2 Then Result = 0
   If iMod1 > iMod2 Then Result = 1
   If iMod1 < iMod2 Then Result = -1

   Set cell1 = Nothing
   Set cell2 = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, sKey As String
   Dim i As Long, j As Integer

   'assign grid array to variable
   Set ar = SGGrid1.Array

   SGGrid1.DataRowCount = 20
   SGGrid1.DataColCount = 2
   'load sample data
   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 1000)
      Next
   Next

   Set ar = Nothing
   'if sort type is sgSortTypeCustom the CompareCells event is fired
   sKey = SGGrid1.Columns(1).Key
   SGGrid1.Sort -1, -1, sKey, sgSortAscending, sgSortTypeCustom
End Sub

Back to topic


DataSourceChanged Method

DataSourceChanged Event
Fired when the data source changes
Syntax | SGGrid_DataSourceChanged
Arguments | None

Remarks

The DataSourceChanged event is fired when a bound data source is first loaded or changed. It is not fired in the sgUnbound and both virtual data modes.

This event is useful when you need to refresh the grid's groups.

Show Example
Copy Code [image] Show Me

The following example uses the DataSourceChanged event to refresh groups.

Private Sub SGGrid1_DataSourceChanged()

   If SGGrid1.Groups.Count = 0 Then Exit Sub

   SGGrid1.RefreshGroups
End Sub

Back to topic


DblClick Method

DblClick Event
Fired when a mouse double click occurs.
Syntax | SGGrid_DblClick
Arguments | None

Remarks

Occurs when the user presses and releases a mouse button and then presses and releases it again over the grid. It doesn't occur while a double clicked cell is in editing mode.

Mouse events occur in this order:

  • MouseDown
  • MouseUp
  • Click (only left button over the grid)
  • DblClick
  • MouseUp

Show Example
Copy Code [image] Show Me

The following example paints the current cell on a user double-click. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_DblClick()
   Dim lColor As Long

   lColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
   SGGrid1.CurrentCell.Style.BackColor = lColor
   SGGrid1.CurrentCell.Redraw

End Sub

Back to topic


DropDownOpen Method

DropDownOpen Event
Fired when popup part of the cell editor is opened.
Syntax | SGGrid_DropDownOpen
Arguments | None

Remarks

The DropDownOpen event occurs before a drop down list appears.

The user can open a drop down list by clicking on a built-in button or by pressing the Alt+Down Arrow combination.

The event can be fired only if a column's control type is set to either sgCellDropDown or sgCellDropList.

Show Example
Copy Code [image] Show Me

The following code resizes a drop down list depending on the position of current row. SGGrid1.Columns(1).Control.Type=sgCellDropDown

Private Sub SGGrid1_DropDownOpen()
   Dim lTop As Long

   lTop = SGGrid1.Rows.Current.Top + SGGrid1.Rows.Current.Height

   SGGrid1.Columns(1).Control.Height = SGGrid1.Height - lTop

End Sub

Back to topic


Error Method

Error Event
Fired when data access error occurs.
Syntax

SGGrid_Error(ErrorCode As Long, ShowMessage As Boolean)

Arguments
ErrorCode | A long that identifies the error that occurred.
ShowMessage | A boolean that may be set to False to suppress error message display.

Remarks

You can use the ErrorText property to retrieve the error string.

Show Example
Copy Code [image] Show Me

The following code displays an error message in the grid's caption instead of in a message box.

Private Sub SGGrid1_Error(ByVal errorCode As Long, _
   showMessage As Boolean)
   SGGrid1.Caption = SGGrid1.ErrorText
   showMessage = False
End Sub

Back to topic


FetchCellStyle Method

FetchCellStyle Event
Fired to retrieve cell style.
Syntax

SGGrid_FetchCellStyle(RowKey As Long, ColIndex As Long, CellValue As Variant, CellStyle As IsgStyle)

Arguments
RowKey | A long that represents the Key of the cell's row.
ColIndex | A long that represents the index of the cell's column.
CellValue | A variant that represents the cell's value.
CellStyle | A SGStyle object used to override the style of the cell being displayed.

Remarks

The FetchCellStyle event occurs when the grid is about to draw a cell in a column whose FetchCellStyle property is set to True.

Typically, use the FetchCellStyle event to change the appearance of individual cells.

Show Example
Copy Code [image] Show Me

The following example paints cells using a cell value to get color. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchCellStyle(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal cellValue As Variant, _
   ByVal cellStyle As IsgStyle)
   cellStyle.BackColor = QBColor(cellValue Mod 16)
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.DataRowCount = 12
   SGGrid1.Columns(1).FetchCellStyle = True
   SGGrid1.GroupByBoxVisible = False

   For i = 0 To SGGrid1.DataRowCount - 1
      SGGrid1.Array.Value(i, 0) = i + 1
   Next
End Sub

Back to topic


FetchCellTip Method

FetchCellTip Event
Fired to retrieve cell tip size, text, picture and style.
Syntax

SGGrid_FetchCellTip(RowKey As Long, ColIndex As Long, CellKind As sgCellKind, Width As Single, Height As Single, CellTipText As String, Picture As Variant, TipStyle As IsgStyle)

Arguments
RowKey | A long that represents the row key of the cell whose tip is being retrieved.
ColIndex | A long that represents the column index of the cell whose tip is being retrieved.
CellKind | A constant that represents the kind of the cell whose tip is being retrieved.
Width | Can be set to request a width for the tool tip window. Specified in the terms of the container's coordinate system. If set to -1, grid control will use default tip width.
Height | Can be set to request a height for the tool tip window. Specified in the terms of the container's coordinate system. If set to -1, grid control will use default tip height.
CellTipText | A string that contains the text to be displayed in the tool tip window.
Picture | A variant that represents a picture. You can pass a Picture object or a long that represents the index of the image from the image list assigned to the grid's Images property. You can also use the grid's built-in pictures by specifying values from sgbipFirst to sgbipLast.
TipStyle | A SGStyle object used to override the tip's default style. You cannot set the style's BkgStyle property to sgCellBkgNone.

Settings

The settings for CellKind are:

Name | Value | Description
sgCellStandard | 0 | Standard cell.
sgCellGroupHeader | 2 | Cell is a group header cell.
sgCellGroupFooter | 3 | Cell is a group footer cell.
sgCellPreviewPane | 4 | Cell is a preview pane.
sgCellGroupByBox | 5 | Cell is a group-by box.
sgCellGroupByHeadingCell | 6 | Cell is a column heading inside the group-by box.

Remarks

The event occurs whenever cursor is idle over the grid's cell for amount of time defined by the CellTipsDelay property.

Use this event to set text, picture, size and style of the cell tip popup window.

To fire this event set the CellTips property to sgCellTipsFloat or sgCellTipsStatic.

Show Example
Copy Code [image] Show Me

The following example uses the FetchCellTip event to take control over the tool tip display. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchCellTip(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal cellKind As sgCellKind, _
   Width As stdole.OLE_XSIZE_CONTAINER, _
   Height As stdole.OLE_YSIZE_CONTAINER, _
   cellTipText As String, Picture As Variant, _
   ByVal tipStyle As IsgStyle)
   Dim col As SGColumn, cell As SGCell

   Set col = SGGrid1.Columns(ColIndex)
   Set cell = SGGrid1.Rows(RowKey).Cells(col.Position)

   cellTipText = cell.Text & vbCrLf
   cellTipText = cellTipText & "This example uses the FetchCellTip event to " & _
      "create user defined tool tip."

   If col.Control.Type = sgCellDropDown And Not cell.Row.Heading Then
      Picture = col.ValueItems.DisplayItem(cell.Text).DisplayPicture

      tipStyle.PictureAlignment = sgPicAlignLeftTop
      tipStyle.WordWrap = True
   End If

   Width = 2100
   Height = 1000

   tipStyle.Appearance = sg3D
   tipStyle.BackColor = QBColor(15 - ColIndex)

   Set cell = Nothing
   Set col = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray

   SGGrid1.DataRowCount = 0
   SGGrid1.DefaultRowHeight = 305
   SGGrid1.DataRowCount = 10
   SGGrid1.DataColCount = 4

   SGGrid1.CellTips = sgCellTipsFloat
   SGGrid1.CellTipsDelay = 500

   SGGrid1.Columns.At(1).Style. _
      DisplayType = sgDisplayTextAndPicture
   SGGrid1.Columns.At(2).Style. _
      DisplayType = sgDisplayPicture
   SGGrid1.Columns.At(3).Style. _
      DisplayType = sgDisplayText

   For i = 1 To 3
      With SGGrid1.Columns.At(i)
         .Control.Type = sgCellDropDown
         For j = 1 To 10
            .ValueItems.Add j, "Item " & Trim(j), sgbipFirst + j
         Next
      End With
   Next

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 9) + 1
      Next
   Next
End Sub

Back to topic


FetchColumnData Method

FetchColumnData Event
Fetches unbound column data when the grid is in DAO or ADO bound mode.
Syntax

SGGrid_FetchColumnData(RowKey As Long, ColIndex As Long, RowBookmark As Variant, Value As Variant)

Arguments
RowKey | A long that represents the row Key of the cell whose data is being fetched.
ColIndex | A long that represents the column index of the cell whose data is being fetched.
RowBookmark | A variant that represents the row bookmark of the cell whose data is being fetched.
Value | A variant used to transfer data to the cell.

Remarks

This event occurs when the grid has unbound columns. Unbound columns have the DBField property set to an empty string ("") and the DBIndex property set to a negative value. To create an unbound column, set column's DBField property to an empty string.

The following code creates an unbound column:

SGGrid1.Columns("Field1").DBField = ""

However, code below doesn't work because the DBIndex property is read only.

SGGrid1.Columns("Field1").DBIndex = -1

Typically, you use this event to display the result of the calculation based on other columns.

Show Example
Copy Code [image] Show Me

The following example uses the FetchColumnData event to multiply first two columns and to display result in the unbound column. The property SkipReadOnly is set to True to speed up data entering. The example uses the KeyPressEdit event to restricts data entry to numeric values. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 3
   SGGrid1.AllowAddNew = True

   With SGGrid1.Columns.At(3)
      .DBField = ""  'unbound column
      .ReadOnly = True
      .Caption = "Col1 * Col2"
   End With
   'add some data
   SGGrid1.Array.Value(0, 0) = 2
   SGGrid1.Array.Value(0, 1) = 3

   SGGrid1.GroupByBoxVisible = False
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.SkipReadOnly = True
End Sub

Private Sub SGGrid1_FetchColumnData _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal RowBookmark As Variant, Value As Variant)
   Dim ar As SGArray
   Dim lRowDataIndex As Long

   Set ar = SGGrid1.Array
   'use first and second cols get value for the unbound col
   lRowDataIndex = SGGrid1.Rows(RowKey).DataIndex
   Value = ar.Value(lRowDataIndex, 0) * ar.Value(lRowDataIndex, 1)
End Sub

Private Sub SGGrid1_KeyPressEdit(ByVal RowKey As Long, _
    ByVal ColIndex As Long, keyASCII As Integer)

    'allow back space
    if keyASCII = vbKeyBack Then Exit Sub

    If keyASCII < vbKey0 Or keyASCII > vbKey9 Then
        keyASCII = 0
    End if
End Sub

Back to topic


FetchGroupFooterStyle Method

FetchGroupFooterStyle Event
Fired to retrieve group footer style.
Syntax

SGGrid_FetchGroupFooterStyle(GroupIndex As Integer, RowKey As Long, FooterStyle As IsgStyle)

Arguments
GroupIndex | An integer that represents the index of the group whose footer style is being fetched.
RowKey | A long that represents the key of the group footer row.
FooterStyle | A SGStyle object used to override the style of the group footer cell being displayed.

Remarks

To enable the FetchGroupFooterStyle event, set group's FetchFooterStyle property to True.

Show Example
Copy Code [image] Show Me

The following example fills the grid with random numbers. Groups them by odd and even. It uses the FetchGroupFooterStyle event to set style and the FetchGroupFooterText event to set a footer text. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupFooterStyle _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   ByVal FooterStyle As IsgStyle)

   With FooterStyle
      If SGGrid1.Rows(RowKey).Parent.GroupingValue = 0 Then
         .ForeColor = &H88
      Else
         .ForeColor = &H880000
      End If
      .TextAlignment = sgAlignCenterCenter
      .Font.Bold = True
   End With
End Sub

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)

   Text = SGGrid1.Rows(RowKey).Parent.Row.Cells(0).Value
   Text = Text & ". The average value is " & _
      Round(SGGrid1.Rows(RowKey).Parent.CalculationResult(1), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim lCount As Long

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then
      lCount = SGGrid1.GroupHeadings(1).CalculationResult(2)
      Text = "There are " & lCount & " even numbers"
   Else
      lCount = SGGrid1.GroupHeadings(2).CalculationResult(2)
      Text = "There are " & lCount & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .DataType = sgtLong
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 12

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 100)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue
   Next

   Set ar = Nothing

   With SGGrid1.Groups.Add("EvenOdd", sgSortAscending, _
      sgSortTypeNumber, True, True)
      .HeaderTextSource = sgGrpHdrFireFetchText
      .FetchFooterStyle = True
      .FooterTextSource = sgGrpFooterFireFetchText
      .Calculations.Add sgCalcAverage, "Number"
      .Calculations.Add sgCalcCount, "EvenOdd"
   End With

   SGGrid1.CollapseAll
End Sub

Back to topic


FetchGroupFooterText Method

FetchGroupFooterText Event
Fired to retrieve group footer text.
Syntax

SGGrid_FetchGroupFooterText(GroupIndex As Integer, RowKey As Long, Text As String)

Arguments
GroupIndex | An integer that represents the index of the group whose footer text is being fetched.
RowKey | A long that represents the key of the group footer row.
Text | A string that contains the text to be displayed in the group footer.

Remarks

To enable the FetchGroupFooterText event, set group's FooterTextSource property to sgGrpFooterFireFetchText.

Show Example
Copy Code [image] Show Me

The following example fills the grid with random numbers. Groups them by odd and even. It uses the FetchGroupFooterStyle event to set style and the FetchGroupFooterText event to set a footer text. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupFooterStyle _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   ByVal FooterStyle As IsgStyle)

   With FooterStyle
      If SGGrid1.Rows(RowKey).Parent.GroupingValue = 0 Then
         .ForeColor = &H88
      Else
         .ForeColor = &H880000
      End If
      .TextAlignment = sgAlignCenterCenter
      .Font.Bold = True
   End With
End Sub

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)

   Text = SGGrid1.Rows(RowKey).Parent.Row.Cells(0).Value
   Text = Text & ". The average value is " & _
      Round(SGGrid1.Rows(RowKey).Parent.CalculationResult(1), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim lCount As Long

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then
      lCount = SGGrid1.GroupHeadings(1).CalculationResult(2)
      Text = "There are " & lCount & " even numbers"
   Else
      lCount = SGGrid1.GroupHeadings(2).CalculationResult(2)
      Text = "There are " & lCount & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .DataType = sgtLong
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 12

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 100)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue
   Next

   Set ar = Nothing

   With SGGrid1.Groups.Add("EvenOdd", sgSortAscending, _
      sgSortTypeNumber, True, True)
      .HeaderTextSource = sgGrpHdrFireFetchText
      .FetchFooterStyle = True
      .FooterTextSource = sgGrpFooterFireFetchText
      .Calculations.Add sgCalcAverage, "Number"
      .Calculations.Add sgCalcCount, "EvenOdd"
   End With

   SGGrid1.CollapseAll
End Sub

Back to topic


FetchGroupHeaderData Method

FetchGroupHeaderData Event
Fired to retrieve group header text and/or picture.
Syntax

SGGrid_FetchGroupHeaderData(GroupIndex As Integer, RowKey As Long, Text As String, PictureExpanded As Variant, PictureCollapsed As Variant)

Arguments
GroupIndex | An integer that represents the index of the group whose header data is being fetched.
RowKey | A long that represents the key of the group header row.
Text | A string that contains the text to be displayed in the group header.
PictureExpanded | A variant that represents a picture drawn when group is expanded. You can pass a Picture object or a long that represents the index of the image from the image list assigned to the grid's Images property. You can also use the grid's built-in pictures by specifying values from sgbipFirst to sgbipLast.
PictureCollapsed | A variant that represents a picture drawn when group is collapsed. You can pass a Picture object or a long that represents the index of the image from the image list assigned to the grid's Images property. You can also use the grid's built-in pictures by specifying values from sgbipFirst to sgbipLast.

Remarks

To enable the FetchGroupHeaderData event, set group's HeaderTextSource property to sgGrpHdrFireFetchText.

Note: you will be able to set expanded or collapsed pictures only if the PictureCollapsed or the PictureExpanded properties of the Group object are set to sgGroupHeaderFetchPicture.

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers. It creates two groups, by odd/even numbers and by mod of seven. It uses the GroupHeadings property to create the group header caption. Paints group headers using the FetchGroupHeaderStyle event. Use the CommandButton to remove the current row. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim lKey As Long

   If SGGrid1.DataRowCount = 0 Then Exit Sub

   lKey = SGGrid1.Rows.Current.Key

   Select Case SGGrid1.Rows.Current.Type
      Case sgGroupHeader
         SGGrid1.GroupHeadings.RemoveGroup lKey
      Case sgSimpleRow
         SGGrid1.Rows.Remove lKey
   End Select
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim lCount As Long, gh As SGGroupHeading

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then

      For Each gh In SGGrid1.GroupHeadings(1).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " even numbers"
   Else
      For Each gh In SGGrid1.GroupHeadings(2).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_FetchGroupHeaderStyle _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   ByVal HeaderStyle As IsgStyle)

   With HeaderStyle
      .BackColor = QBColor(SGGrid1.Rows(RowKey).Cells(0).Value)
      .ForeColor = vbWhite
      .TextAlignment = sgAlignCenterCenter
      .Font.Bold = True
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("ModSeven")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 120

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue Mod 7
      ar.Value(i, 2) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrFireFetchText

   With SGGrid1.Groups.Add("ModSeven", sgSortAscending, _
      sgSortTypeNumber, False, False)
      .FetchHeaderStyle = True
      .HeaderTextSource = sgGrpHdrFormula
      .HeaderFormula = "GroupingValue"
   End With

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic


FetchGroupHeaderStyle Method

FetchGroupHeaderStyle Event
Fired to retrieve group header style.
Syntax

SGGrid_FetchGroupHeaderStyle(GroupIndex As Integer, RowKey As Long, HeaderStyle As IsgStyle)

Arguments
GroupIndex | An integer that represents the index of the group whose header style is being fetched.
RowKey | A long that represents the key of the group header row.
HeaderStyle | A SGStyle object used to override the style of the group header cell being displayed.

Remarks

To enable the FetchGroupHeaderStyle event, set group's FetchHeaderStyle property to True..

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers. It creates two groups, by odd/even numbers and by mod of seven. It uses the GroupHeadings property to create the group header caption. Paints group headers using the FetchGroupHeaderStyle event. Use the CommandButton to remove the current row. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim lKey As Long

   If SGGrid1.DataRowCount = 0 Then Exit Sub

   lKey = SGGrid1.Rows.Current.Key

   Select Case SGGrid1.Rows.Current.Type
      Case sgGroupHeader
         SGGrid1.GroupHeadings.RemoveGroup lKey
      Case sgSimpleRow
         SGGrid1.Rows.Remove lKey
   End Select
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim lCount As Long, gh As SGGroupHeading

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then

      For Each gh In SGGrid1.GroupHeadings(1).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " even numbers"
   Else
      For Each gh In SGGrid1.GroupHeadings(2).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_FetchGroupHeaderStyle _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   ByVal HeaderStyle As IsgStyle)

   With HeaderStyle
      .BackColor = QBColor(SGGrid1.Rows(RowKey).Cells(0).Value)
      .ForeColor = vbWhite
      .TextAlignment = sgAlignCenterCenter
      .Font.Bold = True
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("ModSeven")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 120

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue Mod 7
      ar.Value(i, 2) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrFireFetchText

   With SGGrid1.Groups.Add("ModSeven", sgSortAscending, _
      sgSortTypeNumber, False, False)
      .FetchHeaderStyle = True
      .HeaderTextSource = sgGrpHdrFormula
      .HeaderFormula = "GroupingValue"
   End With

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic


FetchScrollTip Method

FetchScrollTip Event
Fired to retrieve scroll tip size, text, picture and style.
Syntax

SGGrid_FetchScrollTip(bar As sgScrollTip, Index As Variant, Width As Single, Height As Single, ScrollTipText As String, Picture As Variant, TipStyle As IsgStyle)

Arguments
bar | An sgScrollTip value that represents a scrollbar for which this tip is retrieved. It can be either the sgScrollTipsHorizontal (0) or sgScrollTipsVertical (1).
Index | A variant that represents either the key of the row or index of the column for which the tip is being retrieved.
Width | Can be set to request a width for the tool tip window. Specified in the terms of the container's coordinate system. If set to -1, grid control will use default tip width.
Height | Can be set to request a height for the tool tip window. Specified in the terms of the container's coordinate system. If set to -1, grid control will use default tip height.
ScrollTipText | A string that contains the text to be displayed in the tool tip window.
Picture | A variant that represents a picture. You can pass a Picture object or a long that represents the index of the image from the image list assigned to the grid's Images property. You can also use the grid's built-in pictures by specifying values from sgbipFirst to sgbipLast.
TipStyle | A SGStyle object used to override the tip's default style. You cannot set the style's BkgStyle property to sgCellBkgNone.

Settings

The settings for bar are:

Name | Value | Description
sgScrollTipsNone | 0 | Scroll tips are not displayed.
sgScrollTipsHorizontal | 1 | Show scroll tips for the horizontal scroll bar.
sgScrollTipsVertical | 2 | Show scroll tips for the vertical scroll bar.
sgScrollTipsBoth | 3 | Show scroll tips for both the horizontal and vertical scroll bars.

Remarks

The FetchScrollTip event occurs when the user scrolls grid with a scrollbar.

To fire this event, the grid's ScrollBarTips property has to be set to sgScrollTipsHorizontal, sgScrollTipsVertical or sgScrollTipsBoth.

Show Example
Copy Code [image] Show Me

The following example uses the FetchScrollTip event to customize scroll bars tool tip. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchScrollTip(ByVal bar As sgScrollTip, _
   ByVal index As Variant, Width As stdole.OLE_XSIZE_CONTAINER, _
   Height As stdole.OLE_YSIZE_CONTAINER, scrollTipText As String, _
   Picture As Variant, ByVal tipStyle As IsgStyle)
   Static lLastRow As Long
   Static iLastCol As Integer

   If bar = sgScrollTipsVertical Then
      'param index represent RowKey
      With SGGrid1.Rows(index)
         'set tip picture depending of the
         'scroll direction
         If lLastRow > .Position Then
            Picture = sgbipFirst + 3
         Else
            Picture = sgbipFirst + 2
         End If
         'create tip text
         scrollTipText = "Row " & .Position & _
            " of " & SGGrid1.Rows.Count
         tipStyle.BackColor = vbInfoBackground
         'create tool tip border
         tipStyle.BorderColor = tipStyle.BackColor
         tipStyle.Borders = sgCellBorderTop
         tipStyle.BorderSize = _
            .Position * (SGGrid1.ClientHeight / SGGrid1.RowCount)
         'save the last row position
         lLastRow = .Position
      End With
   ElseIf bar = sgScrollTipsHorizontal Then
      'param index represent ColIndex
      With SGGrid1.Columns.At(index)
         'set tip picture depending of the
         'scroll direction
         If iLastCol > .Position Then
            Picture = sgbipFirst + 1
         Else
            Picture = sgbipFirst
         End If
         tipStyle.Borders = sgCellNoBorder
         scrollTipText = "Column Key = " & .Key & " at " & .Position
         'set different tool tip color for even and odd columns
         tipStyle.BackColor = QBColor(.Position Mod 2 + 14)
         'save the last column position
         iLastCol = .Position
      End With
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray
   Dim i As Long, j As Long
   'assign grid array to variable
   Set ar = SGGrid1.Array
   'enable scroll bar tool tips
   SGGrid1.ScrollBarTips = sgScrollTipsBoth
   'create rows and columns
   SGGrid1.DataRowCount = 100
   SGGrid1.DataColCount = 12
   'load test data
   For i = 0 To ar.RowCount - 1
      For j = 0 To ar.ColCount - 1
         ar.Value(i, j) = "Row=" & i & " Col=" & j
      Next
   Next

   Set ar = Nothing
End Sub

Back to topic


FormatText Method

FormatText Event
Fired to enable custom text formating.
Syntax

SGGrid_FormatText(RowKey As Long, ColIndex As Long, CellKind As sgCellKind, Value As Variant)

Arguments
RowKey | A long the represents the row Key of the cell whose data is being formatted.
ColIndex | A long the represents the column index of the cell whose data is being formatted.
CellKind | A constant that represents the kind of the cell whose data is being formatted.
Value | A variant containing the underlying data value. It's also used to transfer the formatted data to be displayed.

Settings

The settings for CellKind are:

Name | Value | Description
sgCellStandard | 0 | Standard cell.
sgCellGroupHeader | 2 | Cell is a group header cell.
sgCellGroupFooter | 3 | Cell is a group footer cell.
sgCellPreviewPane | 4 | Cell is a preview pane.
sgCellGroupByBox | 5 | Cell is a group-by box.
sgCellGroupByHeadingCell | 6 | Cell is a column heading inside the group-by box.

Remarks

The BeeGrid control uses Visual Basic's intrinsic formatting. In cases where these are not available, you can use FormatText event to format text displayed in cells. To fire FormatText event, set the style object's Format member to "FormatText Event".

Show Example
Copy Code [image] Show Me

The following example formats numbers in the first column to be displayed in hexadecimal notation. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.Columns(1).Style.Format = "FormatText Event"
   SGGrid1.Array.Value(0, 0) = 256
   SGGrid1.AllowAddNew = True
End Sub

Private Sub SGGrid1_FormatText _
   (ByVal RowKey As Long, _
   ByVal ColIndex As Long, _
   ByVal CellKind As sgCellKind, _
   Value As Variant)

   If Not IsNumeric(Value) Then Exit Sub

   Value = "&H" & Hex(Value) & "&"
End Sub

Back to topic


GroupByBoxHeaderClick Method

GroupByBoxHeaderClick Event
Fired when the user clicks on the header for a particular grid column in the group-by box.
Syntax

SGGrid_GroupByBoxHeaderClick(GroupIndex As Long)

Arguments
GroupIndex A long that represents the index of the group whose header inside the GroupByBox is being clicked.

Remarks

This event is similar as the ColHeadClick event. You can use this event to apply custom sort or similar action. If you set the ColumnClickSort property to True, the user click on a GroupByBox header will force sorting You cannot use this event to cancel sorting. To cancel sorting use the BeforeClickSort.


KeyDown Method

KeyDown Event
Fired when the user presses a key.
Syntax

SGGrid_KeyDown(KeyCode As Integer, Shift As Integer)

Arguments
KeyCode | An integer representing a Windows key code. You can use the constants from the Visual Basic object library.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.

Remarks

The KeyDown event occurs when the user presses a key while the grid control has focus.

Keystroke events occurs in this order:

  • KeyDown
  • KeyDownEdit (only during cell editing)
  • KeyPress (read only column) or KeyPressEdit (during cell editing)
  • KeyUp
  • KeyUpEdit (only during cell editing)

Show Example
Copy Code [image] Show Me

The following code prevents the grid from switching to edit mode as a result of pressing the F2 function key (by default, F2 switches the grid to edit mode).

Private Sub SGGrid1_KeyDown(keyCode As Integer, shift As Integer)

   If keyCode = vbKeyF2 Then keyCode = 0

End Sub

Back to topic


KeyDownEdit Method

KeyDownEdit Event
Fired when the user presses a key in the cell edit mode.
Syntax

SGGrid_KeyDownEdit(RowKey As Long, ColIndex As Long, KeyCode As Integer, Shift As Integer)

Arguments
RowKey | A long that represents the row key of the cell entering edit mode.
ColIndex | A long that represents the column index of the cell entering edit mode.
KeyCode | An integer representing a Windows key code. You can use the constants from the Visual Basic object library.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.

Remarks

The KeyDownEdit event occurs when user presses a key while grid is in cell-editing mode.


KeyPress Method

KeyPress Event
Fired when the user presses a key.
Syntax

SGGrid_KeyPress(KeyASCII As Integer)

Arguments
KeyASCII An integer that returns a standard numeric ANSI keycode. Keyascii is passed by reference; changing it sends a different character to the grid control. Changing keyascii to 0 cancels the keystroke so the object receives no character.

Remarks

The KeyPress event occurs when the user presses and releases an ANSI key while the grid control has focus.

Show Example
Copy Code [image] Show Me

The following example uses the character entered into a cell to search the current column for a value that starts with that character.

Private Sub SGGrid1_KeyPress(keyASCII As Integer)
   Dim SGRow As SGRow
   Dim sCurrCol As String

   On Error Resume Next

   sCurrCol = SGGrid1.Columns.Current.Key

   Set SGRow = SGGrid1.Rows.Find(sCurrCol, sgOpRegEx, _
      "^" & Chr(keyASCII), , SGGrid1.Row + 1, , sgSearchText)

   If Not SGRow Is Nothing Then
      SGGrid1.Row = SGRow.Position
      Set SGRow = Nothing
   End If
End Sub

Back to topic


KeyPressEdit Method

KeyPressEdit Event
Fired when the user presses a key in the cell edit mode.
Syntax

SGGrid_KeyPressEdit(RowKey As Long, ColIndex As Long, KeyASCII As Integer)

Arguments
RowKey | A long that represents the row key of the cell that is currently edited.
ColIndex | A long that represents the column index of the cell that is currently edited.
KeyASCII | An integer that returns a standard numeric ANSI keycode. Keyascii is passed by reference; changing it sends a different character to the grid control. Changing keyascii to 0 cancels the keystroke so the object receives no character.

Remarks

The KeyPressEdit event occurs when the user presses and releases an ANSI key while grid is in cell-editing mode.

Show Example
Copy Code [image] Show Me

The following example restricts data entry to numeric values and the BackSpace. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_KeyPressEdit(ByVal RowKey As Long, _
      ByVal ColIndex As Long, keyASCII As Integer)

   'allow back space
   if keyASCII = vbKeyBack Then Exit Sub

   If keyASCII < vbKey0 Or keyASCII > vbKey9 Then
      keyASCII = 0
   End if
End Sub

Back to topic


KeyUp Method

KeyUp Event
Fired when the user presses a key.
Syntax

SGGrid_KeyUp(KeyCode As Integer, Shift As Integer)

Arguments
KeyCode | An integer representing a Windows key code. You can use the constants from the Visual Basic object library.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.

Remarks

The KeyUp event occurs when the user releases a key while the grid control has focus.


KeyUpEdit Method

KeyUpEdit Event
Fired when the user presses a key in the cell edit mode.
Syntax

SGGrid_KeyUpEdit(RowKey As Long, ColIndex As Long, KeyCode As Integer, Shift As Integer)

Arguments
RowKey | A long that represents the row key of the cell that is currently edited.
ColIndex | A long that represents the column index of the cell that is currently edited.
KeyCode | An integer representing a Windows key code. You can use the constants from the Visual Basic object library.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.

Remarks

The KeyPressEdit event occurs when the user releases a key while grid is in cell-editing mode.


MouseDown Method

MouseDown Event
Fired when a mouse button is pressed.
Syntax

SGGrid_MouseDown(Button As Integer, Shift As Integer, X As OLE_XPOS_PIXELS, Y As OLE_YPOS_PIXELS)

Arguments
Button | An integer that identifies the button that was pressed to cause the event. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.
X | A single-precision number that specifies the current x coordinate of the mouse pointer.
Y | A single-precision number that specifies the current y coordinate of the mouse pointer.

Remarks

The MouseDown event is triggered when a mouse button is pressed.

Mouse events occurs in this order:

  • MouseDown
  • MouseUp
  • Click (only left button)

Show Example
Copy Code [image] Show Me

The following example adds a new row when the user right-clicks the columns heading, removes a row when the user right-clicks that row, or removes all but one row when the user clicks the background. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseDown(button As Integer, _
   shift As Integer, x As Single, y As Single)

   If button = vbRightButton Then
      Select Case SGGrid1.HitTest(x, y)
         Case sgHitCell
            SGGrid1.Rows.Remove SGGrid1.Rows.At(SGGrid1.MouseRow).Key
         Case sgHitHeadingRow
            SGGrid1.DataRowCount = SGGrid1.RowCount
            SGGrid1.Rows.At(SGGrid1.DataRowCount).Style.BackColor = _
               QBColor(SGGrid1.DataRowCount Mod 16)
         Case sgHitBkg
            SGGrid1.DataRowCount = 1
            SGGrid1.CellAt(1, 1).Value = x
            SGGrid1.CellAt(1, 2).Value = y
      End Select
   End If
End Sub

Back to topic


MouseMove Method

MouseMove Event
Fired when the mouse moves.
Syntax

SGGrid_MouseMove(Button As Integer, Shift As Integer, X As OLE_XPOS_PIXELS, Y As OLE_YPOS_PIXELS)

Arguments
Button | An integer that corresponds to the state of the mouse buttons in which a bit is set if the button is down. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.
X | A single-precision number that specifies the current x coordinate of the mouse pointer.
Y | A single-precision number that specifies the current y coordinate of the mouse pointer.

Remarks

The MouseMove occurs when the user moves the mouse over the grid.

Show Example
Copy Code [image] Show Me

The following example displays the cursor coordinates in the first and the second cells. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   Select Case SGGrid1.HitTest(x, y)
      Case sgHitNowhere
         Me.Caption = "Mouse move test"
      Case sgHitBkg
         SGGrid1.CellAt(1, 1).Value = x
         SGGrid1.CellAt(1, 2).Value = y
   End Select
End Sub

Back to topic


MouseUp Method

MouseUp Event
Fired when a mouse button is released.
Syntax

SGGrid_MouseUp(Button As Integer, Shift As Integer, X As OLE_XPOS_PIXELS, Y As OLE_YPOS_PIXELS)

Arguments
Button | Returns an integer that identifies the button that was released to cause the event. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.
X | A single-precision number that specifies the current x coordinate of the mouse pointer.
Y | A single-precision number that specifies the current y coordinate of the mouse pointer.

Remarks

The MouseUp event occurs when the user releases the mouse button.

Typically, you use this event to open popup menu on a right click.

Mouse events occur in this order:

  • MouseDown
  • MouseUp
  • Click (only left button)

Show Example
Copy Code [image] Show Me

The following example opens a popup menu on a right click.

Private Sub SGGrid1_MouseUp(button As Integer, _
    shift As Integer, x As Single, y As Single)

   If button = vbRightButton Then
      Me.PopupMenu mnuEditTop
   End If

End Sub

Back to topic


OLECompleteDrag Method

OLECompleteDrag Event
Fired on the source control after a drop to inform it that a drag/drop operation was either performed or canceled.
Syntax

SGGrid_OLECompleteDrag(Effect As Long)

Arguments
Effect A long integer set by the source object identifying the action that has been performed, thus allowing the source to take appropriate action if the component was moved.

Remarks

The OLECompleteDrag event is the final event to be called in an OLE drag/drop operation. This event informs the source component of the action that was performed when the object was dropped onto the target component. The target sets this value through the Effect parameter of the OLEDragDrop event. Based on this, the source can then determine the appropriate action it needs to take. For example, if the object was moved into the target (vbDropEffectMove), the source needs to delete the object from itself after the move.

Show Example
Copy Code [image] Show Me

The following example clears selection after the OLE drag/drop operation.

Private Sub SGGrid1_OLECompleteDrag(Effect As Long)
   SGGrid1.Selection.Clear
End Sub

Back to topic


OLEDragDrop Method

OLEDragDrop Event
Fired when a source component is dropped onto a grid control.
Syntax

SGGrid_OLEDragDrop(Data As IsgDataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)

Arguments
Data | An SGDataObject object containing formats that the source will provide and, in addition, possibly the data for those formats.
Effect | A long integer set by the target component identifying the action that has been performed (if any), thus allowing the source to take appropriate action if the component was moved.
Button | An integer which acts as a bit field corresponding to the state of a mouse button when it is depressed. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.
X | A single-precision number that specifies the current x coordinate of the mouse pointer.
Y | A single-precision number that specifies the current y coordinate of the mouse pointer.

Remarks

The OLEDragDrop event occurs when a source component is dropped onto a target component when the source component determines that a drop can occur. This event occurs only when a grid control is the target of a drag/drop operation and the OLEDropMode property is set to sgOLEDragModeManual.

Show Example
Copy Code [image] Show Me

The following example shows how to use custom data in the OLE drag/drop operation.

Private Sub SGGrid1_OLEDragDrop _
   (ByVal Data As IsgDataObject, Effect As Long, _
   ByVal Button As Integer, ByVal Shift As Integer, _
   ByVal x As Single, ByVal y As Single)
   Dim sData As String
   Dim iPos As Integer
   Dim sRow As String

   On Error Resume Next

   If Not Data.GetFormat(vbCFText) Then Exit Sub
   sData = Data.GetData(vbCFText)
   If Len(sData) = 0 Then Exit Sub

   iPos = InStr(sData, vbCrLf)

   Do Until iPos = 0
      sRow = Left$(sData, iPos - 1)
      sData = Right$(sData, Len(sData) - iPos - 1)

      SGGrid1.Rows.Add sgFormatCharSeparatedValue, sRow, vbTab
      iPos = InStr(1, sData, vbCrLf)
   Loop

   SGGrid1.Rows.Add sgFormatCharSeparatedValue, sData, vbTab
End Sub

Back to topic


OLEDragOver Method

OLEDragOver Event
Fired when a grid control is the target of the drag/drop operation.
Syntax

SGGrid_OLEDragOver(Data As IsgDataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)

Arguments
Data | An SGDataObject object containing formats that the source will provide and, in addition, possibly the data for those formats.
Effect | A long integer initially set by the source object identifying all effects it supports. This parameter must be correctly set by the target component during this event. The value of effect is determined by logically Or'ing together all active effects. The target component should check these effects and other parameters to determine which actions are appropriate for it, and then set this parameter to one of the allowable effects (as specified by the source) to specify which actions will be performed if the user drops the selection on the component. This is a list of possible values: vbDropEffectNone 0 Drop target cannot accept the data. vbDropEffectCopy 1 Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation. vbDropEffectMove 2 Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
Button | An integer which acts as a bit field corresponding to the state of a mouse button when it is depressed. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.
X | A single-precision number that specifies the current x coordinate of the mouse pointer.
Y | A single-precision number that specifies the current y coordinate of the mouse pointer.
State | An integer that corresponds to the transition state of the control being dragged in relation to a target form or control. This is a list of possible values: vbEnter 0 Source component is being dragged within the range of a target. vbLeave 1 Source component is being dragged out of the range of a target. vbOver 2 Source component has moved from one position in the target to another.

Remarks

The OLEDragOver event occurs when a grid control is the target of a drag/drop operation.

Show Example
Copy Code [image] Show Me

The following example changes the grid top when the OLEDragOver occures.

Private Sub SGGrid1_OLEDragOver( _
   ByVal Data As StingaGrid10.IsgDataObject, _
   Effect As Long, ByVal Button As Integer, _
   ByVal Shift As Integer, ByVal x As Single, _
   ByVal y As Single, State As Integer)

   SGGrid1.TopRow = SGGrid1.RowCount - 1

End Sub

Back to topic


OLEGiveFeedback Method

OLEGiveFeedback Event
Occurs at the source control of an OLE drag/drop operation to give visual feedback to the end user.
Syntax

SGGrid_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)

Arguments
Effect | A long integer set by the target component in the OLEDragOver event specifying the action to be performed if the user drops the selection on it. This allows the source to take the appropriate action (such as giving visual feedback). This is a list of possible values: vbDropEffectNone 0 Drop target cannot accept the data. vbDropEffectCopy 1 Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation. vbDropEffectMove 2 Drop results in data being moved from drag source to drop source. The drag source should remove the data from itself after the move.
DefaultCursors | A boolean value which determines whether appropriate default mouse cursor is used, or uses a user-defined mouse cursor. True (default) = use default mouse cursor. False = do not use default cursor.

Remarks

The OLEGiveFeedback occurs after every OLEDragOver event. This event allows the grid to provide visual feedback to the user, such as changing the mouse cursor to indicate what will happen if the user drops the object, or provide visual feedback on the selection to indicate what will happen.

Show Example
Copy Code [image] Show Me

The folloving example changes background style of the grid's selection when the OLE drag/drop operation starts.

Private Sub SGGrid1_OLEGiveFeedback(Effect As Long, defaultCursors As Boolean)
   SGGrid1.Selection.Style.BkgStyle = sgCellBkgDiagCross
   SGGrid1.Redraw
End Sub

Private Sub SGGrid1_OLECompleteDrag(Effect As Long)
   SGGrid1.Selection.Style.BkgStyle = sgCellBkgSolid
End Sub

Back to topic


OLESetData Method

OLESetData Event
Fired on the source control when a target component performs the GetData method on the source’s DataObject object.
Syntax

SGGrid_OLESetData(Data As IsgDataObject, DataFormat As Integer)

Arguments
Data | An SGDataObject object containing formats that the source will provide and, in addition, possibly the data for those formats.
DataFormat | An integer specifying the format of the data that the target component is requesting. The source component uses this value to determine what to load into the SGDataObject object..

Remarks

The OLESetData event occurs on a source component when a target component performs the GetData method on the source’s SGDataObject object, but the data for the specified format has not yet been loaded.

This event allows the source to respond to only one request for a given format of data. When this event is called, the source should check the format parameter to determine what needs to be loaded and then perform the SetData method on the SGDataObject object to load the data, which is then passed back to the target component.

Show Example
Copy Code [image] Show Me

The following example shows how to use the OLESetData event to control data for drag-drop.

Private Sub SGGrid1_OLESetData( _
   ByVal Data As IsgDataObject, _
   dataFormat As Integer)
   Dim rng As SGRange, i As Integer
   Dim sData As String, sgCol As SGColumn

   Data.Clear

   For Each rng In SGGrid1.Selection.Ranges
      For i = rng.TopRow To rng.BottomRow
         sData = sData & SGGrid1.Rows.At(i).GetData _
            (sgFormatCharSeparatedValue, vbTab) & vbCrLf
      Next
   Next

   Set rng = Nothing

   If Len(sData) = 0 Then Exit Sub

   sData = Left$(sData, Len(sData) - 2)
   Data.SetData sData, vbCFText

End Sub

Back to topic


OLEStartDrag Method

OLEStartDrag Event
Fired after an OLE drag/drop operation is initiated either manually or automatically.
Syntax

SGGrid_OLEStartDrag(Data As IsgDataObject, AllowedEffects As Long)

Arguments
Data | An SGDataObject object containing formats that the source will provide and, in addition, possibly the data for those formats.
AllowedEffects | A long integer containing the effects that the source component supports. The programmer should provide the values for this parameter in this event.

Remarks

The OLEStartDrag event occurs when the grid's OLEDrag method is called. It also occurs if the OLEDragMode property is set to Automatic and a drag/drop operation is initiated by the user.

This event enables your application to specify the data formats and drop effects that the source grid supports. It can also be used to insert data into the SGDataObject object.

Show Example
Copy Code [image] Show Me

Private Sub SGGrid1_OLEStartDrag(ByVal data As StingaGrid10.IsgDataObject, allowedEffects As Long)
   data.SetData , vbCFText

   allowedEffects = vbDropEffectCopy
End Sub

Back to topic


OnInit Method

OnInit Event
Fired when grid is initialized.
Syntax | SGGrid_OnInit
Arguments | None

Remarks

Typically, you use this event to initialize the grid independent of its container.

See Also

SGGrid


PostMessageEvent Event

See Also [image] Example

Send us your Feedback

PostMessageEvent Event

Fired when there are messages posted with the PostMessage method.

Syntax

SGGrid_PostMessageEvent(MessageID As Long, Data1 As Variant, Data2 As Variant)

Arguments

MessageID | A Long expression that identifies the message being received.
Data1 | A Variant expression that identifies data associated with the message.
Data2 | A Variant expression that identifies data associated with the message.

Remarks

The PostMessageEvent event is triggered by a call to the grid's PostMessage method. You can use the PostMessage method to perform operation at some later time. Typically, you need to postpone operation which is illegal within the grid event. When the PostMessage method is called, the grid will fire the PostMessageEvent event after all pending operations are completed.

See Also

PostMessage


RowColChange Method

RowColChange Event
Fired when current cell changes to a different cell.
Syntax

SGGrid_RowColChange(LastRowKey As Long, LastColIndex As Long)

Arguments
LastRowKey | A long that represents the key of the previously focused row.
LastColIndex | A long that represents the index of the previously focused column.

Remarks

The current cell position is specified by the grid's Row and Col properties.

Show Example
Copy Code [image] Show Me

The following example uses the first data column as heading column. The first column displays letter to mark row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, rng As SGRange
   SGGrid1.DataColCount = 5
   SGGrid1.DataRowCount = 26

   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.At(1)
      .AllowFocus = False
      .ReadOnly = True
      .Frozen = True
      .Caption = ""
      .AllowSizing = False
      .Width = SGGrid1.Columns.At(0).Width
      .Style.Font.Bold = True
   End With

   SGGrid1.HeadingColCount = 0

   SGGrid1.Styles("Frozen").BackColor = SGGrid1.Styles("Heading").BackColor
   SGGrid1.Styles("Heading").TextAlignment = sgAlignCenterCenter

   Set rng = SGGrid1.CreateRange(sgRangeFree, 0, 0, 0, SGGrid1.DataRowCount)
   rng.ApplyStyle SGGrid1.Styles("Heading")

   Set rng = Nothing

   For i = 65 To 90
      SGGrid1.Array.Value(i - 65, 0) = Chr(i)
   Next
End Sub

Private Sub SGGrid1_ColMove( _
   ByVal ColIndex As Long, _
   ByVal newPosition As Long, _
   cancelMove As Boolean)

   If newPosition = 1 Or ColIndex = 1 Then
      cancelMove = True
   End If

End Sub

Private Sub SGGrid1_ColHide(ByVal ColIndex As Long, cancelHide As Boolean)

   cancelHide = (SGGrid1.Columns.At(0).ColIndex = ColIndex)

End Sub

Private Sub SGGrid1_RowColChange _
   (ByVal LastRowKey As Long, ByVal LastColIndex As Long)
   If LastColIndex > -1 Then
      SGGrid1.Rows(LastRowKey).Cells(0).Style.ForeColor = vbBlack
   End If

   SGGrid1.Rows.Current.Cells(0).Style.ForeColor = vbRed
End Sub

Back to topic


RowHeadClick Method

RowHeadClick Event
Fired when a row heading is clicked.
Syntax

SGGrid_RowHeadClick(RowKey As Long)

Arguments
RowKey A long that represents the key of the clicked row.

Remarks

The RowHeadClick event occurs when the user presses then releases a left mouse button over the row's heading.

This event can be fired only if the HeadingColCount is not set to 0.

Show Example
Copy Code [image] Show Me

The following example uses the RowHeadClick event to sort columns by cells value in the clicked row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Click on the any row head.

Private Sub SGGrid1_RowHeadClick(ByVal RowKey As Long)
   Dim row As SGRow, i As Integer
   Dim j As Integer, iMinValue As Integer
   Dim lVal1 As Long, lVal2 As Long
   'stop drawing
   SGGrid1.RedrawEnabled = False
   'reference the current row
   Set row = SGGrid1.Rows(RowKey)
   'sort columns by values from the current row
   For i = 1 To SGGrid1.DataColCount
      iMinValue = i
      For j = i To SGGrid1.DataColCount
         lVal1 = CLng(row.Cells(j).Value)
         lVal2 = CLng(row.Cells(iMinValue).Value)
         If lVal1 < lVal2 Then iMinValue = j
      Next

      If iMinValue > i Then
         row.Cells(iMinValue).Column.Position = i
      End If
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray, lRndNum As Long
   'create cols and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DefaultColWidth = 505
   SGGrid1.DataColCount = 7
   SGGrid1.DataRowCount = 12

   SGGrid1.GroupByBoxVisible = False
   'add random numbers
   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         lRndNum = CLng(Rnd * 255)
         ar.Value(i, j) = lRndNum
         'paint cells
         SGGrid1.CellAt(i + 1, j + 1).Style.BackColor = _
            RGB(255 - lRndNum, 255, 255)
      Next
   Next

   Set ar = Nothing
End Sub

Back to topic


RowHide Method

RowHide Event
Fired before a grid row is hidden.
Syntax

SGGrid_RowHide(RowKey As Long, CancelHide As Boolean)

Arguments
RowKey | A long that represents the key of the row to be hidden.
CancelHide | A boolean that may be set to True, to prevent the user from hiding the row.

Remarks

The RowHide event occurs if:

  • a row's Hidden property is set to True
  • the user drags a row outside of the grid area

The user can drag a row out of the grid if UserDragging property is set to sgAllowRowDrag or sgAllowRowColDrag and UserHiding property is set to sgAllowRowHide or sgAllowRowColHide.

Show Example
Copy Code [image] Show Me

The following example prevents hiding of the row which contains the changed data.

Private Sub SGGrid1_RowHide(ByVal RowKey As Long, cancelHide As Boolean)
   If (SGGrid1.Rows(RowKey).Status And sgRowStatusDataChanged) Then
      cancelHide = True
   End If
End Sub

Back to topic


RowMove Method

RowMove Event
Fired before a grid row is dropped to a new position.
Syntax

SGGrid_RowMove(RowKey As Long, NewPosition As Long, CancelMove As Boolean)

Arguments
RowKey | A long that represents the key of the row to be moved.
NewPosition | A long that indicates the new position for the row.
CancelMove | A boolean that may be set to True, to prevent the user from moving the row.

Remarks

The RowMove event occurs if:

  • a row position has been changed from the code
  • the user drops a row into the new position

The following code moves a row into the new position:

SGGrid1.Rows.At(1).Position = 5
or
SGGrid1.Rows(1).Position = 5

The user can drag a row only if UserDragging property is set to sgAllowRowDrag or sgAllowRowColDrag.

Show Example
Copy Code [image] Show Me

The folowing example prevents the user from removing first five rows.

Private Sub SGGrid1_RowMove(ByVal RowKey As Long, _
    ByVal newPosition As Long, cancelMove As Boolean)

   If newPosition < 6 Or (SGGrid1.Rows(RowKey).Position < 6) Then
      cancelMove = True
   End If
End Sub

Back to topic


RowResize Method

RowResize Event
Fired before a grid row is resized.
Syntax

SGGrid_RowResize(RowKey As Long, CancelResize As Boolean)

Arguments
RowKey | A long that represents the key of the row to be resized.
CancelResize | A boolean that may be set to True, to prevent the user from resizing the row.

Remarks

This event occurs when the user has resized a row. The event is not fired if you change the row height from the code.

The user can resize a row only if the UserResizing property is set to sgAllowRowResizing or sgAllowRowColResizing and row's AllowSizing property is set to True.

Show Example
Copy Code [image] Show Me

The following example prevents the user from resizing a row out of range.

Private Sub SGGrid1_RowResize(ByVal RowKey As Long, cancelResize As Boolean)
   Dim lNewHeight As Long

   lNewHeight = SGGrid1.Rows(RowKey).Height

   cancelResize = (lNewHeight < 220 Or lNewHeight > 1200)
End Sub

Back to topic


SelChange Method

SelChange Event
Fired when the user selects row, column or range.
Syntax

SGGrid_SelChange(CancelSelect As Boolean)

Arguments
CancelSelect A boolean that may be set to True to cancel the new selection.

Remarks

The event occurs when the user selects a different range of rows or columns with either mouse or keyboard. Changing selection from the code doesn't fire the SelChange event.

Show Example
Copy Code [image] Show Me

The following example shows how to use the IsEmpty to enable/disable the command button.

Private Sub SGGrid1_SelChange(cancelSelect As Boolean)
   Command1.Enabled = Not SGGrid1.Selection.IsEmpty
End Sub

Back to topic


ValidateEdit Method

ValidateEdit Event
Fired before the grid exits cell edit mode.
Syntax

SGGrid_ValidateEdit(RowKey As Long, ColIndex As Long, OldValue As Variant, Cancel As Boolean)

Arguments
RowKey | A long that represents the row key of the cell being validated.
ColIndex | A long that represents the column index of the cell being validated.
OldValue | A variant that represents the cell's value before editing.
Cancel | A boolean that may be set to True to indicate that validation failed.

Remarks

Use this event to validate the user entry. If validation fails, set the Cancel parameter to True.

Show Example
Copy Code [image] Show Me

The folowing example prevents the user from entering a value smaller then the existing one.

Private Sub SGGrid1_ValidateEdit(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal oldValue As Variant, _
   cancel As Boolean)

   If ColIndex = 1 Then
      If Val(SGGrid1.Value) < Val(oldValue) Then
         cancel = True
         SGGrid1.Value = oldValue
      End If
   End If
End Sub

Back to topic


ValueItemError Method

ValueItemError Event
Fired when user enters a value not included in the ValueItems collection.
Syntax

SGGrid_ValueItemError(ColIndex As Long)

Arguments
ColIndex A Long expression that represents the index of the column.

Remarks

The ValueItemError event occurs when the user enters data that is not in the value items list and value items are enabled for the edited column. This event is useful when you want to add a new value to the SGValueItems collection.

For example, you can use this event to add the new value to the database table:

Private Sub SGGrid1_ValueItemError(ByVal ColIndex As Long)
   Dim rs As New ADODB.Recordset
   Dim vis As SGValueItems

   rs.Open "Categories", conn

   rs.AddNew
   rs.Fields("Category") = SGGrid1.Value
   rs.Update

   Set vis = SGGrid1.Columns(ColIndex).ValueItems
   vis.Add CLng(rs.Fields("CategoryId")), SGGrid1.Value

   rs.Close
   Set vis = Nothing
   Set rs = Nothing
End Sub

This event is fired only when the associated SGValueItems collection has its property LimitToList set to True.

Show Example
Copy Code [image] Show Me

The following example uses the ValueItemError event to add new item to ValueItems collection. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_ValueItemError(ByVal ColIndex As Long)
   Dim vis As SGValueItems

   Set vis = SGGrid1.Columns(ColIndex).ValueItems

   vis.Add vis.Count, SGGrid1.Value

   Set vis = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.AllowAddNew = True

   With SGGrid1.Columns.At(1)
      .Control.Type = sgCellDropDown
      With .ValueItems
         .Add 0, "Horse"
         .Add 1, "Dog"
         .Add 2, "Cat"
         .LimitToList = True
      End With
   End With
End Sub

Back to topic


VirtualAddRow Method

VirtualAddRow Event
Fired when a new row is added to the grid in virtual data mode.
Syntax

SGGrid_VirtualAddRow(RowBuffer As IsgRowBuffer, Cancel As Boolean)

Arguments
RowBuffer | An SGRowBuffer object containing data for the new row.
Cancel | A boolean that may be set to True to cancel insertion of the new row.

Remarks

Show Example
Copy Code [image] Show Me

The following example shows how to read, edit, add and delete data in the sgVirtualEvents DataMode. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private marColors() As Long

Private Sub SGGrid1_VirtualAddRow _
   (ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   Dim iColorsCount

   iColorsCount = UBound(marColors)

   RowBuffer.RowIndex = iColorsCount

   If CLng(RowBuffer.Value(1)) = 0 Then
      RowBuffer.Value(1) = RGB(RowBuffer.Value(2), _
         RowBuffer.Value(3), RowBuffer.Value(4))
   End If

   marColors(iColorsCount) = CLng(RowBuffer.Value(1))

   SetRGBValues RowBuffer

   ReDim Preserve marColors(iColorsCount + 1) As Long
End Sub

Private Sub SGGrid1_VirtualDeleteRow _
   (ByVal RowIndex As Long, ByVal RowBookmark As Variant, Cancel As Boolean)
   Dim i

   For i = RowIndex To UBound(marColors) - 1
      marColors(i) = marColors(i + 1)
   Next

   ReDim Preserve marColors(UBound(marColors) - 1) As Long
End Sub

Private Sub SGGrid1_VirtualReadData(ByVal RowBuffer As IsgRowBuffer)
   RowBuffer.Value(1) = marColors(RowBuffer.RowIndex)

   SetRGBValues RowBuffer

   If RowBuffer.RowIndex = UBound(marColors) Then
      RowBuffer.RowIndex = -1
   End If
End Sub

Sub SetRGBValues(RowBuffer As IsgRowBuffer)
   Dim sHex As String

   sHex = Hex(marColors(RowBuffer.RowIndex))
   sHex = String(6 - Len(sHex), "0") & sHex
   RowBuffer.Value(4) = CLng("&H" & Left(sHex, 2))
   RowBuffer.Value(3) = CLng("&H" & Mid(sHex, 3, 2))
   RowBuffer.Value(2) = CLng("&H" & Right(sHex, 2))
End Sub

Private Sub SGGrid1_VirtualWriteData(ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   If RowBuffer.Value(1) = marColors(RowBuffer.RowIndex) Then
      marColors(RowBuffer.RowIndex) = RGB(RowBuffer.Value(2), RowBuffer.Value(3), RowBuffer.Value(4))
      RowBuffer.Value(1) = marColors(RowBuffer.RowIndex)
   Else
      marColors(RowBuffer.RowIndex) = RowBuffer.Value(1)
      SetRGBValues RowBuffer
   End If
End Sub

Sub SGGrid1_OnInit()
   Dim col, row, i
   Const ROW_COUNT = 12

   SGGrid1.RedrawEnabled = False

   SGGrid1.Columns.RemoveAll True
   SGGrid1.CacheAllRecords = True
   SGGrid1.ColumnClickSort = True
   SGGrid1.HeadingColCount = 1
   SGGrid1.BackColor = vbWhite
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True
   SGGrid1.SkipReadOnly = True
   SGGrid1.SelectionMode = sgSelectionNone
   SGGrid1.RowNumbering = True
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GroupByBoxVisible = False

   Set col = CreateColumn("")
   col.ReadOnly = True
   col.FetchCellStyle = True
   col.AllowSizing = False
   col.AllowFocus = False
   col.Style.Borders = sgCellBorderAll
   col.Style.BorderSize = 3
   col.Width = 505
   col.HeadingPicture = sgbipFirst + 6
   col.HeadingStyle.Borders = sgCellNoBorder

   Set col = CreateColumn("Color")
   col.Style.Format = "FormatText Event"
   col.DataWidth = 8
   CreateColumn "Red"
   CreateColumn "Green"
   CreateColumn "Blue"

   ReDim marColors(ROW_COUNT)

   Randomize
   For i = 0 To ROW_COUNT
      marColors(i) = CLng(Rnd * vbWhite)
   Next

   With SGGrid1
      .DataMode = sgVirtualEvents
      .DataRowCount = ROW_COUNT
      .RedrawEnabled = True
   End With
End Sub

Private Function CreateColumn(sCaption As String)
   Dim col As SGColumn

   Set col = SGGrid1.Columns.Add("col" & sCaption)
   col.Style.TextAlignment = sgAlignRightCenter
   col.DataType = sgtLong
   col.Caption = sCaption
   col.DataWidth = 3

   Set CreateColumn = col
   Set col = Nothing
End Function

Private Sub SGGrid1_FetchCellStyle(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellValue As Variant, ByVal CellStyle As IsgStyle)
      CellStyle.BackColor = CLng(SGGrid1.Rows(RowKey).Cells(2))
End Sub

Private Sub SGGrid1_FormatText(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellKind As sgCellKind, Value As Variant)
   On Error Resume Next
   'skip heading row
   If SGGrid1.Rows.At(0).Key <> RowKey Then
      Value = "&H" & Hex(CLng(Value))
   End If
End Sub

Private Sub SGGrid1_KeyPressEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, KeyASCII As Integer)
   'ignore back space
   If KeyASCII = vbKeyBack Then Exit Sub

   If KeyASCII < vbKey0 Or KeyASCII > vbKey9 Then KeyASCII = 0
End Sub

Private Sub SGGrid1_ValidateEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal OldValue As Variant, Cancel As Boolean)
   Dim lMaxValue As Long, lCellValue As Long

   On Error Resume Next

   Err = 0

   Select Case ColIndex
      Case 2
         lMaxValue = vbWhite
      Case Else
         lMaxValue = 255
   End Select

   lCellValue = CLng(SGGrid1.Value)

   If (lCellValue < 0 Or lCellValue > lMaxValue) Or Err <> 0 Then
      SGGrid1.Value = OldValue
      Cancel = True
   End If
End Sub

Back to topic


VirtualDeleteRow Method

VirtualDeleteRow Event
Fired when a row is deleted from the grid in virtual data mode.
Syntax

SGGrid_VirtualDeleteRow(RowIndex As Long, RowBookmark As Variant, Cancel As Boolean)

Arguments
RowIndex | A long that represents data index of the row being deleted.
RowBookmark | A variant that represents bookmark of the row being deleted.
Cancel | A boolean that may be set to True to cancel the delete operation.

Remarks

Show Example
Copy Code [image] Show Me

The following example shows how to read, edit, add and delete data in the sgVirtualEvents DataMode. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private marColors() As Long

Private Sub SGGrid1_VirtualAddRow _
   (ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   Dim iColorsCount

   iColorsCount = UBound(marColors)

   RowBuffer.RowIndex = iColorsCount

   If CLng(RowBuffer.Value(1)) = 0 Then
      RowBuffer.Value(1) = RGB(RowBuffer.Value(2), _
         RowBuffer.Value(3), RowBuffer.Value(4))
   End If

   marColors(iColorsCount) = CLng(RowBuffer.Value(1))

   SetRGBValues RowBuffer

   ReDim Preserve marColors(iColorsCount + 1) As Long
End Sub

Private Sub SGGrid1_VirtualDeleteRow _
   (ByVal RowIndex As Long, ByVal RowBookmark As Variant, Cancel As Boolean)
   Dim i

   For i = RowIndex To UBound(marColors) - 1
      marColors(i) = marColors(i + 1)
   Next

   ReDim Preserve marColors(UBound(marColors) - 1) As Long
End Sub

Private Sub SGGrid1_VirtualReadData(ByVal RowBuffer As IsgRowBuffer)
   RowBuffer.Value(1) = marColors(RowBuffer.RowIndex)

   SetRGBValues RowBuffer

   If RowBuffer.RowIndex = UBound(marColors) Then
      RowBuffer.RowIndex = -1
   End If
End Sub

Sub SetRGBValues(RowBuffer As IsgRowBuffer)
   Dim sHex As String

   sHex = Hex(marColors(RowBuffer.RowIndex))
   sHex = String(6 - Len(sHex), "0") & sHex
   RowBuffer.Value(4) = CLng("&H" & Left(sHex, 2))
   RowBuffer.Value(3) = CLng("&H" & Mid(sHex, 3, 2))
   RowBuffer.Value(2) = CLng("&H" & Right(sHex, 2))
End Sub

Private Sub SGGrid1_VirtualWriteData(ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   If RowBuffer.Value(1) = marColors(RowBuffer.RowIndex) Then
      marColors(RowBuffer.RowIndex) = RGB(RowBuffer.Value(2), RowBuffer.Value(3), RowBuffer.Value(4))
      RowBuffer.Value(1) = marColors(RowBuffer.RowIndex)
   Else
      marColors(RowBuffer.RowIndex) = RowBuffer.Value(1)
      SetRGBValues RowBuffer
   End If
End Sub

Sub SGGrid1_OnInit()
   Dim col, row, i
   Const ROW_COUNT = 12

   SGGrid1.RedrawEnabled = False

   SGGrid1.Columns.RemoveAll True
   SGGrid1.CacheAllRecords = True
   SGGrid1.ColumnClickSort = True
   SGGrid1.HeadingColCount = 1
   SGGrid1.BackColor = vbWhite
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True
   SGGrid1.SkipReadOnly = True
   SGGrid1.SelectionMode = sgSelectionNone
   SGGrid1.RowNumbering = True
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GroupByBoxVisible = False

   Set col = CreateColumn("")
   col.ReadOnly = True
   col.FetchCellStyle = True
   col.AllowSizing = False
   col.AllowFocus = False
   col.Style.Borders = sgCellBorderAll
   col.Style.BorderSize = 3
   col.Width = 505
   col.HeadingPicture = sgbipFirst + 6
   col.HeadingStyle.Borders = sgCellNoBorder

   Set col = CreateColumn("Color")
   col.Style.Format = "FormatText Event"
   col.DataWidth = 8
   CreateColumn "Red"
   CreateColumn "Green"
   CreateColumn "Blue"

   ReDim marColors(ROW_COUNT)

   Randomize
   For i = 0 To ROW_COUNT
      marColors(i) = CLng(Rnd * vbWhite)
   Next

   With SGGrid1
      .DataMode = sgVirtualEvents
      .DataRowCount = ROW_COUNT
      .RedrawEnabled = True
   End With
End Sub

Private Function CreateColumn(sCaption As String)
   Dim col As SGColumn

   Set col = SGGrid1.Columns.Add("col" & sCaption)
   col.Style.TextAlignment = sgAlignRightCenter
   col.DataType = sgtLong
   col.Caption = sCaption
   col.DataWidth = 3

   Set CreateColumn = col
   Set col = Nothing
End Function

Private Sub SGGrid1_FetchCellStyle(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellValue As Variant, ByVal CellStyle As IsgStyle)
      CellStyle.BackColor = CLng(SGGrid1.Rows(RowKey).Cells(2))
End Sub

Private Sub SGGrid1_FormatText(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellKind As sgCellKind, Value As Variant)
   On Error Resume Next
   'skip heading row
   If SGGrid1.Rows.At(0).Key <> RowKey Then
      Value = "&H" & Hex(CLng(Value))
   End If
End Sub

Private Sub SGGrid1_KeyPressEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, KeyASCII As Integer)
   'ignore back space
   If KeyASCII = vbKeyBack Then Exit Sub

   If KeyASCII < vbKey0 Or KeyASCII > vbKey9 Then KeyASCII = 0
End Sub

Private Sub SGGrid1_ValidateEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal OldValue As Variant, Cancel As Boolean)
   Dim lMaxValue As Long, lCellValue As Long

   On Error Resume Next

   Err = 0

   Select Case ColIndex
      Case 2
         lMaxValue = vbWhite
      Case Else
         lMaxValue = 255
   End Select

   lCellValue = CLng(SGGrid1.Value)

   If (lCellValue < 0 Or lCellValue > lMaxValue) Or Err <> 0 Then
      SGGrid1.Value = OldValue
      Cancel = True
   End If
End Sub

Back to topic


VirtualReadData Method

VirtualReadData Event
Fired when virtual mode grid needs data for a row.
Syntax

SGGrid_VirtualReadData(RowBuffer As IsgRowBuffer)

Arguments
RowBuffer An SGRowBuffer object that should be initialized with requested data.

Remarks

Show Example
Copy Code [image] Show Me

The following example shows how to read, edit, add and delete data in the sgVirtualEvents DataMode. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private marColors() As Long

Private Sub SGGrid1_VirtualAddRow _
   (ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   Dim iColorsCount

   iColorsCount = UBound(marColors)

   RowBuffer.RowIndex = iColorsCount

   If CLng(RowBuffer.Value(1)) = 0 Then
      RowBuffer.Value(1) = RGB(RowBuffer.Value(2), _
         RowBuffer.Value(3), RowBuffer.Value(4))
   End If

   marColors(iColorsCount) = CLng(RowBuffer.Value(1))

   SetRGBValues RowBuffer

   ReDim Preserve marColors(iColorsCount + 1) As Long
End Sub

Private Sub SGGrid1_VirtualDeleteRow _
   (ByVal RowIndex As Long, ByVal RowBookmark As Variant, Cancel As Boolean)
   Dim i

   For i = RowIndex To UBound(marColors) - 1
      marColors(i) = marColors(i + 1)
   Next

   ReDim Preserve marColors(UBound(marColors) - 1) As Long
End Sub

Private Sub SGGrid1_VirtualReadData(ByVal RowBuffer As IsgRowBuffer)
   RowBuffer.Value(1) = marColors(RowBuffer.RowIndex)

   SetRGBValues RowBuffer

   If RowBuffer.RowIndex = UBound(marColors) Then
      RowBuffer.RowIndex = -1
   End If
End Sub

Sub SetRGBValues(RowBuffer As IsgRowBuffer)
   Dim sHex As String

   sHex = Hex(marColors(RowBuffer.RowIndex))
   sHex = String(6 - Len(sHex), "0") & sHex
   RowBuffer.Value(4) = CLng("&H" & Left(sHex, 2))
   RowBuffer.Value(3) = CLng("&H" & Mid(sHex, 3, 2))
   RowBuffer.Value(2) = CLng("&H" & Right(sHex, 2))
End Sub

Private Sub SGGrid1_VirtualWriteData(ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   If RowBuffer.Value(1) = marColors(RowBuffer.RowIndex) Then
      marColors(RowBuffer.RowIndex) = RGB(RowBuffer.Value(2), RowBuffer.Value(3), RowBuffer.Value(4))
      RowBuffer.Value(1) = marColors(RowBuffer.RowIndex)
   Else
      marColors(RowBuffer.RowIndex) = RowBuffer.Value(1)
      SetRGBValues RowBuffer
   End If
End Sub

Sub SGGrid1_OnInit()
   Dim col, row, i
   Const ROW_COUNT = 12

   SGGrid1.RedrawEnabled = False

   SGGrid1.Columns.RemoveAll True
   SGGrid1.CacheAllRecords = True
   SGGrid1.ColumnClickSort = True
   SGGrid1.HeadingColCount = 1
   SGGrid1.BackColor = vbWhite
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True
   SGGrid1.SkipReadOnly = True
   SGGrid1.SelectionMode = sgSelectionNone
   SGGrid1.RowNumbering = True
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GroupByBoxVisible = False

   Set col = CreateColumn("")
   col.ReadOnly = True
   col.FetchCellStyle = True
   col.AllowSizing = False
   col.AllowFocus = False
   col.Style.Borders = sgCellBorderAll
   col.Style.BorderSize = 3
   col.Width = 505
   col.HeadingPicture = sgbipFirst + 6
   col.HeadingStyle.Borders = sgCellNoBorder

   Set col = CreateColumn("Color")
   col.Style.Format = "FormatText Event"
   col.DataWidth = 8
   CreateColumn "Red"
   CreateColumn "Green"
   CreateColumn "Blue"

   ReDim marColors(ROW_COUNT)

   Randomize
   For i = 0 To ROW_COUNT
      marColors(i) = CLng(Rnd * vbWhite)
   Next

   With SGGrid1
      .DataMode = sgVirtualEvents
      .DataRowCount = ROW_COUNT
      .RedrawEnabled = True
   End With
End Sub

Private Function CreateColumn(sCaption As String)
   Dim col As SGColumn

   Set col = SGGrid1.Columns.Add("col" & sCaption)
   col.Style.TextAlignment = sgAlignRightCenter
   col.DataType = sgtLong
   col.Caption = sCaption
   col.DataWidth = 3

   Set CreateColumn = col
   Set col = Nothing
End Function

Private Sub SGGrid1_FetchCellStyle(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellValue As Variant, ByVal CellStyle As IsgStyle)
      CellStyle.BackColor = CLng(SGGrid1.Rows(RowKey).Cells(2))
End Sub

Private Sub SGGrid1_FormatText(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellKind As sgCellKind, Value As Variant)
   On Error Resume Next
   'skip heading row
   If SGGrid1.Rows.At(0).Key <> RowKey Then
      Value = "&H" & Hex(CLng(Value))
   End If
End Sub

Private Sub SGGrid1_KeyPressEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, KeyASCII As Integer)
   'ignore back space
   If KeyASCII = vbKeyBack Then Exit Sub

   If KeyASCII < vbKey0 Or KeyASCII > vbKey9 Then KeyASCII = 0
End Sub

Private Sub SGGrid1_ValidateEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal OldValue As Variant, Cancel As Boolean)
   Dim lMaxValue As Long, lCellValue As Long

   On Error Resume Next

   Err = 0

   Select Case ColIndex
      Case 2
         lMaxValue = vbWhite
      Case Else
         lMaxValue = 255
   End Select

   lCellValue = CLng(SGGrid1.Value)

   If (lCellValue < 0 Or lCellValue > lMaxValue) Or Err <> 0 Then
      SGGrid1.Value = OldValue
      Cancel = True
   End If
End Sub

Back to topic


VirtualWriteData Method

VirtualWriteData Event
Fired when virtual mode grid needs to modify data.
Syntax

SGGrid_VirtualWriteData(RowBuffer As IsgRowBuffer, Cancel As Boolean)

Arguments
RowBuffer | An SGRowBuffer object containing new data.
Cancel | A boolean that may be set to True to cancel editing of the row.

Remarks

Show Example
Copy Code [image] Show Me

The following example shows how to read, edit, add and delete data in the sgVirtualEvents DataMode. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private marColors() As Long

Private Sub SGGrid1_VirtualAddRow _
   (ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   Dim iColorsCount

   iColorsCount = UBound(marColors)

   RowBuffer.RowIndex = iColorsCount

   If CLng(RowBuffer.Value(1)) = 0 Then
      RowBuffer.Value(1) = RGB(RowBuffer.Value(2), _
         RowBuffer.Value(3), RowBuffer.Value(4))
   End If

   marColors(iColorsCount) = CLng(RowBuffer.Value(1))

   SetRGBValues RowBuffer

   ReDim Preserve marColors(iColorsCount + 1) As Long
End Sub

Private Sub SGGrid1_VirtualDeleteRow _
   (ByVal RowIndex As Long, ByVal RowBookmark As Variant, Cancel As Boolean)
   Dim i

   For i = RowIndex To UBound(marColors) - 1
      marColors(i) = marColors(i + 1)
   Next

   ReDim Preserve marColors(UBound(marColors) - 1) As Long
End Sub

Private Sub SGGrid1_VirtualReadData(ByVal RowBuffer As IsgRowBuffer)
   RowBuffer.Value(1) = marColors(RowBuffer.RowIndex)

   SetRGBValues RowBuffer

   If RowBuffer.RowIndex = UBound(marColors) Then
      RowBuffer.RowIndex = -1
   End If
End Sub

Sub SetRGBValues(RowBuffer As IsgRowBuffer)
   Dim sHex As String

   sHex = Hex(marColors(RowBuffer.RowIndex))
   sHex = String(6 - Len(sHex), "0") & sHex
   RowBuffer.Value(4) = CLng("&H" & Left(sHex, 2))
   RowBuffer.Value(3) = CLng("&H" & Mid(sHex, 3, 2))
   RowBuffer.Value(2) = CLng("&H" & Right(sHex, 2))
End Sub

Private Sub SGGrid1_VirtualWriteData(ByVal RowBuffer As IsgRowBuffer, Cancel As Boolean)
   If RowBuffer.Value(1) = marColors(RowBuffer.RowIndex) Then
      marColors(RowBuffer.RowIndex) = RGB(RowBuffer.Value(2), RowBuffer.Value(3), RowBuffer.Value(4))
      RowBuffer.Value(1) = marColors(RowBuffer.RowIndex)
   Else
      marColors(RowBuffer.RowIndex) = RowBuffer.Value(1)
      SetRGBValues RowBuffer
   End If
End Sub

Sub SGGrid1_OnInit()
   Dim col, row, i
   Const ROW_COUNT = 12

   SGGrid1.RedrawEnabled = False

   SGGrid1.Columns.RemoveAll True
   SGGrid1.CacheAllRecords = True
   SGGrid1.ColumnClickSort = True
   SGGrid1.HeadingColCount = 1
   SGGrid1.BackColor = vbWhite
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True
   SGGrid1.SkipReadOnly = True
   SGGrid1.SelectionMode = sgSelectionNone
   SGGrid1.RowNumbering = True
   SGGrid1.CellsBorderVisible = False
   SGGrid1.GroupByBoxVisible = False

   Set col = CreateColumn("")
   col.ReadOnly = True
   col.FetchCellStyle = True
   col.AllowSizing = False
   col.AllowFocus = False
   col.Style.Borders = sgCellBorderAll
   col.Style.BorderSize = 3
   col.Width = 505
   col.HeadingPicture = sgbipFirst + 6
   col.HeadingStyle.Borders = sgCellNoBorder

   Set col = CreateColumn("Color")
   col.Style.Format = "FormatText Event"
   col.DataWidth = 8
   CreateColumn "Red"
   CreateColumn "Green"
   CreateColumn "Blue"

   ReDim marColors(ROW_COUNT)

   Randomize
   For i = 0 To ROW_COUNT
      marColors(i) = CLng(Rnd * vbWhite)
   Next

   With SGGrid1
      .DataMode = sgVirtualEvents
      .DataRowCount = ROW_COUNT
      .RedrawEnabled = True
   End With
End Sub

Private Function CreateColumn(sCaption As String)
   Dim col As SGColumn

   Set col = SGGrid1.Columns.Add("col" & sCaption)
   col.Style.TextAlignment = sgAlignRightCenter
   col.DataType = sgtLong
   col.Caption = sCaption
   col.DataWidth = 3

   Set CreateColumn = col
   Set col = Nothing
End Function

Private Sub SGGrid1_FetchCellStyle(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellValue As Variant, ByVal CellStyle As IsgStyle)
      CellStyle.BackColor = CLng(SGGrid1.Rows(RowKey).Cells(2))
End Sub

Private Sub SGGrid1_FormatText(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal CellKind As sgCellKind, Value As Variant)
   On Error Resume Next
   'skip heading row
   If SGGrid1.Rows.At(0).Key <> RowKey Then
      Value = "&H" & Hex(CLng(Value))
   End If
End Sub

Private Sub SGGrid1_KeyPressEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, KeyASCII As Integer)
   'ignore back space
   If KeyASCII = vbKeyBack Then Exit Sub

   If KeyASCII < vbKey0 Or KeyASCII > vbKey9 Then KeyASCII = 0
End Sub

Private Sub SGGrid1_ValidateEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal OldValue As Variant, Cancel As Boolean)
   Dim lMaxValue As Long, lCellValue As Long

   On Error Resume Next

   Err = 0

   Select Case ColIndex
      Case 2
         lMaxValue = vbWhite
      Case Else
         lMaxValue = 255
   End Select

   lCellValue = CLng(SGGrid1.Value)

   If (lCellValue < 0 Or lCellValue > lMaxValue) Or Err <> 0 Then
      SGGrid1.Value = OldValue
      Cancel = True
   End If
End Sub

Back to topic


OLEDBBeeGrid10 Objects

Objects

SGArray Array | SGArray is helper object that can be used to access values displayed in grid cells.
SGDataObject OLEStartDrag OLESetData OLEDragOver OLEDragDrop | SGDataObject object represents formats and data used by OLE drag/drop operations.
SGCell SGCells.Item Cell | SGCell object represents single grid cell.
SGCells SGRow.Cells | Collection of SGCell objects
SGCondition SGStyleCondition.Condition SGCalculation.Condition SGFilter.Condition | SGCondition object represents condition used by other SGGrid objects.
SGCalculation SGCalculations.Item | SGCalculation is a definition for group calculations.
SGCalculations SGGroup.Calculations | Collection of SGCalculation objects
SGValueItem SGValueItems.Item | SGValueItem contains translation from database to display value and picture.
SGValueItems SGColumn.ValueItems | Collection of SGValueItem objects
SGStyle SGColumn.Style SGControl.Style SGStyles.Item SGSelection.Style SGRow.Style SGCell.Style FetchScrollTip FetchCellTip FetchGroupHeaderStyle FetchGroupFooterStyle FetchCellStyle | SGStyle is a definition of visual attributes.
SGStyles Styles | Collection of SGStyle objects.
SGStyleCondition SGStyleConditions.Item | SGStyleCondition encapsulates style object and condition that determines when to apply that style.
SGStyleConditions SGColumn.StyleConditions CellStyleConditions | Collection of SGStyleCondition objects.
SGControl SGColumn.Control | SGControl is object that represents cell editor.
SGColumn SGColumns.Item SGCell.Column | SGColumn is object that represents one grid column.
SGColumns Columns | Collection of SGColumn objects.
SGRow SGRows.Item SGGroupHeading.Row SGRowCollection.Item SGCell.Row | SGRow is object that represents one grid row.
SGRows Rows | Collection of all SGRow objects.
SGRowCollection SGGroupHeading.ChildRows | Collection of child SGRow objects.
SGGroupHeading SGRow.GroupHeading SGGroupHeadings.Item | SGGroupHeading object represents group header row.
SGGroupHeadings SGGroupHeading.Headings GroupHeadings | Collection of SGGroupHeading objects.
SGRange SGRanges.Item CreateRange | SGRange object represents a range of rows, columns or cells.
SGRanges SGSelection.Ranges | Collection of SGRange objects.
SGGroup SGGroupHeading.GroupDef SGGroups.Item | SGGroup is a definition of one hierarchy level.
SGGroups Groups | Collection of SGGroup objects.
SGSelection Selection | SGSelection object can be used to manipulate current selection.
SGFilter SGFilters.Item | SGFilter object represents row filter definition.
SGFilters RowFilters | Collection of SGFilter objects.
SGRowBuffer VirtualAddRow VirtualReadData VirtualWriteData | SGRowBuffer object is row data buffer used to get/set data in virtual mode.


SGArray Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGArray Object

Name: | SGArray
Description: | SGArray is helper object that can be used to access values displayed in grid cells.
GUID: | {A7542961-A71E-11D2-8ED4-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example calculates the estimated time required for loading grid array with data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray
   Dim t As Date
   Dim i As Long, j As Long
   'save start time
   t = Time
   'assign grid array to variable
   Set ar = SGGrid1.Array
   'hide group box
   SGGrid1.GroupByBoxVisible = False
   'create rows and columns
   SGGrid1.DataRowCount = 100
   SGGrid1.DataColCount = 20
   'load test data
   For i = 0 To ar.RowCount - 1
      For j = 0 To ar.ColCount - 1
         ar.Value(i, j) = "Row=" & i & " Col=" & j
      Next
   Next

   Set ar = Nothing
   'show estimate time in the grid's caption
   Me.Caption = "Time: " & DateDiff("s", t, Time)
End Sub

Back to topic

Referenced By

Array


SGArray Properties

ColCount | Returns column count.
RowCount | Returns known row count.
Value | Returns or sets cell's underlying data value.


ColCount Property (SGArray Object)

ColCount Property (SGArray Object)
Returns column count.
Syntax

object.ColCount As Long

The object placeholder represents an object expression that evaluates to the SGArray object.

Remarks

Use the ColCount and RowCount properties to determine the size of the underlying data source.

Show Example
Copy Code [image] Show Me

The following example calculates the estimated time required for loading grid array with data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray
   Dim t As Date
   Dim i As Long, j As Long
   'save start time
   t = Time
   'assign grid array to variable
   Set ar = SGGrid1.Array
   'hide group box
   SGGrid1.GroupByBoxVisible = False
   'create rows and columns
   SGGrid1.DataRowCount = 100
   SGGrid1.DataColCount = 20
   'load test data
   For i = 0 To ar.RowCount - 1
      For j = 0 To ar.ColCount - 1
         ar.Value(i, j) = "Row=" & i & " Col=" & j
      Next
   Next

   Set ar = Nothing
   'show estimate time in the grid's caption
   Me.Caption = "Time: " & DateDiff("s", t, Time)
End Sub

Back to topic


RowCount Property (SGArray Object)

RowCount Property (SGArray Object)
Returns known row count.
Syntax

object.RowCount As Long

The object placeholder represents an object expression that evaluates to the SGArray object.

Remarks

Use the ColCount and RowCount properties to determine the size of the underlying data source. If grid is connected to the OLEDB or ICursor data source, the RowCount property returns row count known at that time.

Show Example
Copy Code [image] Show Me

The following example calculates the estimated time required for loading grid array with data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray
   Dim t As Date
   Dim i As Long, j As Long
   'save start time
   t = Time
   'assign grid array to variable
   Set ar = SGGrid1.Array
   'hide group box
   SGGrid1.GroupByBoxVisible = False
   'create rows and columns
   SGGrid1.DataRowCount = 100
   SGGrid1.DataColCount = 20
   'load test data
   For i = 0 To ar.RowCount - 1
      For j = 0 To ar.ColCount - 1
         ar.Value(i, j) = "Row=" & i & " Col=" & j
      Next
   Next

   Set ar = Nothing
   'show estimate time in the grid's caption
   Me.Caption = "Time: " & DateDiff("s", t, Time)
End Sub

Back to topic


Value Property (SGArray Object)

Value Property (SGArray Object)
Returns or sets cell's underlying data value.

Read/Write at run time. Not available at design time.

Syntax

object.Value As Variant

The object placeholder represents an object expression that evaluates to the SGArray object.

Remarks

Arguments
Row | A Long expression that represents the DataIndex of the row.
Col | A Long expression that represents the DBIndex of the column.

The Value property returns or sets the variant value of an individual SGArray element. In sgUnbound data mode you can set value for any element. In other data modes you can only change current row's data, and changes are transmitted to the data source after the Update method is called.

Use the ColCount and RowCount properties to determine the size of an array.

Show Example
Copy Code [image] Show Me

The following example calculates the estimated time required for loading grid array with data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray
   Dim t As Date
   Dim i As Long, j As Long
   'save start time
   t = Time
   'assign grid array to variable
   Set ar = SGGrid1.Array
   'hide group box
   SGGrid1.GroupByBoxVisible = False
   'create rows and columns
   SGGrid1.DataRowCount = 100
   SGGrid1.DataColCount = 20
   'load test data
   For i = 0 To ar.RowCount - 1
      For j = 0 To ar.ColCount - 1
         ar.Value(i, j) = "Row=" & i & " Col=" & j
      Next
   Next

   Set ar = Nothing
   'show estimate time in the grid's caption
   Me.Caption = "Time: " & DateDiff("s", t, Time)
End Sub

Back to topic


SGArray Methods

Get | Returns array element value.
Set | Sets array element value.


Get Method (SGArray Object)

Get Method (SGArray Object)
Returns array element value.
Syntax

object.Get(Row As Long, Col As Long, Val As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGArray object.
Row | A Long expression that represents the DataIndex of the row.
Col | A Long expression that represents the DBIndex of the column.
Val | A Variant expression that returns the Array value.

Remarks

The Get method retrieves an SGArray element value. You can use it instead of the Value property of the SGArray object.

Show Example
Copy Code [image] Show Me

The following code uses the Get method to retrieve an array element value.

Private Sub Command1_Click()
   Dim varValue As Variant

   Call SGGrid1.Array.Get(0, 0, varValue)

   MsgBox varValue
End Sub

Back to topic


Set Method (SGArray Object)

Set Method (SGArray Object)
Sets array element value.
Syntax

object.Set(Row As Long, Col As Long, Val As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGArray object.
Row | A Long expression that represents the DataIndex of the row.
Col | A Long expression that represents the DBIndex of the column.
Val | A Variant expression that sets the Array value.

Remarks

The Set method assigns an SGArray element value. You can use it instead of the Value property of the SGArray object.

Show Example
Copy Code [image] Show Me

The following code uses the Set method to assign an array element value.

Private Sub Command1_Click()
   Dim varValue As Variant

   varValue = InputBox("Enter cell value", "Cell value")
   Call SGGrid1.Array.Set(0, 0, varValue)

   SGGrid1.RedrawEnabled = True
End sub

Back to topic


SGCalculation Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGCalculation Object

Name: | SGCalculation
Description: | SGCalculation is a definition for group calculations.
GUID: | {5483FE4B-2A22-11D3-B729-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the FetchGroupFooterText and FetchGroupHeaderData events to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).Parent.Row.GroupHeading

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100
   SGGrid1.FitLastColumn = True

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFireFetchText
   grp.FooterTextSource = sgGrpFooterFireFetchText
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic

Referenced By

SGCalculations.Item


SGCalculation Properties

ConditionColKey | Returns or sets the key of the column whose values are used as a left-side value when evaluating condition.
Condition | Returns SGCondition object that filters rows used when calculating.
Grid | Returns parent SGGrid object.
Index | Returns the index of a calculation object in a collection.
ListSeparator | Returns or sets result list separator.
Type | Returns or sets a value indicating type of the calculation.
ValueColKey | Returns or sets the key of the column whose values are used in the calculation.


Condition Property (SGCalculation Object)

Condition Property (SGCalculation Object)
Returns SGCondition object that filters rows used when calculating.

Read-only at run time. Not available at design time.

Syntax

object.Condition As IsgCondition

The object placeholder represents an object expression that evaluates to the SGCalculation object.

Remarks

The Condition property returns an SGCondition object associated with the calculation.

Show Example
Copy Code [image] Show Me

The following example creates five columns: Month, Day , Invoice, Amount and Paid and populates them with random data. It uses Month column to create group object and creates five group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup, curAmount As Currency
   SGGrid1.FitLastColumn = True
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
   End With

   Call SGGrid1.Columns.Add("Invoice")

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With

   With SGGrid1.Columns.Add("Paid")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      curAmount = Round((Rnd * 1000), 2)
      ar.Value(i, 2) = "I" & Trim(i)
      ar.Value(i, 3) = curAmount
      If CLng(Rnd * 100) Mod 3 = 0 Then
         curAmount = 0
      End If
      ar.Value(i, 4) = curAmount
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount", "Paid", sgOpEqual, 0
   With grp.Calculations.Add(sgCalcList, "Invoice", "Paid", sgOpEqual, 0)
      .ListSeparator = ", "
   End With
   grp.Calculations.Add sgCalcMinimum, "Day"
   'use calculations in formulas
   grp.HeaderFormula = "Format(GroupCalc(5),'mmmm') & ' - Invoices: ' " & _
      "& GroupCalc(4) & ' (unpaid ' & Format(GroupCalc(3),'Currency') & ')'"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(1),'Currency') & " & _
      "' Total: ' & Format(GroupCalc(2),'Currency')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


ConditionColKey Property (SGCalculation Object)

ConditionColKey Property (SGCalculation Object)
Returns or sets the key of the column whose values are used as a left-side value when evaluating condition.

Read/Write at run time. Not available at design time.

Syntax

object.ConditionColKey As String

The object placeholder represents an object expression that evaluates to the SGCalculation object.

Remarks

The ConditionColKey property returns or sets the key of the column whose values are used when evaluating condition. This property is case sensitive.

Show Example
Copy Code [image] Show Me

The following example creates five columns: Month, Day , Invoice, Amount and Paid and populates them with random data. It uses Month column to create group object and creates five group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup, curAmount As Currency
   SGGrid1.FitLastColumn = True
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
   End With

   Call SGGrid1.Columns.Add("Invoice")

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With

   With SGGrid1.Columns.Add("Paid")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      curAmount = Round((Rnd * 1000), 2)
      ar.Value(i, 2) = "I" & Trim(i)
      ar.Value(i, 3) = curAmount
      If CLng(Rnd * 100) Mod 3 = 0 Then
         curAmount = 0
      End If
      ar.Value(i, 4) = curAmount
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount", "Paid", sgOpEqual, 0
   With grp.Calculations.Add(sgCalcList, "Invoice", "Paid", sgOpEqual, 0)
      .ListSeparator = ", "
   End With
   grp.Calculations.Add sgCalcMinimum, "Day"
   'use calculations in formulas
   grp.HeaderFormula = "Format(GroupCalc(5),'mmmm') & ' - Invoices: ' " & _
      "& GroupCalc(4) & ' (unpaid ' & Format(GroupCalc(3),'Currency') & ')'"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(1),'Currency') & " & _
      "' Total: ' & Format(GroupCalc(2),'Currency')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


Grid Property (SGCell Object)

Grid Property
Returns parent SGGrid object.

Read-only at run time. Not available at design time.

Syntax

object.Grid As IsgGrid

The object placeholder represents an object expression that evaluates to SGCell, SGCells, SGCondition, SGCalculation, SGCalculations, SGStyle, SGStyles, SGStyleCondition, SGStyleConditions, SGControl, SGColumn, SGColumns, SGRow, SGRows, SGRowCollection, SGGroupHeading, SGGroupHeadings, SGRange, SGRanges, SGGroup, SGGroups, SGSelection, SGFilter and SGFilters objects.

Remarks

Typically, use this property to reference the grid, when you pass reference of a grid's object as an argument.

Show Example
Copy Code [image] Show Me

The following example uses the Grid property to check columns count.

Private Sub PrintRows(rows As SGRows)
   Dim row As SGRow

   If rows.Grid.ColCount = 0 Then Exit Sub

   For Each row In rows
      Debug.Print row.GetData(sgFormatXML) & vbCrLf
   Next
End Sub

Back to topic


Index Property (SGCalculation Object)

Index Property (SGCalculation Object)
Returns the index of a calculation object in a collection.

Read/Write at run time. Not available at design time.

Syntax

object.Index As Integer

The object placeholder represents an object expression that evaluates to the SGCalculation object.

Remarks

This property returns the one-based index that uniquely identifies the SGCalculation object in the SGCalculations collection.

The Index property is set to the order of the creation of objects in a collection. The index for the first object in a collection will always be one (1).

See Also

SGCalculation


ListSeparator Property (SGCalculation Object)

ListSeparator Property (SGCalculation Object)
Returns or sets result list separator.

Read/Write at run time. Not available at design time.

Syntax

object.ListSeparator As String

The object placeholder represents an object expression that evaluates to the SGCalculation object.

Remarks

This property has effect only if Type of the Calculation object is set to sgCalcList

Show Example
Copy Code [image] Show Me

The following example creates five columns: Month, Day , Invoice, Amount and Paid and populates them with random data. It uses Month column to create group object and creates five group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup, curAmount As Currency
   SGGrid1.FitLastColumn = True
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
   End With

   Call SGGrid1.Columns.Add("Invoice")

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With

   With SGGrid1.Columns.Add("Paid")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      curAmount = Round((Rnd * 1000), 2)
      ar.Value(i, 2) = "I" & Trim(i)
      ar.Value(i, 3) = curAmount
      If CLng(Rnd * 100) Mod 3 = 0 Then
         curAmount = 0
      End If
      ar.Value(i, 4) = curAmount
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount", "Paid", sgOpEqual, 0
   With grp.Calculations.Add(sgCalcList, "Invoice", "Paid", sgOpEqual, 0)
      .ListSeparator = ", "
   End With
   grp.Calculations.Add sgCalcMinimum, "Day"
   'use calculations in formulas
   grp.HeaderFormula = "Format(GroupCalc(5),'mmmm') & ' - Invoices: ' " & _
      "& GroupCalc(4) & ' (unpaid ' & Format(GroupCalc(3),'Currency') & ')'"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(1),'Currency') & " & _
      "' Total: ' & Format(GroupCalc(2),'Currency')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


Type Property (SGCalculation Object)

Type Property (SGCalculation Object)
Returns or sets a value indicating type of the calculation.

Read/Write at run time. Not available at design time.

Syntax

object.Type As sgCalculationType

The object placeholder represents an object expression that evaluates to the SGCalculation object.

Settings

The Type settings are:

Name | Value | Description
sgCalcNone | 0 | No calculation.
sgCalcCount | 1 | Row count.
sgCalcMaximum | 2 | Maximum.
sgCalcMinimum | 3 | Minimum.
sgCalcSum | 4 | Sum.
sgCalcAverage | 5 | Average.
sgCalcList | 6 | Creates list.

Remarks

This property determines the type of the calculation.

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the FetchGroupFooterText and FetchGroupHeaderData events to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).Parent.Row.GroupHeading

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100
   SGGrid1.FitLastColumn = True

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFireFetchText
   grp.FooterTextSource = sgGrpFooterFireFetchText
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


ValueColKey Property (SGCalculation Object)

ValueColKey Property (SGCalculation Object)
Returns or sets the key of the column whose values are used in the calculation.

Read/Write at run time. Not available at design time.

Syntax

object.ValueColKey As String

The object placeholder represents an object expression that evaluates to the SGCalculation object.

Remarks

The ValueColKey property returns or sets the key of the column whose values are used in calculation. The column key is case sensitive.

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the FetchGroupFooterText and FetchGroupHeaderData events to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).Parent.Row.GroupHeading

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100
   SGGrid1.FitLastColumn = True

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFireFetchText
   grp.FooterTextSource = sgGrpFooterFireFetchText
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


SGCalculations Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGCalculations Object

Name: | SGCalculations
Description: | Collection of SGCalculation objects
GUID: | {5483FE49-2A22-11D3-B729-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   'use calculations in formulas
   grp.HeaderFormula = "GroupingValue & ' from ' " & _
      "& GroupCalc(1) & ' to ' & GroupCalc(2)"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(3),'#.00') & " & _
      "' Total: ' & Format(GroupCalc(4),'#.00')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic

Referenced By

SGGroup.Calculations


SGCalculations Properties

Count | Returns the number of SGCalculation objects in the collection
Grid | Returns parent SGGrid object.
Item | Returns specified calculation object


Count Property (SGCells Collection)

Count Property
Returns the number of objects in the collection

Read-only at run time. Not available at design time.

Syntax

object.Count As Long

The object placeholder represents an object expression that evaluates to SGCells, SGCalculations, SGValueItems, SGStyles, SGStyleConditions, SGColumns, SGRows, SGRowCollection, SGGroupHeadings, SGRanges, SGGroups and SGFilters objects.

Remarks

Returns a Long containing the number of objects in a collection.

Show Example
Copy Code [image] Show Me

The following example shows how to use the Count property.

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.DataColCount = 5
   For i = 1 To SGGrid1.Columns.Count - 1
      SGGrid1.Columns(i).Caption = "Col " & Trim(i)
   Next
End Sub

Back to topic

See Also

Item


Item Property (SGCells Collection)

Item Property
Returns an item from the specified collection.

Read-only at run time. Not available at design time.

Syntax

object.Item As Object

The object placeholder represents an object expression that evaluates to SGCells, SGCalculations, SGValueItems, SGStyles, SGStyleConditions, SGColumns, SGRows, SGRowCollection, SGGroupHeadings, SGRanges, SGGroups and SGFilters objects.

Remarks

If the value provided as index doesn’t match any existing member of the collection, an error occurs.

Item is the default property for a collection. Therefore, the following lines of code are equivalent:

    Set item = Collection(1)
    Set item = Collection.Item(1)
Show Example
Copy Code [image] Show Me

The following example shows how to use the Item property.

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 1
   SGGrid1.Columns.Item(1).Caption = "xxx"
End Sub

Back to topic

See Also

Count


SGCalculations Methods

Add | Adds new calculation object to the collection and returns a reference to the newly created object.
Remove | Removes specified calculation object from the collection.
RemoveAll | Removes all calculation objects from the collection.


Add Method (SGCalculations Collection)

Add Method (SGCalculations Collection)
Adds new calculation object to the collection and returns a reference to the newly created object.
Syntax

object.Add(Type As sgCalculationType, CalcColumnKey As String, [CondColumnKey] As Variant, [Op] As Variant, [Val1] As Variant, [Val2] As Variant)

Return Value A SGCalculation object.
Arguments
object | An object expression that evaluates to the SGCalculations object.
Type | An sgCalculationType expression that determines the type of the calculation. The possible values are listed in Settings.
CalcColumnKey | A String expression that represents the key of the column whose values are used in calculation.
CondColumnKey | Optional. A String expression that represents the key of the column whose values are used when evaluating condition.
Op | An sgOperator expression that sets the operator to be used when evaluating condition. Check out pattern syntax if you use regular expresion (sgOpRegEx). The possible values are listed in Settings.
Val1 | A Variant expression that contains the first right-side value to be used when evaluating condition criteria.
Val2 | A Variant expression that contains the second right-side value to be used when evaluating condition criteria. This argument is used only if the operator is set to sgOpBetween.

Settings

The settings for Type are:

Name | Value | Description
sgCalcNone | 0 | No calculation.
sgCalcCount | 1 | Row count.
sgCalcMaximum | 2 | Maximum.
sgCalcMinimum | 3 | Minimum.
sgCalcSum | 4 | Sum.
sgCalcAverage | 5 | Average.
sgCalcList | 6 | Creates list.

Remarks

When an SGCalculation object is added to the collection, a reference to the newly created object is returned.

Show Example
Copy Code [image] Show Me

The following example creates Calculation object for all currency columns.

Private Sub SetCalculation()
   Dim SGCol As SGColumn

   For Each SGCol In SGGrid1.Columns
      If SGCol.DataType = sgtCurrency Then
         SGGrid1.Groups(1).Calculations.Add sgCalcSum, SGCol.Key
      End If
   Next

End Sub

Back to topic


Remove Method (SGCalculations Collection)

Remove Method (SGCalculations Collection)
Removes specified calculation object from the collection.
Syntax

object.Remove(Index As Integer)

Return Value None
Arguments
object | An object expression that evaluates to the SGCalculations object.
Index | An integer that uniquely identifies the object within the collection.

Remarks

To remove all SGCalculation objects from the SGCalculations collection use the RemoveAll method.

Show Example
Copy Code [image] Show Me

The following example removes calculation by given column key.

Private Function RemoveCalculationByKey(sColKey As String) As Boolean
   Dim calc As SGCalculation

   For Each calc In SGGrid1.Groups(1).Calculations
      If StrComp(calc.ConditionColKey, sColKey) = 0 Then
         SGGrid1.Groups(1).Calculations.Remove calc.index
         RemoveCalculationByKey = True
         Exit Function
      End If
   Next

End Function

Back to topic


RemoveAll Method (SGCalculations Collection)

RemoveAll Method (SGCalculations Collection)
Removes all calculation objects from the collection.
Syntax | object.RemoveAll
Return Value | None
Arguments | None

Remarks

To remove a particular SGCalculation object from the SGCalculations collection use the Remove method.

Show Example
Copy Code [image] Show Me

The following example removes all Calculations from all groups.

Private Sub ClearAllCalculations()
   Dim grp As SGGroup

   For Each grp In SGGrid1.Groups
      grp.Calculations.RemoveAll
   Next

End Sub

Back to topic


SGCell Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGCell Object

Name: | SGCell
Description: | SGCell object represents single grid cell.
GUID: | {28D20E76-4F3A-11D3-B75C-008048E27A77}

Show Example
Copy Code [image] Show Me

The folloving example cahanges cells back and fore color. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As Variant
   Dim i%, j%, k%
   Dim lRow As Long
   Dim oCell As SGCell

   With SGGrid1
      'disable grid redrawing
      .RedrawEnabled = False
      'hide GroupByBox
      .GroupByBoxVisible = False
      'set grid's appearance
      .Font.Name = "Symbol"
      .TextAlignment = sgAlignCenterCenter
      .Styles("CurrentRow").Font.Name = "Symbol"
      'create and customize rows
      'and columns
      .Columns.RemoveAll True

      .DefaultColWidth = 300
      .DefaultRowHeight = 300

      .HeadingColCount = 0
      .HeadingRowCount = 0

      .DataRowCount = 49
      .DataColCount = 7
   End With

   'use SGCell object to load data and
   'custimize cells styles
   ar = Array(0, 64, 96, 128, 192, 224, 255)

   For i = 0 To 6
      For j = 0 To 6
         For k = 0 To 6
            Set oCell = SGGrid1.Rows.At(lRow).Cells(k)
            oCell.Style.BackColor = RGB(ar(k), ar(j), ar(i))
            oCell.Style.ForeColor = RGB(ar(i), ar(k), ar(j))
            oCell.Value = Chr(&HAA)
         Next
         lRow = lRow + 1
      Next
   Next
   'enable grid repainting
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

Referenced By


SGCell Properties

ColKey | Returns key of the column that contains this cell.
Column | Returns a column that contains this cell as an SGColumn object.
Grid | Returns parent SGGrid object.
Height | Returns cell's height.
Kind | Returns a value indicating kind of the cell.
Left | Returns the position of the cell's left edge.
ReadOnly | Returns or sets a value indicating whether a cell can be changed.
RowKey | Returns key of the row that contains this cell
Row | Returns a row that contains this cell as an SGRow object
Status | Returns cell's status value.
Style | Returns cell's style object.
Tag | Returns or sets the user defined data attached to the cell
Text | Returns cell's content as formatted text
Top | Returns the position of the cell's top edge.
Value | Returns or sets cell's data value
Visible | Returns true if a cell is visible
Width | Returns cell's width.


ColKey Property (SGCell Object)

ColKey Property (SGCell Object)
Returns key of the column that contains this cell.

Read-only at run time. Not available at design time.

Syntax

object.ColKey As String

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The ColKey property returns key of the column that contains this cell.

Show Example
Copy Code [image] Show Me

The following example uses the MouseMove event and the HitTestObject method to reference the cell under the mouse pointer. It paints column and row of the referenced cell to green. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(Button As Integer, _
   Shift As Integer, x As Single, y As Single)
   Dim oCell As Variant       'current cell
   Static oExCell As SGCell   'last visited cell
   'check out if the mouse pointer is over a cell
   If SGGrid1.HitTestObject(x, y, oCell) = sgHitCell Then
      If Not oExCell Is Nothing Then
         'exit if you move over the same cell
         If oExCell.ColKey = oCell.ColKey And _
            oExCell.RowKey = oCell.RowKey Then Exit Sub

      End If
      SGGrid1.Styles.RemoveCustom
      SGGrid1.Redraw
      'paint column and row of the current cell
      oCell.row.Style.BackColor = vbGreen
      oCell.Column.Style.BackColor = vbGreen
      oCell.row.Redraw
      oCell.Column.Redraw
      'save reference of the current cell
      Set oExCell = oCell
   End If
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      'create rows and columns
      .DataColCount = 12
      .DataRowCount = 100
      'hide GroupByBox
      .GroupByBoxVisible = False
   End With
End Sub

Back to topic


Column Property (SGCell Object)

Column Property (SGCell Object)
Returns a column that contains this cell as an SGColumn object.

Read-only at run time. Not available at design time.

Syntax

object.Column As IsgColumn

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The Column property returns reference to SGColumn object that contains this cell.

Show Example
Copy Code [image] Show Me

The following example uses the MouseMove event and the HitTestObject method to reference the cell under the mouse pointer. It paints column and row of the referenced cell to green. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(Button As Integer, _
   Shift As Integer, x As Single, y As Single)
   Dim oCell As Variant       'current cell
   Static oExCell As SGCell   'last visited cell
   'check out if the mouse pointer is over a cell
   If SGGrid1.HitTestObject(x, y, oCell) = sgHitCell Then
      If Not oExCell Is Nothing Then
         'exit if you move over the same cell
         If oExCell.ColKey = oCell.ColKey And _
            oExCell.RowKey = oCell.RowKey Then Exit Sub

      End If
      SGGrid1.Styles.RemoveCustom
      SGGrid1.Redraw
      'paint column and row of the current cell
      oCell.row.Style.BackColor = vbGreen
      oCell.Column.Style.BackColor = vbGreen
      oCell.row.Redraw
      oCell.Column.Redraw
      'save reference of the current cell
      Set oExCell = oCell
   End If
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      'create rows and columns
      .DataColCount = 12
      .DataRowCount = 100
      'hide GroupByBox
      .GroupByBoxVisible = False
   End With
End Sub

Back to topic


Height Property (SGCell Object)

Height Property (SGCell Object)
Returns cell's height.

Read-only at run time. Not available at design time.

Syntax

object.Height As OLE_YSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The Height property is specified in terms of the container's coordinate system.

The cell's Left, Top, Width and Height properties are valid only for completely visible cells. This property returns -1, if a cell is not visible.

Show Example
Copy Code [image] Show Me

The following example opens the MonthView control when the user clicks on a cell's button. To try the example, place BeeGrid and MonthView (MS Windows common controls 2) control on a form. Paste the code into the Declarations section, press F5 and click a cell's button.

Private Sub SGGrid1_ButtonClick _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   Cancel As Boolean)
   Dim oCell As SGCell
   Dim sColKey As String

   sColKey = SGGrid1.Columns(ColIndex).Key

   Set oCell = SGGrid1.Cell(RowKey, sColKey)

   If MonthView1.Height + oCell.Top + oCell.Height > _
      SGGrid1.Top + SGGrid1.Height Then
      MonthView1.Move SGGrid1.Left + oCell.Left, _
         oCell.Top + SGGrid1.Top - MonthView1.Height
   Else
      MonthView1.Move SGGrid1.Left + oCell.Left, _
         SGGrid1.Top + oCell.Top + oCell.Height
   End If

   If oCell.Width > MonthView1.Width Then
      MonthView1.Left = MonthView1.Left + (oCell.Width - MonthView1.Width)
   End If

   MonthView1.Visible = True
End Sub

Private Sub SGGrid1_OnInit()
   MonthView1.Visible = False
   SGGrid1.DataRowCount = 30

   With SGGrid1.Columns(1)
      .DataType = sgtDateTime
      .Control.ShowButton = sgShowButtonFocused
   End With
End Sub

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
   SGGrid1.CurrentCell.Value = DateClicked
   MonthView1.Visible = False
End Sub

Private Sub MonthView1_LostFocus()
   MonthView1.Visible = False
End Sub

Private Sub SGGrid1_Click()
   MonthView1.Visible = False
End Sub

Back to topic


Kind Property (SGCell Object)

Kind Property (SGCell Object)
Returns a value indicating kind of the cell.

Read-only at run time. Not available at design time.

Syntax

object.Kind As sgCellKind

The object placeholder represents an object expression that evaluates to the SGCell object.

Settings

The Kind settings are:

Name | Value | Description
sgCellStandard | 0 | Standard cell.
sgCellGroupHeader | 2 | Cell is a group header cell.
sgCellGroupFooter | 3 | Cell is a group footer cell.
sgCellPreviewPane | 4 | Cell is a preview pane.
sgCellGroupByBox | 5 | Cell is a group-by box.
sgCellGroupByHeadingCell | 6 | Cell is a column heading inside the group-by box.

Remarks

Cells in the heading row or the heading column are also standard cells (sgCellStandard). You can use the Heading property of the SGRow/SGColumn object to check out if cell part of the heading row/column.


Left Property (SGCell Object)

Left Property (SGCell Object)
Returns the position of the cell's left edge.

Read-only at run time. Not available at design time.

Syntax

object.Left As OLE_XPOS_CONTAINER

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The Left property is specified in terms of the container's coordinate system.

The cell's Left, Top, Width and Height properties are valid only for completely visible cells. This property returns -1, if a cell is not visible.

Show Example
Copy Code [image] Show Me

The following example opens the MonthView control when the user clicks on a cell's button. To try the example, place BeeGrid and MonthView (MS Windows common controls 2) control on a form. Paste the code into the Declarations section, press F5 and click a cell's button.

Private Sub SGGrid1_ButtonClick _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   Cancel As Boolean)
   Dim oCell As SGCell
   Dim sColKey As String

   sColKey = SGGrid1.Columns(ColIndex).Key

   Set oCell = SGGrid1.Cell(RowKey, sColKey)

   If MonthView1.Height + oCell.Top + oCell.Height > _
      SGGrid1.Top + SGGrid1.Height Then
      MonthView1.Move SGGrid1.Left + oCell.Left, _
         oCell.Top + SGGrid1.Top - MonthView1.Height
   Else
      MonthView1.Move SGGrid1.Left + oCell.Left, _
         SGGrid1.Top + oCell.Top + oCell.Height
   End If

   If oCell.Width > MonthView1.Width Then
      MonthView1.Left = MonthView1.Left + (oCell.Width - MonthView1.Width)
   End If

   MonthView1.Visible = True
End Sub

Private Sub SGGrid1_OnInit()
   MonthView1.Visible = False
   SGGrid1.DataRowCount = 30

   With SGGrid1.Columns(1)
      .DataType = sgtDateTime
      .Control.ShowButton = sgShowButtonFocused
   End With
End Sub

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
   SGGrid1.CurrentCell.Value = DateClicked
   MonthView1.Visible = False
End Sub

Private Sub MonthView1_LostFocus()
   MonthView1.Visible = False
End Sub

Private Sub SGGrid1_Click()
   MonthView1.Visible = False
End Sub

Back to topic


ReadOnly Property (SGCell Object)

ReadOnly Property (SGCell Object)
Returns or sets a value indicating whether a cell can be changed.

Read/Write at run time. Not available at design time.

Syntax

object.ReadOnly As Boolean

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The ReadOnly property prevents the user from changing the data in the specified cell. You can change data from your code even if ReadOnly property is set to True.

Show Example
Copy Code [image] Show Me

The following example allows a user to enter value into a cell only once.

Private Sub SGGrid1_AfterUpdate()
   SGGrid1.CurrentCell.ReadOnly = True
End Sub

Back to topic

See Also

SGCell


Row Property (SGCell Object)

Row Property (SGCell Object)
Returns a row that contains this cell as an SGRow object

Read-only at run time. Not available at design time.

Syntax

object.Row As IsgRow

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The Row property returns reference to SGRow object that contains this cell.

Show Example
Copy Code [image] Show Me

The following example uses the MouseMove event and the HitTestObject method to reference the cell under the mouse pointer. It paints column and row of the referenced cell to green. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(Button As Integer, _
   Shift As Integer, x As Single, y As Single)
   Dim oCell As Variant       'current cell
   Static oExCell As SGCell   'last visited cell
   'check out if the mouse pointer is over a cell
   If SGGrid1.HitTestObject(x, y, oCell) = sgHitCell Then
      If Not oExCell Is Nothing Then
         'exit if you move over the same cell
         If oExCell.ColKey = oCell.ColKey And _
            oExCell.RowKey = oCell.RowKey Then Exit Sub

      End If
      SGGrid1.Styles.RemoveCustom
      SGGrid1.Redraw
      'paint column and row of the current cell
      oCell.row.Style.BackColor = vbGreen
      oCell.Column.Style.BackColor = vbGreen
      oCell.row.Redraw
      oCell.Column.Redraw
      'save reference of the current cell
      Set oExCell = oCell
   End If
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      'create rows and columns
      .DataColCount = 12
      .DataRowCount = 100
      'hide GroupByBox
      .GroupByBoxVisible = False
   End With
End Sub

Back to topic


RowKey Property (SGCell Object)

RowKey Property (SGCell Object)
Returns key of the row that contains this cell

Read-only at run time. Not available at design time.

Syntax

object.RowKey As Long

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

You can use the cell's Row property to reference a row that contains a cell.

Show Example
Copy Code [image] Show Me

The following example uses the MouseMove event and the HitTestObject method to reference the cell under the mouse pointer. It paints column and row of the referenced cell to green. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(Button As Integer, _
   Shift As Integer, x As Single, y As Single)
   Dim oCell As Variant       'current cell
   Static oExCell As SGCell   'last visited cell
   'check out if the mouse pointer is over a cell
   If SGGrid1.HitTestObject(x, y, oCell) = sgHitCell Then
      If Not oExCell Is Nothing Then
         'exit if you move over the same cell
         If oExCell.ColKey = oCell.ColKey And _
            oExCell.RowKey = oCell.RowKey Then Exit Sub

      End If
      SGGrid1.Styles.RemoveCustom
      SGGrid1.Redraw
      'paint column and row of the current cell
      oCell.row.Style.BackColor = vbGreen
      oCell.Column.Style.BackColor = vbGreen
      oCell.row.Redraw
      oCell.Column.Redraw
      'save reference of the current cell
      Set oExCell = oCell
   End If
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      'create rows and columns
      .DataColCount = 12
      .DataRowCount = 100
      'hide GroupByBox
      .GroupByBoxVisible = False
   End With
End Sub

Back to topic


Status Property (SGCell Object)

Status Property (SGCell Object)
Returns cell's status value.

Read-only at run time. Not available at design time.

Syntax

object.Status As sgCellStatus

The object placeholder represents an object expression that evaluates to the SGCell object.

Settings

The Status settings are:

Name | Value | Description
sgCellStatusNormal | 0 | No special status.
sgCellStatusCurrent | 1 | Cell is focused.
sgCellStatusCurrentRow | 2 | Cell is a member of the current row.
sgCellStatusDataChanged | 4 | Cell content has changed but has not yet been written to the database.

Remarks

Always mask value from the Status property. For example, a cell can be member of the current row and can be changed. In that case its status is 6 (sgCellStatusCurrentRow + sgCellStatusDataChanged).
The code below demonstrates how to check if the cell is current:

   If SGGrid1.CellAt(0, 0).Status And sgCellStatusCurrent Then
      ....
   End If
Show Example
Copy Code [image] Show Me

The following example uses a cell tool tip to display the current cell status. In addition, it uses the RowColChange event to paint cell depending of its status. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      .DataColCount = 5
      .DataRowCount = 5
      .CellTips = sgCellTipsFloat
   End With
End Sub

Private Sub SGGrid1_FetchCellTip _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal CellKind As sgCellKind, _
   Width As stdole.OLE_XSIZE_CONTAINER, _
   Height As stdole.OLE_YSIZE_CONTAINER, CellTipText As String, _
   Picture As Variant, ByVal TipStyle As IsgStyle)

   CellTipText = "Cell status: " & _
      SGGrid1.cell(RowKey, SGGrid1.Columns(ColIndex).Key).Status
End Sub

Private Sub SGGrid1_RowColChange _
   (ByVal LastRowKey As Long, ByVal LastColIndex As Long)
   Dim row As SGRow
   Dim cell As SGCell

   For Each row In SGGrid1.Rows
      If Not row.Heading Then
         For Each cell In row.Cells
            cell.Style.BackColor2 = QBColor(cell.Status + 1)
            cell.Style.BkgStyle = sgCellBkgGradientHorizontal
         Next
      End If
   Next
End Sub

Back to topic


Style Property (SGCell Object)

Style Property (SGCell Object)
Returns cell's style object.

Read-only at run time. Not available at design time.

Syntax

object.Style As IsgStyle

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

For more information, see the SGStyle topic.

Show Example
Copy Code [image] Show Me

The following example enumerates all grid's styles and copies a each style to a cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sty As SGStyle, cell As SGCell
   Dim iCol As Integer, lRow As Long

   With SGGrid1
      'create cols and rows
      .DataColCount = 3
      .DataRowCount = 6
      .HeadingColCount = 0
      'hide GroupByBox
      .GroupByBoxVisible = False
   End With

   lRow = 1
   'enumerate all elements of the
   'Styles collection
   For Each sty In SGGrid1.Styles
      'reference next cell
      Set cell = SGGrid1.Rows.At(lRow). _
         Cells(iCol Mod SGGrid1.DataColCount)
      'display the name of the referenced style
      cell.Value = iCol & " " & sty.Name
      'copy the referenced style to cell's style
      cell.Style.CopyFrom sty
      'increment column index
      iCol = iCol + 1
      If iCol Mod SGGrid1.DataColCount = 0 Then
         'move to the next row
         lRow = lRow + 1
      End If
   Next
End Sub

Private Sub Command1_Click()
   SGGrid1.Styles.RemoveAll
   SGGrid1.Redraw
End Sub

Back to topic


Tag Property (SGCell Object)

Tag Property (SGCell Object)
Returns or sets the user defined data attached to the cell

Read/Write at run time. Not available at design time.

Syntax

object.Tag As Variant

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

Returns or sets an expression that stores any extra data needed for a cell.

Show Example
Copy Code [image] Show Me

The following example simulates undo operations by saving old cell value in a cell's tag. When you click a button, content of edited cells will be replaced with old values. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button. Edit some cells and press a button.

Private Sub Command1_Click()
   Dim cell As SGCell
   Dim row As SGRow
   'replace cells value with value saved
   'in the cell's tag
   For Each row In SGGrid1.Rows
      For Each cell In row.Cells
         If Len(cell.Tag) > 0 Then
            cell.Value = cell.Tag
         End If
      Next cell, row

   SGGrid1.Redraw
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Long, j As Integer

   With SGGrid1
      'create cols and rows
      .DataColCount = 3
      .DataRowCount = 5
      'add test data
      For i = 0 To .DataRowCount - 1
         For j = 0 To .DataColCount - 1
            .Array.Value(i, j) = i & "-" & j
         Next j, i
   End With
End Sub

Private Sub SGGrid1_ValidateEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal OldValue As Variant, Cancel As Boolean)
   Dim sCol As String

   sCol = SGGrid1.Columns(ColIndex).Key
   'save the old cell value to the cell's tag
   SGGrid1.cell(RowKey, sCol).Tag = OldValue
End Sub

Back to topic

See Also

SGCell


Text Property (SGCell Object)

Text Property (SGCell Object)
Returns cell's content as formatted text

Read-only at run time. Not available at design time.

Syntax

object.Text As String

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The Text property returns the formatted presentation of the underlying cell value.

Show Example
Copy Code [image] Show Me

The following example shows difference between the Text and Value property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   SGGrid1.CurrentCell.Value = 3123
   SGGrid1.CurrentCell.Style.Format = "Currency"
   SGGrid1.Redraw

   MsgBox "This is the Text property: " _
      & SGGrid1.Text & vbCrLf _
      & "This is the Value property: " _
      & SGGrid1.Value
End Sub

Back to topic


Top Property (SGCell Object)

Top Property (SGCell Object)
Returns the position of the cell's top edge.

Read-only at run time. Not available at design time.

Syntax

object.Top As OLE_YPOS_CONTAINER

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The Top property is specified in terms of the container's coordinate system.

The cell's Left, Top, Width and Height properties are valid only for completely visible cells. This property returns -1, if a cell is not visible.

Show Example
Copy Code [image] Show Me

The following example opens the MonthView control when the user clicks on a cell's button. To try the example, place BeeGrid and MonthView (MS Windows common controls 2) control on a form. Paste the code into the Declarations section, press F5 and click a cell's button.

Private Sub SGGrid1_ButtonClick _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   Cancel As Boolean)
   Dim oCell As SGCell
   Dim sColKey As String

   sColKey = SGGrid1.Columns(ColIndex).Key

   Set oCell = SGGrid1.Cell(RowKey, sColKey)

   If MonthView1.Height + oCell.Top + oCell.Height > _
      SGGrid1.Top + SGGrid1.Height Then
      MonthView1.Move SGGrid1.Left + oCell.Left, _
         oCell.Top + SGGrid1.Top - MonthView1.Height
   Else
      MonthView1.Move SGGrid1.Left + oCell.Left, _
         SGGrid1.Top + oCell.Top + oCell.Height
   End If

   If oCell.Width > MonthView1.Width Then
      MonthView1.Left = MonthView1.Left + (oCell.Width - MonthView1.Width)
   End If

   MonthView1.Visible = True
End Sub

Private Sub SGGrid1_OnInit()
   MonthView1.Visible = False
   SGGrid1.DataRowCount = 30

   With SGGrid1.Columns(1)
      .DataType = sgtDateTime
      .Control.ShowButton = sgShowButtonFocused
   End With
End Sub

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
   SGGrid1.CurrentCell.Value = DateClicked
   MonthView1.Visible = False
End Sub

Private Sub MonthView1_LostFocus()
   MonthView1.Visible = False
End Sub

Private Sub SGGrid1_Click()
   MonthView1.Visible = False
End Sub

Back to topic


Value Property (SGCell Object)

Value Property (SGCell Object)
Returns or sets cell's data value

Read/Write at run time. Not available at design time.

Syntax

object.Value As Variant

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The Value property returns or sets underlying data value packed in the variant value.

Use the Text property to get cell's value as formatted text.

Show Example
Copy Code [image] Show Me

The following example shows difference between the Text and Value property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   SGGrid1.CurrentCell.Value = 3123
   SGGrid1.CurrentCell.Style.Format = "Currency"
   SGGrid1.Redraw

   MsgBox "This is the Text property: " _
      & SGGrid1.Text & vbCrLf _
      & "This is the Value property: " _
      & SGGrid1.Value
End Sub

Back to topic


Visible Property (SGCell Object)

Visible Property (SGCell Object)
Returns true if a cell is visible

Read-only at run time. Not available at design time.

Syntax

object.Visible As Boolean

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

This property returns False if a particular cell has been scrolled out of view or if column/row that contains cell is hidden.

Use the EnsureVisible method to ensure a specified Cell object is visible.

Show Example
Copy Code [image] Show Me

The following example displays count of visible cells in the grid's caption. It uses the AfterScroll event to count visible cells. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_AfterScroll _
   (ByVal OldTopRow As Long, ByVal OldLeftCol As Long, _
   ByVal NewTopRow As Long, ByVal NewLeftCol As Long)
   Dim cell As SGCell
   Dim row As SGRow
   Dim lVisibleCells As Long
   'count visible cells
   For Each row In SGGrid1.Rows
      For Each cell In row.Cells
         If cell.Visible Then
            lVisibleCells = lVisibleCells + 1
         End If
      Next
   Next
   'display a count of the visible cells in the
   'grid's caption
   SGGrid1.Caption = "There are " & lVisibleCells & _
      " visible cells"
End Sub

Private Sub SGGrid1_OnInit()
   'create cols and rows
   SGGrid1.DataColCount = 12
   SGGrid1.DataRowCount = 30
   'call the AfterScroll event to
   'get a count of visible cells
   SGGrid1_AfterScroll 0, 0, 0, 0
End Sub

Back to topic


Width Property (SGCell Object)

Width Property (SGCell Object)
Returns cell's width.

Read-only at run time. Not available at design time.

Syntax

object.Width As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGCell object.

Remarks

The Width property is specified in terms of the container's coordinate system.

The cell's Left, Top, Width and Height properties are valid only for completely visible cells. This property returns -1, if a cell is not visible.

Show Example
Copy Code [image] Show Me

The following example opens the MonthView control when the user clicks on a cell's button. To try the example, place BeeGrid and MonthView (MS Windows common controls 2) control on a form. Paste the code into the Declarations section, press F5 and click a cell's button.

Private Sub SGGrid1_ButtonClick _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   Cancel As Boolean)
   Dim oCell As SGCell
   Dim sColKey As String

   sColKey = SGGrid1.Columns(ColIndex).Key

   Set oCell = SGGrid1.Cell(RowKey, sColKey)

   If MonthView1.Height + oCell.Top + oCell.Height > _
      SGGrid1.Top + SGGrid1.Height Then
      MonthView1.Move SGGrid1.Left + oCell.Left, _
         oCell.Top + SGGrid1.Top - MonthView1.Height
   Else
      MonthView1.Move SGGrid1.Left + oCell.Left, _
         SGGrid1.Top + oCell.Top + oCell.Height
   End If

   If oCell.Width > MonthView1.Width Then
      MonthView1.Left = MonthView1.Left + (oCell.Width - MonthView1.Width)
   End If

   MonthView1.Visible = True
End Sub

Private Sub SGGrid1_OnInit()
   MonthView1.Visible = False
   SGGrid1.DataRowCount = 30

   With SGGrid1.Columns(1)
      .DataType = sgtDateTime
      .Control.ShowButton = sgShowButtonFocused
   End With
End Sub

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
   SGGrid1.CurrentCell.Value = DateClicked
   MonthView1.Visible = False
End Sub

Private Sub MonthView1_LostFocus()
   MonthView1.Visible = False
End Sub

Private Sub SGGrid1_Click()
   MonthView1.Visible = False
End Sub

Back to topic


SGCell Methods

EnsureVisible | Ensures that cell is visible.
Redraw | Redraws cell.


EnsureVisible Method (SGCell Object)

EnsureVisible Method (SGCell Object)
Ensures that cell is visible.
Syntax | object.EnsureVisible
Return Value | None
Arguments | None

Remarks

This method ensures a specified Cell object is visible. It applies for both hidden and invisible cells. If necessary, this method expands SGGroupHeadings objects and/or scrolls the grid control.

Show Example
Copy Code [image] Show Me

The following example uses the EnsureVisible method to display a random cell. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim iColPos As Integer
   Dim lRndCell As Long
   Dim lCellsCount As Long
   Dim lRowPos As Long
   Static cell As SGCell

   If Not cell Is Nothing Then
      cell.Style.Reset
   End If
   'get random value and display it
   lCellsCount = SGGrid1.DataColCount * SGGrid1.DataRowCount
   lRndCell = Rnd * lCellsCount + 1
   SGGrid1.Caption = "Cell Nr. " & lRndCell
   'get col position from the random value
   iColPos = lRndCell Mod SGGrid1.DataColCount
   If iColPos = 0 Then iColPos = SGGrid1.DataColCount
   'get row position from the random value
   lRowPos = Fix((lRndCell - 1) / SGGrid1.DataColCount) + 1
   'assign cell object
   Set cell = SGGrid1.Rows.At(lRowPos).Cells(iColPos)
   'change cell's style
   cell.Style.BackColor = vbRed
   'show it
   cell.EnsureVisible
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, iCell As Integer
   Dim i As Integer, j As Integer

   With SGGrid1
      'create cols and rows
      .DataColCount = 12
      .DataRowCount = 100
      'assign array object to variable
      Set ar = .Array
      'add test data
      For i = 0 To .DataRowCount - 1
         For j = 0 To .DataColCount - 1
            iCell = iCell + 1
            ar.Value(i, j) = iCell
         Next j, i
   End With

   Set ar = Nothing

   Command1_Click
End Sub

Back to topic


Redraw Method (SGCell Object)

Redraw Method (SGCell Object)
Redraws cell.
Syntax | object.Redraw
Return Value | None
Arguments | None

Remarks

The Redraw method has no effect if the control's RedrawEnabled property is set to False.

Show Example
Copy Code [image] Show Me

The following example paints a cell bellow the mouse pointer. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(button As Integer, _
   shift As Integer, x As Single, y As Single)
   Dim lRowKey As Long, sColKey As String
   Dim oCell As SGCell
   Static lOldRowKey As Long
   Static sOldColKey As String

   'check out if mouse pointer is over cells
   If SGGrid1.HitTest(x, y) <> sgHitCell Then Exit Sub
   'get row and col keys
   lRowKey = SGGrid1.Rows.At(SGGrid1.MouseRow).Key
   sColKey = SGGrid1.Columns.At(SGGrid1.MouseCol).Key

   If lOldRowKey = lRowKey And _
      sColKey = sOldColKey Then Exit Sub

   'paint old cell to white
   If Len(sOldColKey) > 0 Then
      Set oCell = SGGrid1.cell(lOldRowKey, sOldColKey)
      oCell.Style.BackColor = vbWhite
      oCell.Redraw
   End If

   Set oCell = SGGrid1.cell(lRowKey, sColKey)
   'paint it red
   oCell.Style.BackColor = vbRed
   Set oCell = Nothing
   'save current keys to static variables
   lOldRowKey = lRowKey
   sOldColKey = sColKey

   SGGrid1.RedrawCell SGGrid1.MouseRow, SGGrid1.MouseCol
End Sub

Back to topic


SGCells Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGCells Object

Name: | SGCells
Description: | Collection of SGCell objects
GUID: | {28D20E77-4F3A-11D3-B75C-008048E27A77}

Remarks

This object contains the collection of a row's SGCell objects. The code below demonstrates how to enumerate all cells:

Private Sub SGGrid1_OnInit()
   Dim row As SGRow
   Dim cell As SGCell

   For Each row In SGGrid1.Rows
      For Each cell In row.Cells
         Debug.Print cell.Value
      Next
   Next
End Sub

The SGCells collection hasn't properties and methods.

Show Example
Copy Code [image] Show Me

The following example print position and size of each cell in the Immediate window. To try the example, place a SGGrid and CommandButton on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim SGCell As SGCell
   Dim SGRow As SGRow

   For Each SGRow In SGGrid1.Rows
      For Each SGCell In SGRow.Cells
         Debug.Print "Cell rect: " & SGCell.Left & "-" & _
            SGCell.Top & "-" & SGCell.Width & "-" & SGCell.Height
      Next
   Next

End Sub

Back to topic

Referenced By

SGRow.Cells


SGCells Properties

Count | Returns the number of cells in the collection
Grid | Returns parent SGGrid object.
Item | Returns specified cell object (position is zero based).


SGColumn Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGColumn Object

Name: | SGColumn
Description: | SGColumn is object that represents one grid column.
GUID: | {F0A68CB2-9109-11D2-8EBB-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example change columns background color. To try the example, place SGGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim sgCol As SGColumn

   For Each sgCol In SGGrid1.Columns
      sgCol.Style.BackColor = QBColor(sgCol.ColIndex Mod 16)
   Next
   'redraw grid after changing columns
   'background color
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

Referenced By


SGColumn Properties

AllowFocus | Returns or sets a value indicating whether a column can receive focus.
AllowSizing | Returns or sets a value indicating whether a user can resize a column.
BaseColumnName | Returns a string that identifies the name of the associated database field.
BaseTableName | Returns a string that identifies the name of the associated database table.
Caption | Returns or sets column's heading text.
ColIndex | Returns the one-based index of a column within the Columns collection.
Control | Returns an SGControl object associated with the column.
DBField | Returns or sets the name of the bound database filed.
DBIndex | Returns zero-based index of the bound database filed.
DataChanged | Returns true if column's data has been changed.
DataType | Returns or sets column's data type.
DataWidth | Returns or sets the number of characters that can be entered when editing a cell.
DefaultValue | Returns or sets a default value for a column.
EditMaskDataMode | Returns or sets a value that determines how masked cells will be stored by the underlaying data source.
EditMask | Returns or sets the input mask used to edit cells.
FetchCellStyle | Returns or sets a value indicating whether FetchCellStyle event is fired.
Frozen | Returns or sets a value indicating whether the column is frozen.
Grid | Returns parent SGGrid object.
HeadingPicture | Returns or sets picture displayed in the column heading.
HeadingStyle | Returns the SGStyle object associated with the column heading.
Heading | Returns True if column is heading column.
Hidden | Determines whether the column is hidden or not.
Key | Returns or sets column's unique identifier.
Left | Returns the position of the column's left edge.
MergeCells | Returns or sets a value indicating cell merging rules.
Position | Returns or sets column's position. Zero-based.
ReadOnly | Returns or sets a value indicating whether an object can be edited.
Right | Returns the position of the column's right edge.
SortOrder | Returns or sets column's sort order.
SortType | Returns or sets data type used when sorting.
StyleConditions | Returns the collection of a conditional style rules.
Style | Returns the SGStyle object associated with the column.
Tag | Returns or sets user defined value associated with the grid column.
ValueItems | Collection of column's value items.
Visible | Returns whether a column is currently within view.
Width | Returns or sets column's width.


AllowFocus Property (SGColumn Object)

AllowFocus Property (SGColumn Object)
Returns or sets a value indicating whether a column can receive focus.

Read/Write at run time and design time.

Syntax

object.AllowFocus As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

If this property is False, the user will not be able to set the focus to this column, either with mouse or with keyboard.

Show Example
Copy Code [image] Show Me

The following example uses the first data column as heading column. The first column displays letter to mark row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, rng As SGRange
   SGGrid1.DataColCount = 5
   SGGrid1.DataRowCount = 26

   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.At(1)
      .AllowFocus = False
      .ReadOnly = True
      .Frozen = True
      .Caption = ""
      .AllowSizing = False
      .Width = SGGrid1.Columns.At(0).Width
      .Style.Font.Bold = True
   End With

   SGGrid1.HeadingColCount = 0

   SGGrid1.Styles("Frozen").BackColor = SGGrid1.Styles("Heading").BackColor
   SGGrid1.Styles("Heading").TextAlignment = sgAlignCenterCenter

   Set rng = SGGrid1.CreateRange(sgRangeFree, 0, 0, 0, SGGrid1.DataRowCount)
   rng.ApplyStyle SGGrid1.Styles("Heading")

   Set rng = Nothing

   For i = 65 To 90
      SGGrid1.Array.Value(i - 65, 0) = Chr(i)
   Next
End Sub

Private Sub SGGrid1_ColMove( _
   ByVal ColIndex As Long, _
   ByVal newPosition As Long, _
   cancelMove As Boolean)

   If newPosition = 1 Or ColIndex = 1 Then
      cancelMove = True
   End If

End Sub

Private Sub SGGrid1_ColHide(ByVal ColIndex As Long, cancelHide As Boolean)

   cancelHide = (SGGrid1.Columns.At(0).ColIndex = ColIndex)

End Sub

Private Sub SGGrid1_RowColChange _
   (ByVal LastRowKey As Long, ByVal LastColIndex As Long)
   If LastColIndex > -1 Then
      SGGrid1.Rows(LastRowKey).Cells(0).Style.ForeColor = vbBlack
   End If

   SGGrid1.Rows.Current.Cells(0).Style.ForeColor = vbRed
End Sub

Back to topic


AllowSizing Property (SGColumn Object)

AllowSizing Property (SGColumn Object)
Returns or sets a value indicating whether a user can resize a column.

Read/Write at run time and design time.

Syntax

object.AllowSizing As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

If this property is True, the mouse pointer turns into a "Size W-E" arrow when positioned over the divider of the specified column. The user can resize the column by dragging or auto-resize by double-clicking.

Show Example
Copy Code [image] Show Me

The following example uses the first data column as heading column. The first column displays letter to mark row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, rng As SGRange
   SGGrid1.DataColCount = 5
   SGGrid1.DataRowCount = 26

   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.At(1)
      .AllowFocus = False
      .ReadOnly = True
      .Frozen = True
      .Caption = ""
      .AllowSizing = False
      .Width = SGGrid1.Columns.At(0).Width
      .Style.Font.Bold = True
   End With

   SGGrid1.HeadingColCount = 0

   SGGrid1.Styles("Frozen").BackColor = SGGrid1.Styles("Heading").BackColor
   SGGrid1.Styles("Heading").TextAlignment = sgAlignCenterCenter

   Set rng = SGGrid1.CreateRange(sgRangeFree, 0, 0, 0, SGGrid1.DataRowCount)
   rng.ApplyStyle SGGrid1.Styles("Heading")

   Set rng = Nothing

   For i = 65 To 90
      SGGrid1.Array.Value(i - 65, 0) = Chr(i)
   Next
End Sub

Private Sub SGGrid1_ColMove( _
   ByVal ColIndex As Long, _
   ByVal newPosition As Long, _
   cancelMove As Boolean)

   If newPosition = 1 Or ColIndex = 1 Then
      cancelMove = True
   End If

End Sub

Private Sub SGGrid1_ColHide(ByVal ColIndex As Long, cancelHide As Boolean)

   cancelHide = (SGGrid1.Columns.At(0).ColIndex = ColIndex)

End Sub

Private Sub SGGrid1_RowColChange _
   (ByVal LastRowKey As Long, ByVal LastColIndex As Long)
   If LastColIndex > -1 Then
      SGGrid1.Rows(LastRowKey).Cells(0).Style.ForeColor = vbBlack
   End If

   SGGrid1.Rows.Current.Cells(0).Style.ForeColor = vbRed
End Sub

Back to topic


BaseColumnName Property (SGColumn Object)

BaseColumnName Property (SGColumn Object)
Returns a string that identifies the name of the associated database field.

Read-only at run time. Not available at design time.

Syntax

object.BaseColumnName As String

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

This property has effect only if the DataMode property is set to sgBound.


BaseTableName Property (SGColumn Object)

BaseTableName Property (SGColumn Object)
Returns a string that identifies the name of the associated database table.

Read-only at run time. Not available at design time.

Syntax

object.BaseTableName As String

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

This property has effect only if the DataMode property is set to sgBound.


Caption Property (SGColumn Object)

Caption Property (SGColumn Object)
Returns or sets column's heading text.

Read/Write at run time and design time.

Syntax

object.Caption As String

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

If the Caption property is set to an empty string, the column's DBField will be displayed in the column's heading.

Use the "Heading" style to define the caption appearance.

Show Example
Copy Code [image] Show Me

The following example creates a new column, sets column's caption and its appearance. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1.Columns.Add("NewCol")
      .Caption = "New Column"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .HeadingStyle.Font.Bold = True
      .HeadingStyle.ForeColor = vbRed
   End With
End Sub

Back to topic


ColIndex Property (SGColumn Object)

ColIndex Property (SGColumn Object)
Returns the one-based index of a column within the Columns collection.

Read-only at run time. Not available at design time.

Syntax

object.ColIndex As Long

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

Data columns have one-based index and the ColIndex of the heading column is always zero (0).

The value of the ColIndex property of a column can change when column is removed from the collection. So rather, refer to columns in a collection by using the column's key.

Show Example
Copy Code [image] Show Me

The following example creates four columns and fills cells with following columns properties: Key, ColIndex, DBIndex, DBField, Caption and Position. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.DataRowCount = 6
   'create two columns using the
   'DataColCount property
   SGGrid1.DataColCount = 2
   'create one column using the
   'Add method
   SGGrid1.Columns.Add
   'create one column using the
   'InsertAt method
   With SGGrid1.Columns.InsertAt(1)
      .Caption = "Inserted"
   End With
   'use cells to display columns properties
   For i = 1 To SGGrid1.DataColCount
      With SGGrid1.Columns.At(i)
         SGGrid1.Rows.At(1).Cells(i) = "Key=" & .Key
         SGGrid1.Rows.At(2).Cells(i) = "ColIndex=" & .ColIndex
         SGGrid1.Rows.At(3).Cells(i) = "DBIndex=" & .DBIndex
         SGGrid1.Rows.At(4).Cells(i) = "DBField=" & .DBField
         SGGrid1.Rows.At(5).Cells(i) = "Caption=" & .Caption
         SGGrid1.Rows.At(6).Cells(i) = "Position=" & .Position
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


Control Property (SGColumn Object)

Control Property (SGColumn Object)
Returns an SGControl object associated with the column.

Read-only at run time. Not available at design time.

Syntax

object.Control As IsgControl

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The Control property returns an SGControl object associated with the column.

For more information, see the SGControl topic.

Show Example
Copy Code [image] Show Me

The following example creates two columns. The first column uses a built-in combo box to represent data from the ValueItems collection. The second column uses a check box to represent its data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ctl As SGControl
   Dim i As Integer
   'create cols and rows
   SGGrid1.DataColCount = 2
   SGGrid1.DataRowCount = 10

   With SGGrid1.Columns(1)
      'add elements to the ValueItems
      'collection
      With .ValueItems
         For i = 0 To 10
            .Add i, "Item " & i, sgbipFirst + i
         Next

         .LimitToList = True
         .Default = 0
      End With
      Set ctl = .Control

      ctl.Type = sgCellDropDown
      'set DropDown size and position
      ctl.Width = .Width * 1.5
      ctl.PopupAlignment = sgPopupLeft
      ctl.PopupRows = 5
      'customize DropDown appearance
      With ctl.PopupStyle
         .BackColor = vbYellow
         .TextAlignment = sgAlignLeftCenter
         .PictureAlignment = sgPicAlignRightCenter
         .BorderColor = vbRed
         .BorderSize = 15
         .Borders = sgCellBorderBottom
         .BorderStyle = sgCellBorderDotted
         .Appearance = sg3DLight
      End With
   End With
   'use check-box ro represent columns data
   With SGGrid1.Columns(2).Control
      .Type = sgCellCheckBox
      .PopupStyle.Appearance = sg3DLight
   End With

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


DBField Property (SGColumn Object)

DBField Property (SGColumn Object)
Returns or sets the name of the bounded database filed.

Read/Write at run time and design time.

Syntax

object.DBField As String

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

Show Example
Copy Code [image] Show Me

The following example creates four columns and fills cells with following columns properties: Key, ColIndex, DBIndex, DBField, Caption and Position. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.DataRowCount = 6
   'create two columns using the
   'DataColCount property
   SGGrid1.DataColCount = 2
   'create one column using the
   'Add method
   SGGrid1.Columns.Add
   'create one column using the
   'InsertAt method
   With SGGrid1.Columns.InsertAt(1)
      .Caption = "Inserted"
   End With
   'use cells to display columns properties
   For i = 1 To SGGrid1.DataColCount
      With SGGrid1.Columns.At(i)
         SGGrid1.Rows.At(1).Cells(i) = "Key=" & .Key
         SGGrid1.Rows.At(2).Cells(i) = "ColIndex=" & .ColIndex
         SGGrid1.Rows.At(3).Cells(i) = "DBIndex=" & .DBIndex
         SGGrid1.Rows.At(4).Cells(i) = "DBField=" & .DBField
         SGGrid1.Rows.At(5).Cells(i) = "Caption=" & .Caption
         SGGrid1.Rows.At(6).Cells(i) = "Position=" & .Position
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


DBIndex Property (SGColumn Object)

DBIndex Property (SGColumn Object)
Returns zero-based index of the bounded database filed.

Read-only at run time. Not available at design time.

Syntax

object.DBIndex As Long

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

Show Example
Copy Code [image] Show Me

The following example creates four columns and fills cells with following columns properties: Key, ColIndex, DBIndex, DBField, Caption and Position. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.DataRowCount = 6
   'create two columns using the
   'DataColCount property
   SGGrid1.DataColCount = 2
   'create one column using the
   'Add method
   SGGrid1.Columns.Add
   'create one column using the
   'InsertAt method
   With SGGrid1.Columns.InsertAt(1)
      .Caption = "Inserted"
   End With
   'use cells to display columns properties
   For i = 1 To SGGrid1.DataColCount
      With SGGrid1.Columns.At(i)
         SGGrid1.Rows.At(1).Cells(i) = "Key=" & .Key
         SGGrid1.Rows.At(2).Cells(i) = "ColIndex=" & .ColIndex
         SGGrid1.Rows.At(3).Cells(i) = "DBIndex=" & .DBIndex
         SGGrid1.Rows.At(4).Cells(i) = "DBField=" & .DBField
         SGGrid1.Rows.At(5).Cells(i) = "Caption=" & .Caption
         SGGrid1.Rows.At(6).Cells(i) = "Position=" & .Position
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


DataChanged Property (SGColumn Object)

DataChanged Property (SGColumn Object)
Returns true if column's data has been changed.

Read-only at run time. Not available at design time.

Syntax

object.DataChanged As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The DataChanged property reflects only changes made by the user, not changes you made from your code.

After an update operation, this property returns False for all columns.

In addition, you can use the SGCell object's Status property to check if that cell's data has been changed.

Show Example
Copy Code [image] Show Me

The following example uses a column's caption to notify data changing for each column. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_BeforeUpdate(CancelUpdate As Boolean)
   Dim col As SGColumn

   For Each col In SGGrid1.Columns
      If col.DataChanged Then
         col.Caption = "Changed"
      Else
         col.Caption = "-"
      End If
      col.Redraw
   Next
End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns

   SGGrid1.DataColCount = 4
   SGGrid1.DataRowCount = 7
End Sub

Back to topic


DataType Property (SGColumn Object)

DataType Property (SGColumn Object)
Returns or sets column's data type.

Read/Write at run time and design time.

Syntax

object.DataType As sgDataType

The object placeholder represents an object expression that evaluates to the SGColumn object.

Settings

The DataType settings are:

Name | Value | Description
sgtEmpty | 0 | Data type is undefined.
sgtShort | 2 | 16 bit integer.
sgtLong | 3 | 32 bit integer.
sgtFloat | 4 | Single precision number.
sgtDouble | 5 | Double precision number.
sgtCurrency | 6 | Currency.
sgtDateTime | 7 | Date-time value.
sgtString | 8 | Character string.
sgtBoolean | 11 | Boolean.
sgtDecimal | 14 | Decimal.
sgtByte | 17 | 8 bit integer.
sgtBinary | 65 | Binary data.

Remarks

Show Example
Copy Code [image] Show Me

The following example creates few columns with a different DataType. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.Columns.RemoveAll False
   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   SGGrid1.AllowAddNew = True
   SGGrid1.ColumnClickSort = True

   With SGGrid1.Columns.Add("sgtBoolean")
      .DataType = sgtBoolean
   End With

   With SGGrid1.Columns.Add("sgtString")
      .DataType = sgtString
   End With

   With SGGrid1.Columns.Add("sgtCurrency")
      .DataType = sgtCurrency
   End With

   With SGGrid1.Columns.Add("sgtDateTime")
      .DataType = sgtDateTime
   End With

   With SGGrid1.Columns.Add("sgtByte")
      .DataType = sgtByte
   End With

   With SGGrid1.Columns.Add("sgtDecimal")
      .DataType = sgtDecimal
   End With

   With SGGrid1.Columns.Add("sgtDouble")
      .DataType = sgtDouble
   End With

   With SGGrid1.Columns.Add("sgtShort")
      .DataType = sgtShort
   End With
End Sub

Back to topic


DataWidth Property (SGColumn Object)

DataWidth Property (SGColumn Object)
Returns or sets the number of characters that can be entered when editing a cell.

Read/Write at run time and design time.

Syntax

object.DataWidth As Long

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The DataWidth property works like a TextBox's MaxLength property.

See Also

SGColumn


DefaultValue Property (SGColumn Object)

DefaultValue Property (SGColumn Object)
Returns or sets a default value for a column.

Read/Write at run time and design time.

Syntax

object.DefaultValue As Variant

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

Show Example
Copy Code [image] Show Me

The following example illustrates how to use the DefaultValue property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Enter some data to the first column.

Private Sub Form_Load()
   'remove cols and rows
   SGGrid1.Columns.RemoveAll False
   SGGrid1.DataRowCount = 0
   'enable row insertions
   SGGrid1.AllowAddNew = True
   'speed up data input
   SGGrid1.EnterKeyBehavior = sgEnterKeyRows
   'create the first col
   SGGrid1.Columns.Add
   'create the second col
   With SGGrid1.Columns.Add
      'add two elements to the ValueItems collection
      .ValueItems.Add 1, "First item", sgbipFirst
      .ValueItems.Add 2, "Second item", sgbipFirst + 1
      .DefaultValue = 2
      .Style.DisplayType = sgDisplayTextAndPicture
   End With
   'create the third col
   With SGGrid1.Columns.Add
      .DefaultValue = "Default"
   End With
End Sub

Back to topic


EditMask Property (SGColumn Object)

EditMask Property (SGColumn Object)
Returns or sets the input mask used to edit cells.

Read/Write at run time and design time.

Syntax

object.EditMask As String

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The EditMask property provides restricted data input as well as formatted data output. This property supplies visual cues about the type of data being entered or displayed.

Show Example
Copy Code [image] Show Me

The following example demonstrates the EditMask and the EditMaskDataMode properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Finally, enter some data into the last column.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim ar As SGArray

   With SGGrid1
      .FitLastColumn = True
      .EnterKeyBehavior = sgEnterKeyRows
      .UserDragging = sgNoRowColDrag
      .DataColCount = 3
      .DataRowCount = 13
      With .Columns(1)
         .Width = .Width * 2
         .Caption = "Mask"
      End With
      With .Columns(2)
         .Caption = "Mask Data Mode"
         .Control.Type = sgCellDropList
         .ValueItems.Default = sgMaskModeInput
         .ValueItems.Add sgMaskModeInput, "Store only data"
         .ValueItems.Add sgMaskModeIncludeLiterals, "Store data and literal characters"
         .ValueItems.Add sgMaskModeIncludePrompt, "Store data and prompt characters"
         .ValueItems.Add sgMaskModeSaveAll, "Store All"
      End With
      .Columns(3).Caption = "Data"
   End With

   Set ar = SGGrid1.Array

   ar.Value(0, 0) = "Digit: ###-####"
   ar.Value(1, 0) = "Digit: ###-####;q_"
   ar.Value(2, 0) = "Decimal: ###.###.###.###"
   ar.Value(3, 0) = "Thousands: ##,###.##"
   ar.Value(4, 0) = "Time: ##:##"
   ar.Value(5, 0) = "Date: ##/##/####"
   ar.Value(6, 0) = "\Alphanumeric: AAAAAAAAAA\, AAAAAAAA"
   ar.Value(7, 0) = "\Alphabetic: ????????????????"
   ar.Value(8, 0) = "Uppercase: >>>>>>> ????????"
   ar.Value(9, 0) = "Lowercase: <<<<<<< ????????"
   ar.Value(10, 0) = "Phone: (###)###-#### Ext:####"
   ar.Value(11, 0) = "AAA-#######"
   ar.Value(12, 0) = "&####-##-## ##\:##\:##"

   SGGrid1.Col = 3

End Sub

Private Sub SGGrid1_RowColChange _
   (ByVal LastRowKey As Long, ByVal LastColIndex As Long)

   If SGGrid1.Col <> 3 Then Exit Sub

   With SGGrid1
      .Editing = False
      .Columns.Current.EditMask = _
         .Rows.Current.Cells(1).Value
      .Columns.Current.EditMaskDataMode = _
         CLng(.Array.Value(.Rows.Current.DataIndex, 1))
   End With
End Sub

Back to topic


EditMaskDataMode Property (SGColumn Object)

EditMaskDataMode Property (SGColumn Object)
Returns or sets a value that determines how masked cells will be stored by the underlying data source.

Read/Write at run time and design time.

Syntax

object.EditMaskDataMode As sgMaskDataMode

The object placeholder represents an object expression that evaluates to the SGColumn object.

Settings

The EditMaskDataMode settings are:

Name | Value | Description
sgMaskModeInput | 0 | Store only entered characters.
sgMaskModeSaveAll | 1 | Store all characters.
sgMaskModeIncludeLiterals | 2 | Store entered and literal characters.
sgMaskModeIncludePrompt | 3 | Store entered and prompt characters.

Remarks

The EditMaskDataMode property has no effect if the column's EditMask property is set to zero string("").

Show Example
Copy Code [image] Show Me

The following example demonstrates the EditMask and the EditMaskDataMode properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Finally, enter some data into the last column.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim ar As SGArray

   With SGGrid1
      .FitLastColumn = True
      .EnterKeyBehavior = sgEnterKeyRows
      .UserDragging = sgNoRowColDrag
      .DataColCount = 3
      .DataRowCount = 13
      With .Columns(1)
         .Width = .Width * 2
         .Caption = "Mask"
      End With
      With .Columns(2)
         .Caption = "Mask Data Mode"
         .Control.Type = sgCellDropList
         .ValueItems.Default = sgMaskModeInput
         .ValueItems.Add sgMaskModeInput, "Store only data"
         .ValueItems.Add sgMaskModeIncludeLiterals, "Store data and literal characters"
         .ValueItems.Add sgMaskModeIncludePrompt, "Store data and prompt characters"
         .ValueItems.Add sgMaskModeSaveAll, "Store All"
      End With
      .Columns(3).Caption = "Data"
   End With

   Set ar = SGGrid1.Array

   ar.Value(0, 0) = "Digit: ###-####"
   ar.Value(1, 0) = "Digit: ###-####;q_"
   ar.Value(2, 0) = "Decimal: ###.###.###.###"
   ar.Value(3, 0) = "Thousands: ##,###.##"
   ar.Value(4, 0) = "Time: ##:##"
   ar.Value(5, 0) = "Date: ##/##/####"
   ar.Value(6, 0) = "\Alphanumeric: AAAAAAAAAA\, AAAAAAAA"
   ar.Value(7, 0) = "\Alphabetic: ????????????????"
   ar.Value(8, 0) = "Uppercase: >>>>>>> ????????"
   ar.Value(9, 0) = "Lowercase: <<<<<<< ????????"
   ar.Value(10, 0) = "Phone: (###)###-#### Ext:####"
   ar.Value(11, 0) = "AAA-#######"
   ar.Value(12, 0) = "&####-##-## ##\:##\:##"

   SGGrid1.Col = 3

End Sub

Private Sub SGGrid1_RowColChange _
   (ByVal LastRowKey As Long, ByVal LastColIndex As Long)

   If SGGrid1.Col <> 3 Then Exit Sub

   With SGGrid1
      .Editing = False
      .Columns.Current.EditMask = _
         .Rows.Current.Cells(1).Value
      .Columns.Current.EditMaskDataMode = _
         CLng(.Array.Value(.Rows.Current.DataIndex, 1))
   End With
End Sub

Back to topic


FetchCellStyle Property (SGColumn Object)

FetchCellStyle Property (SGColumn Object)
Returns or sets a value indicating whether FetchCellStyle event is fired.

Read/Write at run time and design time.

Syntax

object.FetchCellStyle As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

Set this property to True to fire the FetchCellStyle event.

Show Example
Copy Code [image] Show Me

The following example paints cells using a cell value to get color. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchCellStyle(ByVal RowKey As Long, _
   ByVal ColIndex As Long, ByVal cellValue As Variant, _
   ByVal cellStyle As IsgStyle)
   cellStyle.BackColor = QBColor(cellValue Mod 16)
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.DataRowCount = 12
   SGGrid1.Columns(1).FetchCellStyle = True
   SGGrid1.GroupByBoxVisible = False

   For i = 0 To SGGrid1.DataRowCount - 1
      SGGrid1.Array.Value(i, 0) = i + 1
   Next
End Sub

Back to topic


Frozen Property (SGColumn Object)

Frozen Property (SGColumn Object)
Returns or sets a value indicating whether the column is frozen.

Read/Write at run time and design time.

Syntax

object.Frozen As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The Frozen property controls column's "freeze" state. When a column is "frozen", it remains visible when the user scrolls horizontally. Frozen column is positioned at the left side of the grid and value of its Position property is always smaller than the value of the control's FrozenColCount property.

The code below freezes two columns:

Private Sub Form_Load()
   SGGrid1.DataColCount = 10

   SGGrid1.Columns(7).Frozen = True
   SGGrid1.Columns(4).Frozen = True
End Sub

Use the "Frozen" style to change appearance of the frozen columns.

Show Example
Copy Code [image] Show Me

The following example fills the grid with test data, freezes the first row and col and applies the heading style to them. Press the command button to freeze additional rows and cols. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   If SGGrid1.FrozenColCount > 3 Then
      SGGrid1.Columns.At(SGGrid1.FrozenColCount).Frozen = False
      SGGrid1.Rows.At(SGGrid1.FrozenRowCount).Frozen = False
   Else
      SGGrid1.Columns.At(SGGrid1.FrozenColCount + 1).Frozen = True
      SGGrid1.Rows.At(SGGrid1.FrozenRowCount + 1).Frozen = True
   End If
End Sub

Private Sub Form_Load()
   Dim ar As SGArray
   Dim i&, j&

   'assign grid array to variable
   Set ar = SGGrid1.Array

   SGGrid1.RowNumbering = True

   SGGrid1.DataColCount = 20
   SGGrid1.DataRowCount = 100
   'load test data
   For i = 0 To SGGrid1.DataColCount - 1
      SGGrid1.Columns.At(i).Caption = "Col " & Trim(i)
      For j = 0 To SGGrid1.DataRowCount - 1
         ar.Value(j, i) = "Row=" & j & " Col=" & i
      Next
   Next

   'make two first cols and rows frozen and
   'apply the Heading to them
   SGGrid1.GridLines = SGGrid1.HeadingGridLines
   SGGrid1.Styles("Frozen").CopyFrom SGGrid1.Styles("Heading")

   SGGrid1.Columns.At(1).Frozen = True
   SGGrid1.Rows.At(1).Frozen = True

   Set ar = Nothing
End Sub

Back to topic


Heading Property (SGColumn Object)

Heading Property (SGColumn Object)
Returns True if column is heading column.

Read-only at run time. Not available at design time.

Syntax

object.Heading As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

Use the HeadingColCount property to add/remove heading columns.

Show Example
Copy Code [image] Show Me

The following example paints all columns (except the heading column) to random color. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim col As SGColumn

   SGGrid1.DataColCount = 10

   For Each col In SGGrid1.Columns
      If Not col.Heading Then
         col.Caption = "Col " & col.ColIndex
         col.Style.BackColor = Rnd * vbWhite
      End If
   Next
End Sub

Back to topic


HeadingPicture Property (SGColumn Object)

HeadingPicture Property (SGColumn Object)
Returns or sets picture displayed in the column heading.

Read/Write at run time and design time.

Syntax

object.HeadingPicture As Variant

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The HeadingPicture property is a variant expression that represent picture. You can pass Picture object or long expression that represents the index of the image from the grid image list Images. You can also use the grid's buil-in pictures using values from sgbipFirst to sgbipLast.

Set the heading style's DisplayType property to sgDisplayPicture or sgDisplayTextAndPicture to display heading picture.

Show Example
Copy Code [image] Show Me

The following example shows few possible sources for a heading picture. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.DataColCount = 4
   SGGrid1.RowNumbering = True

   With SGGrid1.Columns
      .At(1).HeadingPicture = Me.Icon
      .At(2).HeadingPicture = sgbipFirst
      .At(3).HeadingPicture = .At(1).HeadingPicture
      .At(4).HeadingPicture = _
         SGGrid1.CellAsPicture( _
         SGGrid1.Rows.At(1).Key, .At(0).Key)
   End With
End Sub

Back to topic


HeadingStyle Property (SGColumn Object)

HeadingStyle Property (SGColumn Object)
Returns the SGStyle object associated with the column heading.

Read-only at run time. Not available at design time.

Syntax

object.HeadingStyle As IsgStyle

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

By default, the column heading style is derived from the "Heading" style.

For more information, see the SGStyle topic.

Show Example
Copy Code [image] Show Me

The following example paints the caption of the current column to green. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_RowColChange _
   (ByVal LastRowKey As Long, ByVal LastColIndex As Long)
   'exit if a row has changed
   If LastColIndex = SGGrid1.Columns.Current.ColIndex Then Exit Sub
   'change heading of the current column
   With SGGrid1.Columns.Current
      .HeadingStyle = "CurrentCol"
      .Redraw
   End With
   'reset style of the previous current cell
   If LastColIndex <> -1 Then
      With SGGrid1.Columns(LastColIndex)
         .HeadingStyle = "Heading"
         .Redraw
      End With
   End If
End Sub

Private Sub SGGrid1_OnInit()
   'create seven cols
   SGGrid1.DataColCount = 7
   'create new custom style
   With SGGrid1.Styles.Add("CurrentCol")
      .BaseStyle = "Heading"
      .ForeColor = vbGreen
      .Font.Bold = True
   End With
End Sub

Back to topic


Hidden Property (SGColumn Object)

Hidden Property (SGColumn Object)
Determines whether the column is hidden or not.

Read/Write at run time and design time.

Syntax

object.Hidden As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

Hidden column is a column that is not displayed. To hide a column, you can set the Hidden property to True. In addition, the user can hide a column by dragging its heading away. You can prevent users from hiding columns by setting the control's UserHiding property to sgNoRowColHide or sgAllowRowHide.

Don't confuse the Hidden and the Visible properties. If a particular column has been scrolled out of the view, its Hidden property remains True. However, a column is not visible any more and thus, its Visible property changes to False.

Show Example
Copy Code [image] Show Me

The following example records the Visible and the Hidden properties of the Column object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   'create cols and rows
   SGGrid1.DataColCount = 10
   SGGrid1.DataRowCount = 9

   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns(1)
      .Frozen = True
      .Width = .Width * 1.8
      .Caption = "Visible And Hidden Cols"
   End With

   SGGrid1_AfterScroll 0, 0, 0, 0
End Sub

Private Sub SGGrid1_AfterScroll _
   (ByVal OldTopRow As Long, ByVal OldLeftCol As Long, _
   ByVal NewTopRow As Long, ByVal NewLeftCol As Long)
   Dim col As SGColumn
   Dim i As Integer

   With SGGrid1
      For i = 2 To .ColCount - 1
         Set col = .Columns(i)
         'record visible and hidden props
         .Array.Value(i - 2, 0) = _
            "Col: " & Trim(i - 1) & " H=" & _
            col.Hidden & " V=" & col.Visible
      Next
   End With
End Sub

Private Sub SGGrid1_ColHide( _
   ByVal ColIndex As Long, _
   CancelHide As Boolean)

   SGGrid1_AfterScroll 0, 0, 0, 0
   SGGrid1.Array.Value(ColIndex - 2, 0) = _
      "Col: " & Trim(ColIndex - 1) & " H=True V=False"

End Sub

Back to topic


Key Property (SGColumn Object)

Key Property (SGColumn Object)
Returns or sets column's unique identifier.

Read/Write at run time and design time.

Syntax

object.Key As String

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The column's key is a case sensitive string value that uniquely identifies a column. Column's key cannot be changed during column's lifetime. It is assigned to the column when column is created. You can set the column's key when you use the Add method to add a column to the collection.

The value of the ColIndex property of a column can change when column is removed from the collection. So rather, refer to columns in a collection by using column's key.

Show Example
Copy Code [image] Show Me

The following example creates four columns and fills cells with following columns properties: Key, ColIndex, DBIndex, DBField, Caption and Position. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.DataRowCount = 6
   'create two columns using the
   'DataColCount property
   SGGrid1.DataColCount = 2
   'create one column using the
   'Add method
   SGGrid1.Columns.Add
   'create one column using the
   'InsertAt method
   With SGGrid1.Columns.InsertAt(1)
      .Caption = "Inserted"
   End With
   'use cells to display columns properties
   For i = 1 To SGGrid1.DataColCount
      With SGGrid1.Columns.At(i)
         SGGrid1.Rows.At(1).Cells(i) = "Key=" & .Key
         SGGrid1.Rows.At(2).Cells(i) = "ColIndex=" & .ColIndex
         SGGrid1.Rows.At(3).Cells(i) = "DBIndex=" & .DBIndex
         SGGrid1.Rows.At(4).Cells(i) = "DBField=" & .DBField
         SGGrid1.Rows.At(5).Cells(i) = "Caption=" & .Caption
         SGGrid1.Rows.At(6).Cells(i) = "Position=" & .Position
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


Left Property (SGColumn Object)

Left Property (SGColumn Object)
Returns the position of the column's left edge.

Read-only at run time. Not available at design time.

Syntax

object.Left As OLE_XPOS_CONTAINER

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The Left property is specified in terms of the container's coordinate system.

Column's Left and Right properties are valid only for completely visible columns. This property returns -1, if the column is not visible.

Show Example
Copy Code [image] Show Me

The following example uses the AfterScroll event to paint a column placed at the middle of grid to blue. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_AfterScroll(ByVal OldTopRow As Long, _
   ByVal OldLeftCol As Long, ByVal NewTopRow As Long, _
   ByVal NewLeftCol As Long)
   Dim col As SGColumn
   Dim lPoint As Long
   'get midlle point
   lPoint = SGGrid1.ClientWidth / 2
   lPoint = lPoint + SGGrid1.Columns(SGGrid1.LeftCol).Left
   'repaint columns to the default color
   SGGrid1.Styles.RemoveCustom
   'get a column placed at the midlle of grid
   'and paint it blue
   For Each col In SGGrid1.Columns
      If col.Left <= lPoint And col.Right >= lPoint Then
         col.Style.BackColor = vbBlue
         Exit For
      End If
   Next
End Sub

Private Sub SGGrid1_OnInit()
   'create columns
   SGGrid1.DataColCount = 12

   SGGrid1_AfterScroll 0, 0, 0, 0
End Sub

Back to topic


MergeCells Property (SGColumn Object)

MergeCells Property (SGColumn Object)
Returns or sets a value indicating cell merging rules.

Read/Write at run time and design time.

Syntax

object.MergeCells As sgCellMerge

The object placeholder represents an object expression that evaluates to the SGColumn object.

Settings

The MergeCells settings are:

Name | Value | Description
sgMergeNone | 0 | Do not merge cells.
sgMergeFree | 1 | Merge cells with same contents.

Remarks

Set the MergeCells property to sgMergeFree to merge adjacent cells with the same contents into a single cell.

You can use the TextAlignment, WordWrap and PictureAlignment properties of the column's SGStyle object to center the text and picture within the merged cell.

Show Example
Copy Code [image] Show Me

The following example fills the grid with random numbers and merges the first and second column. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, lRndNumber As Long
   Dim ar As SGArray
   'create three columns
   SGGrid1.Columns.RemoveAll False
   With SGGrid1.Columns.Add("Mod4")
      .MergeCells = sgMergeFree
      .Style.TextAlignment = sgAlignCenterCenter
      .ValueItems.Add 0, "Zero", sgbipFirst
      .ValueItems.Add 1, "One", sgbipFirst + 1
      .ValueItems.Add 2, "Two", sgbipFirst + 2
      .ValueItems.Add 3, "Three", sgbipFirst + 3
      .Style.WordWrap = True
      .DataType = sgtShort
      .Style.DisplayType = sgDisplayTextAndPicture
   End With

   With SGGrid1.Columns.Add("Mod7")
      .MergeCells = sgMergeFree
      .DataType = sgtShort
   End With

   SGGrid1.Columns.Add "Random Value"
   SGGrid1.DataRowCount = 50
   '---end col & row creations-----

   'fill grid with random numbers
   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndNumber = CLng(Rnd * 1000)
      ar.Value(i, 0) = lRndNumber Mod 4
      ar.Value(i, 1) = lRndNumber Mod 7
      ar.Value(i, 2) = lRndNumber
   Next

   Set ar = Nothing
   'sort by marged columns
   SGGrid1_ColHeadClick 1
End Sub

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   Dim so As sgSortOrder
   'change current sort order
   If SGGrid1.Columns(ColIndex).SortOrder = sgSortAscending Then
      so = sgSortDescending
   Else
      so = sgSortAscending
   End If

   Select Case ColIndex
      Case 1, 2
         SGGrid1.Sort -1, -1, "Mod4", so, sgSortTypeNumber, _
            "Mod7", so, sgSortTypeNumber
      Case Else
         SGGrid1.Sort -1, -1, "Mod4", so, sgSortTypeNumber, _
            "Mod7", so, sgSortTypeNumber, "Random Value", so, sgSortTypeNumber
   End Select
End Sub

Back to topic


Position Property (SGColumn Object)

Position Property (SGColumn Object)
Returns or sets column's position. Zero-based.

Read/Write at run time and design time.

Syntax

object.Position As Long

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The Position property returns or sets the current position of a particular column. It's zero-based.

You can use the SGColumns collection's At method to refer to a column if you know its position.

Show Example
Copy Code [image] Show Me

The following example uses the RowHeadClick event to sort columns by cells value in the clicked row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Click on the any row head.

Private Sub SGGrid1_RowHeadClick(ByVal RowKey As Long)
   Dim row As SGRow, i As Integer
   Dim j As Integer, iMinValue As Integer
   Dim lVal1 As Long, lVal2 As Long
   'stop drawing
   SGGrid1.RedrawEnabled = False
   'reference the current row
   Set row = SGGrid1.Rows(RowKey)
   'sort columns by values from the current row
   For i = 1 To SGGrid1.DataColCount
      iMinValue = i
      For j = i To SGGrid1.DataColCount
         lVal1 = CLng(row.Cells(j).Value)
         lVal2 = CLng(row.Cells(iMinValue).Value)
         If lVal1 < lVal2 Then iMinValue = j
      Next

      If iMinValue > i Then
         row.Cells(iMinValue).Column.Position = i
      End If
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray, lRndNum As Long
   'create cols and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DefaultColWidth = 505
   SGGrid1.DataColCount = 7
   SGGrid1.DataRowCount = 12

   SGGrid1.GroupByBoxVisible = False
   'add random numbers
   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         lRndNum = CLng(Rnd * 255)
         ar.Value(i, j) = lRndNum
         'paint cells
         SGGrid1.CellAt(i + 1, j + 1).Style.BackColor = _
            RGB(255 - lRndNum, 255, 255)
      Next
   Next

   Set ar = Nothing
End Sub

Back to topic


ReadOnly Property (SGColumn Object)

ReadOnly Property (SGColumn Object)
Returns or sets a value indicating whether an object can be edited.

Read/Write at run time and design time.

Syntax

object.ReadOnly As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The ReadOnly property prevents the user from changing the data in the specified column. You can change data from your code even if ReadOnly property is set to True.

Use the control's SkipReadOnly property to skip read only columns and speed up data input.

Show Example
Copy Code [image] Show Me

The following example creates the new column and sets the ReadOnly property to true.

Private Sub SGGrid1_OnInit()

   With SGGrid1.Columns.Add
      .Caption = "ReadOnly"
      .ReadOnly = True
   End With

End Sub

Back to topic


Right Property (SGColumn Object)

Right Property (SGColumn Object)
Returns the position of the column's right edge.

Read-only at run time. Not available at design time.

Syntax

object.Right As OLE_XPOS_CONTAINER

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The Right property is specified in terms of the container's coordinate system.

Column's Left and Right properties are valid only for completely visible columns. This property returns -1, if the column is not visible.

Show Example
Copy Code [image] Show Me

The following example resizes the grid to fit the last visible column. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 10
   SGGrid1.Width = SGGrid1.Columns(SGGrid1.VisibleCols - 1).Right
End Sub

Back to topic


SortOrder Property (SGColumn Object)

SortOrder Property (SGColumn Object)
Returns or sets column's sort order.

Read/Write at run time and design time.

Syntax

object.SortOrder As sgSortOrder

The object placeholder represents an object expression that evaluates to the SGColumn object.

Settings

The SortOrder settings are:

Name | Value | Description
sgNoSorting | 0 | Do not sort.
sgSortAscending | 1 | Sort in ascending order.
sgSortDescending | 2 | Sort in descending order.

Remarks

The SortOrder property indicates column's sorting order. It is automatically changed when the user clicks on a column' heading. In addition, it will be changed when you invoke the Sort method from the code and specify a different sort order.

By default, this property is set to sgNoSorting. If you change this property a column will not be sorted. Use the Sort method to sort a column.

When a column is sorted, a small arrow occurs in the column's heading. If you want to hide that arrow, set the SortOrder property to sgNoSorting.

Show Example
Copy Code [image] Show Me

The following example fills grid with sample data and uses the Sort method to sort them. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   Dim so(2) As sgSortOrder
   Dim sColKey As String

   Select Case ColIndex
      Case 1
         If SGGrid1.Columns(ColIndex).SortOrder = sgSortAscending Then
            so(0) = sgSortDescending
            so(1) = sgSortAscending
            so(2) = sgSortDescending
         Else
            so(0) = sgSortAscending
            so(1) = sgSortDescending
            so(2) = sgSortAscending
         End If

         SGGrid1.Sort -1, -1, _
            "n1", so(0), sgSortTypeNumber, _
            "n2", so(1), sgSortTypeNumber, _
            "dt", so(2), sgSortTypeDateTime
      Case 2, 3
         sColKey = SGGrid1.Columns(ColIndex).Key

         If SGGrid1.Columns(ColIndex).SortOrder = sgSortAscending Then
            SGGrid1.Sort -1, -1, sColKey, sgSortDescending, sgSortTypeDateTime
         Else
            SGGrid1.Sort -1, -1, sColKey, sgSortAscending, sgSortTypeDateTime
         End If
   End Select
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Long, j As Integer

   With SGGrid1
      .Columns.RemoveAll False
      .CacheAllRecords = True
      .ColumnClickSort = False
      .GroupByBoxVisible = False

      With .Columns.Add("n1")
         .Caption = "Nr 1"
         .DataType = sgtLong
      End With

      With .Columns.Add("n2")
         .Caption = "Nr 2"
         .DataType = sgtLong
      End With

      With .Columns.Add("dt")
         .Caption = "Date"
         .DataType = sgtDateTime
         .SortType = sgSortTypeDateTime
      End With

      .DataRowCount = 50

      For i = 0 To .DataRowCount - 1
         .Array.Value(i, 0) = CLng(Rnd * 20)
         .Array.Value(i, 1) = CLng(Rnd * 10)
         .Array.Value(i, 2) = _
            FormatDateTime(CDate(Rnd * 365 + CLng(Now)), vbShortDate)
      Next
   End With
End Sub

Back to topic


SortType Property (SGColumn Object)

SortType Property (SGColumn Object)
Returns or sets data type used when sorting.

Read/Write at run time and design time.

Syntax

object.SortType As sgSortType

The object placeholder represents an object expression that evaluates to the SGColumn object.

Settings

The SortType settings are:

Name | Value | Description
sgSortTypeDefault | 0 | Convert values to the column's data type before comparing.
sgSortTypeCustom | 1 | Fire the CompareCell event to compare two values.
sgSortTypeNumber | 2 | Convert to double-precision values before comparing.
sgSortTypeString | 3 | Convert to string values before comparing.
sgSortTypeNoCaseString | 4 | Convert to string values before comparing. Ignore case.
sgSortTypeDateTime | 5 | Convert to date-time values before comparing.

Remarks

The SortType property determines the data type used to coerce column values during comparison. In addition, if you set it to sgSortTypeCustom, BeeGrid will fire CompareCells event. In the CompareCells event you can implement customized cell comparation rules.

By default, this property is set to sgSortTypeDefault and the grid uses the column's DataType property while sorting.

Show Example
Copy Code [image] Show Me

The following example fills grid with sample data and uses the Sort method to sort them. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   Dim so(2) As sgSortOrder
   Dim sColKey As String

   Select Case ColIndex
      Case 1
         If SGGrid1.Columns(ColIndex).SortOrder = sgSortAscending Then
            so(0) = sgSortDescending
            so(1) = sgSortAscending
            so(2) = sgSortDescending
         Else
            so(0) = sgSortAscending
            so(1) = sgSortDescending
            so(2) = sgSortAscending
         End If

         SGGrid1.Sort -1, -1, _
            "n1", so(0), sgSortTypeNumber, _
            "n2", so(1), sgSortTypeNumber, _
            "dt", so(2), sgSortTypeDateTime
      Case 2, 3
         sColKey = SGGrid1.Columns(ColIndex).Key

         If SGGrid1.Columns(ColIndex).SortOrder = sgSortAscending Then
            SGGrid1.Sort -1, -1, sColKey, sgSortDescending, sgSortTypeDateTime
         Else
            SGGrid1.Sort -1, -1, sColKey, sgSortAscending, sgSortTypeDateTime
         End If
   End Select
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Long, j As Integer

   With SGGrid1
      .Columns.RemoveAll False
      .CacheAllRecords = True
      .ColumnClickSort = False
      .GroupByBoxVisible = False

      With .Columns.Add("n1")
         .Caption = "Nr 1"
         .DataType = sgtLong
      End With

      With .Columns.Add("n2")
         .Caption = "Nr 2"
         .DataType = sgtLong
      End With

      With .Columns.Add("dt")
         .Caption = "Date"
         .DataType = sgtDateTime
         .SortType = sgSortTypeDateTime
      End With

      .DataRowCount = 50

      For i = 0 To .DataRowCount - 1
         .Array.Value(i, 0) = CLng(Rnd * 20)
         .Array.Value(i, 1) = CLng(Rnd * 10)
         .Array.Value(i, 2) = _
            FormatDateTime(CDate(Rnd * 365 + CLng(Now)), vbShortDate)
      Next
   End With
End Sub

Back to topic


Style Property (SGColumn Object)

Style Property (SGColumn Object)
Returns the SGStyle object associated with the column.

Read-only at run time. Not available at design time.

Syntax

object.Style As IsgStyle

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

By default, data columns use the "Normal" style and the heading column uses "Heading" style.

For more information, see the SGStyle topic.

Show Example
Copy Code [image] Show Me

The following example shows how to use the column Style object in various ways. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray

   With SGGrid1
      .DataColCount = 5
      .DataRowCount = 20
      'use named styles
      .Columns(1).Style = "Tip"
      With .Styles.Add("MyStyle")
         .Font.Bold = True
         .ForeColor = vbGreen
         .BackColor = vbBlack
      End With
      'use custom style
      .Columns(2).Style = "MyStyle"
      'change column style
      With .Columns(3).Style
         .TextAlignment = sgAlignCenterCenter
         .Font.Underline = True
      End With
      'fetch style
      .Columns(4).FetchCellStyle = True
      'use style conditions
      .Columns(5).StyleConditions.Add "MyStyle", _
         sgConditionCellValue, sgOpGreaterThan, 500
   End With
   'fill the grid with random numbers
   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 1000)
      Next
   Next

   Set ar = Nothing
End Sub

Private Sub SGGrid1_FetchCellStyle _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal CellValue As Variant, ByVal CellStyle As IsgStyle)
   If CellValue Mod 2 Then
      CellStyle.ForeColor = vbRed
   End If
End Sub

Back to topic


StyleConditions Property (SGColumn Object)

StyleConditions Property (SGColumn Object)
Returns the collection of a conditional style rules.

Read-only at run time. Not available at design time.

Syntax

object.StyleConditions As IsgStyleConditions

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The StyleConditions property returns a collection of the SGStyleCondition objects. Each object in this collection represents one style and condition when that style can be applied. When the BeeGrid paints a cell, it examines this collection and if a condition is met, style is applied to the cell.

You can manipulate members of the SGStyleConditions collection by using standard collection methods. Each object in the collection can be accessed by its index.

Use the Add method to add a new condition to a collection:

   SGGrid1.Columns(1).StyleConditions.Add _
      "Tip", sgConditionCellValue, sgOpGreaterThan, 1

For more information, see the SGStyleConditions topic.

Show Example
Copy Code [image] Show Me

The following example ads three columns and creates three different StyleCondition for each column. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray

   With SGGrid1
      .DataColCount = 3
      .DataRowCount = 20
      .Columns(1).StyleConditions.Add "Heading", _
         sgConditionCellValue, sgOpBetween, 200, 600

      With .Styles.Add("MyStyle")
         .Font.Bold = True
         .ForeColor = vbGreen
         .BackColor = vbBlack
      End With
      .Columns(2).StyleConditions.Add "MyStyle", _
         sgConditionCellValue, sgOpGreaterThan, 500
      .Columns(3).StyleConditions.Add "Frozen", _
         sgConditionCellValue, sgOpLessThan, 500
   End With
   'fill the grid with random numbers
   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 1000)
      Next
   Next

   Set ar = Nothing
End Sub

Back to topic


Tag Property (SGColumn Object)

Tag Property (SGColumn Object)
Returns or sets user defined value associated with the grid column.

Read/Write at run time. Not available at design time.

Syntax

object.Tag As Variant

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

Returns or sets an expression that stores any extra data needed for a column.

Show Example
Copy Code [image] Show Me

The following example uses a column tag to store column's minimal width. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.DataColCount = 4
   'store min column width in column tag
   For i = 1 To SGGrid1.DataColCount
      SGGrid1.Columns(i).Tag = SGGrid1.Columns(1).Width / i
   Next
End Sub

Private Sub SGGrid1_ColResize _
   (ByVal ColIndex As Long, CancelResize As Boolean)
   Dim col As SGColumn

   Set col = SGGrid1.Columns(ColIndex)
   CancelResize = CLng(col.Tag) > col.Width

   Set col = Nothing
End Sub

Back to topic

See Also

SGColumn


ValueItems Property (SGColumn Object)

ValueItems Property (SGColumn Object)
Collection of column's value items.

Read-only at run time. Not available at design time.

Syntax

object.ValueItems As IsgValueItems

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The ValueItems collection enables you to specify alternate text and pictures to be displayed in place of the underlying data values.

You can manipulate SGValueItems collection by using standard collection methods. Each value item in the collection can be accessed by its index.

Use the Add method to add a new value item to the collection:

   SGGrid1.Columns(1).ValueItems.Add 1, "Pig", LoadPicture("Pig.bmp")

For more information, see the SGValueItems topic.

Show Example
Copy Code [image] Show Me

The following example creates two columns. The first column uses a built-in combo box to represent data from the ValueItems collection. The second column uses a check box to represent its data. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ctl As SGControl
   Dim i As Integer
   'create cols and rows
   SGGrid1.DataColCount = 2
   SGGrid1.DataRowCount = 10

   With SGGrid1.Columns(1)
      'add elements to the ValueItems
      'collection
      With .ValueItems
         For i = 0 To 10
            .Add i, "Item " & i, sgbipFirst + i
         Next

         .LimitToList = True
         .Default = 0
      End With
      Set ctl = .Control

      ctl.Type = sgCellDropDown
      'set DropDown size and position
      ctl.Width = .Width * 1.5
      ctl.PopupAlignment = sgPopupLeft
      ctl.PopupRows = 5
      'customize DropDown appearance
      With ctl.PopupStyle
         .BackColor = vbYellow
         .TextAlignment = sgAlignLeftCenter
         .PictureAlignment = sgPicAlignRightCenter
         .BorderColor = vbRed
         .BorderSize = 15
         .Borders = sgCellBorderBottom
         .BorderStyle = sgCellBorderDotted
         .Appearance = sg3DLight
      End With
   End With
   'use check-box ro represent columns data
   With SGGrid1.Columns(2).Control
      .Type = sgCellCheckBox
      .PopupStyle.Appearance = sg3DLight
   End With

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


Visible Property (SGColumn Object)

Visible Property (SGColumn Object)
Returns whether a column is currently within view.

Read-only at run time. Not available at design time.

Syntax

object.Visible As Boolean

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The Visible property indicates whether a column is currently visible. This property returns False if a particular column has been scrolled out of view. In addition, it will return False if column's Hidden property is set to True.

Don't confuse the Hidden and the Visible properties. If a particular column has been scrolled out of the view, its Hidden property remains True. However, a column is not visible any more and thus, its Visible property changes to False.

Show Example
Copy Code [image] Show Me

The following example records the Visible and the Hidden properties of the Column object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   'create cols and rows
   SGGrid1.DataColCount = 10
   SGGrid1.DataRowCount = 9

   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns(1)
      .Frozen = True
      .Width = .Width * 1.8
      .Caption = "Visible And Hidden Cols"
   End With

   SGGrid1_AfterScroll 0, 0, 0, 0
End Sub

Private Sub SGGrid1_AfterScroll _
   (ByVal OldTopRow As Long, ByVal OldLeftCol As Long, _
   ByVal NewTopRow As Long, ByVal NewLeftCol As Long)
   Dim col As SGColumn
   Dim i As Integer

   With SGGrid1
      For i = 2 To .ColCount - 1
         Set col = .Columns(i)
         'record visible and hidden props
         .Array.Value(i - 2, 0) = _
            "Col: " & Trim(i - 1) & " H=" & _
            col.Hidden & " V=" & col.Visible
      Next
   End With
End Sub

Private Sub SGGrid1_ColHide( _
   ByVal ColIndex As Long, _
   CancelHide As Boolean)

   SGGrid1_AfterScroll 0, 0, 0, 0
   SGGrid1.Array.Value(ColIndex - 2, 0) = _
      "Col: " & Trim(ColIndex - 1) & " H=True V=False"

End Sub

Back to topic


Width Property (SGColumn Object)

Width Property (SGColumn Object)
Returns or sets column's width.

Read/Write at run time and design time.

Syntax

object.Width As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGColumn object.

Remarks

The Width property is specified in terms of the container's coordinate system.

Show Example
Copy Code [image] Show Me

The following example resizes the first column at a half size of the grid. Other columns use the second half. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim lGridWidth As Long
   'get place for data columns
   lGridWidth = SGGrid1.ClientWidth - SGGrid1.Columns(0).Width
   'create columns
   SGGrid1.DataColCount = 6
   SGGrid1.FitLastColumn = True
   'resize columns
   SGGrid1.Columns(1).Width = lGridWidth / 2

   For i = 2 To SGGrid1.DataColCount
      SGGrid1.Columns(i).Width = lGridWidth / 10
   Next
End Sub

Back to topic


SGColumn Methods

AutoSize | Resize column to fit cell content.
GetDefinition | Returns XML representation of the Column object.
Redraw | Redraws column.
SetDefinition | Initializes Column object with XML string.


AutoSize Method (SGColumn Object)

AutoSize Method (SGColumn Object)
Resize column to fit cell content.
Syntax | object.AutoSize
Return Value | None
Arguments | None

Remarks

The AutoSize method resizes a specified column width to fit cell content. You can use the AutoSizeColumns method to resize all columns.


GetDefinition Method (SGCondition Object)

GetDefinition Method
Returns XML representation of the specified object.
Syntax | object.GetDefinition
Return Value | A String value containing the object's definition.
Arguments | None

Remarks

Typically, you use this method to save condition settings to the hard disk or to the database.

The following code saves the styles definition using the xmldom object.

   Dim xmlDoc As Object
   Dim sStyleDefinition As String

   Set xmlDoc = CreateObject("microsoft.xmldom")

   sStyleDefinition = SGGrid1.Styles.GetDefinition
   xmlDoc.loadXML sStyleDefinition

   xmlDoc.Save sFileName

   Set xmlDoc = Nothing
Show Example
Copy Code [image] Show Me

The following example saves the style definition using generic SaveDefinition function.

Private Sub SGGrid1_OnInit()
    SaveDefinition SGGrid1.Styles("Normal"),"Sty_Normal.xml"
End Sub

Private Sub SaveDefinition( _
   oGridObject As Object, sFileName As String)
   Dim iFreeFile As Integer
   Dim sDefinition As String

   sDefinition = oGridObject.GetDefinition

   iFreeFile = FreeFile

   Open sFileName For _
      Binary Access Write As iFreeFile

   Put #iFreeFile, , sDefinition
   Close #iFreeFile
End Sub

Back to topic

See Also

SetDefinition


Redraw Method (SGColumn Object)

Redraw Method (SGColumn Object)
Redraws column.
Syntax | object.Redraw
Return Value | None
Arguments | None

Remarks

The Redraw method has no effect if the control's RedrawEnabled property is set to False.

If the column's FetchCellStyle property is set to True, the Redraw method fires the FetchCellStyle event.

Show Example
Copy Code [image] Show Me

The following example paints column to red and redraws it. To try the example, place a SGGrid and CommandButton on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()

   SGGrid1.Columns(2).Style.BackColor = vbRed
   SGGrid1.Columns(2).Redraw

End Sub

Back to topic


SetDefinition Method (SGCondition Object)

SetDefinition Method
Initializes specified object with XML string.
Syntax

object.SetDefinition(XMLDefinition As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGCondition object.
XMLDefinition | A String expression that containing the XML definition.

Remarks

Typically, you use this method to load condition settings from the hard disk or from the database.

The following example uses the XMLDOMDocument Object to loads the column definition from the file.

   Dim xmlDoc As Object

   Set xmlDoc = CreateObject("microsoft.xmldom")

   xmlDoc.Load sFileName
   SGGrid1.Columns(sColKey).SetDefinition xmlDoc.xml

   Set xmlDoc = Nothing
Show Example
Copy Code [image] Show Me

The following example loads the style definition using generic LoadDefinition function.

Private Sub SGGrid1_OnInit()
   LoadDefinition SGGrid1.Styles("Normal"),"Sty_Normal.xml"
End Sub

Private Sub LoadDefinition( _
   oGridObject As Object, sFileName As String)
   Dim iFreeFile As Integer
   Dim sDefinition As String

   sDefinition = String(FileLen(sFileName), " ")

   iFreeFile = FreeFile

   Open sFileName For _
      Binary Access Read As iFreeFile

   Get #iFreeFile, , sDefinition
   Close #iFreeFile

   oGridObject.SetDefinition sDefinition
End Sub

Back to topic

See Also

GetDefinition


SGColumns Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGColumns Object

Name: | SGColumns
Description: | Collection of SGColumn objects.
GUID: | {F0A68CB3-9109-11D2-8EBB-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example changes width and color of the current column. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 3
   With SGGrid1.Columns.Current
      .Width = .Width * 1.3
      .Style.BackColor = vbBlue
   End With
End Sub

Back to topic

Referenced By

Columns


SGColumns Properties

Count | Returns the number of SGColumn objects in the collection
Current | Returns the current column as an SGColumn object.
First | Returns first non-heading column an SGColumn object.
Grid | Returns parent SGGrid object.
Item | Returns specified grid column object
Last | Returns last column an SGColumn object.


Current Property (SGColumns Collection)

Current Property (SGColumns Collection)
Returns the current column as an SGColumn object.

Read-only at run time. Not available at design time.

Syntax

object.Current As IsgColumn

The object placeholder represents an object expression that evaluates to the SGColumns object.

Remarks


First Property (SGColumns Collection)

First Property (SGColumns Collection)
Returns first non-heading column an SGColumn object.

Read-only at run time. Not available at design time.

Syntax

object.First As IsgColumn

The object placeholder represents an object expression that evaluates to the SGColumns object.

Remarks

The First property returns both hidden and visible columns.

Show Example
Copy Code [image] Show Me

The following example demonstrates the First and the Last properties of the Columns collection. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .DataColCount = 5
   End With

   With SGGrid1.Columns
      .First.Caption = "First"
      .Last.Caption = "Last"
   End With
End Sub

Back to topic


Last Property (SGColumns Collection)

Last Property (SGColumns Collection)
Returns last column an SGColumn object.

Read-only at run time. Not available at design time.

Syntax

object.Last As IsgColumn

The object placeholder represents an object expression that evaluates to the SGColumns object.

Show Example
Copy Code [image] Show Me

The following example demonstrates the First and the Last properties of the Columns collection. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .DataColCount = 5
   End With

   With SGGrid1.Columns
      .First.Caption = "First"
      .Last.Caption = "Last"
   End With
End Sub

Back to topic


SGColumns Methods

Add | Adds new column object to the collection and returns a reference to the newly created object.
At | Returns a reference to the column at specified position.
GetDefinition | Returns XML representation of the Columns collection.
InsertAt | Inserts the new column object at specified position and returns a reference to the newly created object.
RemoveAll | Removes all columns from the collection.
RemoveAt | Removes column at specified position.
Remove | Removes specified column from the collection.
SetDefinition | Initializes Columns collection with XML string.


Add Method (SGColumns Collection)

Add Method (SGColumns Collection)
Adds new column object to the collection and returns a reference to the newly created object.
Syntax

object.Add([ColumnKey = ""] As String)

Return Value A SGColumn object.
Arguments
object | An object expression that evaluates to the SGColumns object.
ColumnKey | A String expression that represents the Key of the column.

Remarks

If you omit the ColumnKey parameter, the grid will automatically generate column's key. Additionally, if grid is not in an sgBound data mode, column's DBField and DBIndex properties are automatically initialized.

When a new column object is added to the collection, a reference to the newly created object is returned. You can use that reference to initialize column:

   Set col = SGGrid1.Columns.Add("Company")

   col.Caption = "Company"
   col.DBField = "Company"
   col.Frozen = True
    ...
    ...
Show Example
Copy Code [image] Show Me

The following example creates new columns for each data field except "Id" and "Code".

Private Sub AddColumns(rs As Recordset)
   Dim fld As Field
   Dim SGCol As SGColumn

   SGGrid1.Columns.RemoveAll

   For Each fld In rs.Fields
      If fld.Name <> "Id" And fld.Name <> "Code" Then
         Set SGCol = SGGrid1.Columns.Add(fld.Name)
         SGCol.DBField = fld.Name
         SGCol.Caption = fld.Name
         SGCol.Style.Format = fld.DataFormat
      End If
   Next

End Sub

Back to topic


At Method (SGColumns Collection)

At Method (SGColumns Collection)
Returns a reference to the column at specified position.
Syntax

object.At(Position As Long)

Return Value A SGColumn object.
Arguments
object | An object expression that evaluates to the SGColumns object.
Position | A Long that identifies the column Position.

Remarks

The At method returns an SGColumn object representing column at the specified position.

Show Example
Copy Code [image] Show Me

The following example swaps odd and even columns onto the grid. To try the example, place a SGGrid and CommandButton on a form. Paste the code into the Declarations section, press F5, enter some data into the grid and click button.

Private Sub Command1_Click()
   Dim i As Integer

   For i = 2 To SGGrid1.Columns.Count Step 2
      SGGrid1.Columns.At(i).Position = i - 1
   Next
End Sub

Back to topic

See Also

SGColumns


InsertAt Method (SGColumns Collection)

InsertAt Method (SGColumns Collection)
Inserts the new column object at specified position and returns a reference to the newly created object.
Syntax

object.InsertAt(Position As Long, [ColumnKey = ""] As String)

Return Value A SGColumn object.
Arguments
object | An object expression that evaluates to the SGColumns object.
Position | A Long that identifies the column Position.
ColumnKey | A String expression that represents the Key of the column.

Remarks

Show Example
Copy Code [image] Show Me

The following example inserts a new column at the first position.

Private Sub SGGrid1_OnInit()
   Dim iHeadCols As Integer

   iHeadCols = SGGrid1.HeadingColCount

   SGGrid1.Columns.InsertAt iHeadCols, ""
   SGGrid1.Columns.At(iHeadCols).Caption = "The New Column"
End Sub

Back to topic


Remove Method (SGColumns Collection)

Remove Method (SGColumns Collection)
Removes specified column from the collection.
Syntax

object.Remove(Index As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGColumns object.
Index | An integer or string that uniquely identifies the object within the collection. Use an integer to specify the value of the Index property; use a string to specify the value of the Key property.

Remarks

Use this method to remove a data column. To remove a heading column, set the control's HeadingColCount property to zero (0).

Show Example
Copy Code [image] Show Me

The following example removes all columns from the grid except the first column. To try the example, place a SGGrid and CommandButton on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim i As Integer

   SGGrid1.RedrawEnabled = False

   For i = 2 To SGGrid1.Columns.Count
      SGGrid1.Columns.Remove 2
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


RemoveAll Method (SGColumns Collection)

RemoveAll Method (SGColumns Collection)
Removes all columns from the collection.
Syntax

object.RemoveAll([RemoveHeading = -1] As Boolean)

Return Value None
Arguments
object | An object expression that evaluates to the SGColumns object.
RemoveHeading | Optional. A Boolean expression specifying whether the heading column will be also removed. Default value is -1.

Remarks

You can set control's DataColCount property to zero to remove all columns.
The following lines have same effect:

SGGrid1.Columns.RemoveAll False

- or -

SGGrid1.DataColCount = 0

Note: even if you remove all columns, the row count remain the same.

Show Example
Copy Code [image] Show Me

The following example removes all columns and adds ten new columns. Note that the number of rows remains the same. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.DataRowCount = 3

   SGGrid1.DefaultColWidth = 300
   SGGrid1.Columns.RemoveAll False

   SGGrid1.DataColCount = 10
End Sub

Back to topic


RemoveAt Method (SGColumns Collection)

RemoveAt Method (SGColumns Collection)
Removes column at specified position.
Syntax

object.RemoveAt(Position As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGColumns object.
Position | A Long that identifies the column Position.

Remarks

Show Example
Copy Code [image] Show Me

The following example removes all columns from the grid except the column at the first position. To try the example, place a SGGrid and CommandButton on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim i As Integer

   SGGrid1.RedrawEnabled = False

   For i = 2 To SGGrid1.Columns.Count
      SGGrid1.Columns.RemoveAt 2
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


SGCondition Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGCondition Object

Name: | SGCondition
Description: | SGCondition object represents condition used by other SGGrid objects.
GUID: | {86F749D3-360F-11D3-B736-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example uses Between operator for row filtering. When you click on the button, it increases the Condition members Value1 and Value2 by 100 and applies new filter. To try the example, place SGGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim cnd As SGCondition
   Dim sColKey As String

   sColKey = SGGrid1.Columns(1).Key

   With SGGrid1.RowFilters
      'clear last filter action
      .ClearMarkers .FilterAction
      'create filter object on the
      'first call
      If .Count = 0 Then _
         Call .Add("Filter", sColKey, sgOpBetween, -100, 0)
   End With

   Set cnd = SGGrid1.RowFilters("Filter").Condition
   'increase range in the filter criteria
   If cnd.Value2 = 1000 Then
      cnd.Value1 = -100
      cnd.Value2 = 0
   End If

   cnd.Set sgOpBetween, cnd.Value1 + 100, cnd.Value2 + 100
   'apply filter action
   SGGrid1.RowFilters.Apply sgFilterActionSelect

   Set cnd = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   With SGGrid1
      'create rows and cols
      .DataColCount = 1
      .DataRowCount = 50
      'hide GroupByBox
      .GroupByBoxVisible = False
      'fill grid's array with random data
      For i = 0 To .DataRowCount - 1
         .Array.Value(i, 0) = CLng(Rnd * 1000)
      Next
      'customize the FilteredRow style
      .Styles("FilteredRow").BackColor = vbBlack
      .Styles("FilteredRow").ForeColor = vbGreen
   End With

   Command1_Click
End Sub

Back to topic

Referenced By


SGCondition Properties

CaseSensitive | Returns or sets a value indicating whether matching is case-sensitive.
Grid | Returns parent SGGrid object.
Operator | Returns or sets operator used in a comparation.
Value1 | Returns or sets the first right-side value used in a comparation.
Value2 | Returns or sets the second right-side value used in a comparation.


CaseSensitive Property (SGCondition Object)

CaseSensitive Property (SGCondition Object)
Returns or sets a value indicating whether matching is case-sensitive.

Read/Write at run time. Not available at design time.

Syntax

object.CaseSensitive As Boolean

The object placeholder represents an object expression that evaluates to the SGCondition object.

Remarks

This property has effect only if the Value1 property contains string.

Show Example
Copy Code [image] Show Me

The following example applies "Tip" style to cells with the value set to "AA". To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim cnd As SGCondition

   SGGrid1.DataColCount = 1
   SGGrid1.DataRowCount = 5

   SGGrid1.CellStyleConditions.Add "Tip", _
      sgConditionCellValue, sgOpEqual, "AA"
   Set cnd = SGGrid1.CellStyleConditions(1).Condition

   cnd.CaseSensitive = True
   Set cnd = Nothing

   With SGGrid1.Array
      .Value(0, 0) = "aa"
      .Value(1, 0) = "AA"
      .Value(2, 0) = "AAaa"
   End With

End Sub

Back to topic


Operator Property (SGCondition Object)

Operator Property (SGCondition Object)
Returns or sets operator used in a comparation.

Read/Write at run time. Not available at design time.

Syntax

object.Operator As sgOperator

The object placeholder represents an object expression that evaluates to the SGCondition object.

Settings

The Operator settings are:

Name | Value | Description
sgOpFalse | 0 | Always fail.
sgOpTrue | 1 | Always succeed.
sgOpLessThan | 2 | Succeeds if the left-side value is smaller then the right-side value.
sgOpLessThanOrEqual | 3 | Succeeds if the left-side value is smaller than or equal to the right-side value.
sgOpGreaterThan | 4 | Succeeds if the left-side value is greater then the right-side value.
sgOpGreaterThanOrEqual | 5 | Succeeds if the left-side value is greater then or equal to the right-side value.
sgOpEqual | 6 | Succeeds if the left-side value is equal to the right-side value.
sgOpBetween | 7 | Succeeds if the left-side value is both greater then the first right-side value and smaller or equal to the second right-side value.
sgOpContains | 8 | Succeeds if left-side value is contained in the right-side value. Applies only to string and integral (byte, short, long, int64) types.
sgOpRegEx | 9 | Succeeds if regular expression is matched. Applies only to string values.
sgOpCallback | 10 | Uses IsgConditionTest interface to test a value.
sgOpNot | 16384 | Negates operator. Can be used only in combination with some other operator.

Remarks

Show Example
Copy Code [image] Show Me

The following example uses Between operator for row filtering. When you click on the button, it increases the Condition members Value1 and Value2 by 100 and applies new filter. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim cnd As SGCondition
   Dim sColKey As String

   sColKey = SGGrid1.Columns(1).Key

   With SGGrid1.RowFilters
      'clear last filter action
      .ClearMarkers .FilterAction
      'create filter object on the
      'first call
      If .Count = 0 Then _
         Call .Add("Filter", sColKey, sgOpBetween, -100, 0)
   End With

   Set cnd = SGGrid1.RowFilters("Filter").Condition
   'increase range in the filter criteria
   If cnd.Value2 = 1000 Then
      cnd.Value1 = -100
      cnd.Value2 = 0
   End If

   cnd.Set sgOpBetween, cnd.Value1 + 100, cnd.Value2 + 100
   'apply filter action
   SGGrid1.RowFilters.Apply sgFilterActionSelect

   Set cnd = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   With SGGrid1
      'create rows and cols
      .DataColCount = 1
      .DataRowCount = 50
      'hide GroupByBox
      .GroupByBoxVisible = False
      'fill grid's array with random data
      For i = 0 To .DataRowCount - 1
         .Array.Value(i, 0) = CLng(Rnd * 1000)
      Next
      'customize the FilteredRow style
      .Styles("FilteredRow").BackColor = vbBlack
      .Styles("FilteredRow").ForeColor = vbGreen
   End With

   Command1_Click
End Sub

Back to topic


Value1 Property (SGCondition Object)

Value1 Property (SGCondition Object)
Returns or sets the first right-side value used in a comparation.

Read/Write at run time. Not available at design time.

Syntax

object.Value1 As Variant

The object placeholder represents an object expression that evaluates to the SGCondition object.

Remarks

Show Example
Copy Code [image] Show Me

The following example uses Between operator for row filtering. When you click on the button, it increases the Condition members Value1 and Value2 by 100 and applies new filter. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim cnd As SGCondition
   Dim sColKey As String

   sColKey = SGGrid1.Columns(1).Key

   With SGGrid1.RowFilters
      'clear last filter action
      .ClearMarkers .FilterAction
      'create filter object on the
      'first call
      If .Count = 0 Then _
         Call .Add("Filter", sColKey, sgOpBetween, -100, 0)
   End With

   Set cnd = SGGrid1.RowFilters("Filter").Condition
   'increase range in the filter criteria
   If cnd.Value2 = 1000 Then
      cnd.Value1 = -100
      cnd.Value2 = 0
   End If

   cnd.Set sgOpBetween, cnd.Value1 + 100, cnd.Value2 + 100
   'apply filter action
   SGGrid1.RowFilters.Apply sgFilterActionSelect

   Set cnd = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   With SGGrid1
      'create rows and cols
      .DataColCount = 1
      .DataRowCount = 50
      'hide GroupByBox
      .GroupByBoxVisible = False
      'fill grid's array with random data
      For i = 0 To .DataRowCount - 1
         .Array.Value(i, 0) = CLng(Rnd * 1000)
      Next
      'customize the FilteredRow style
      .Styles("FilteredRow").BackColor = vbBlack
      .Styles("FilteredRow").ForeColor = vbGreen
   End With

   Command1_Click
End Sub

Back to topic


Value2 Property (SGCondition Object)

Value2 Property (SGCondition Object)
Returns or sets the second right-side value used in a comparation.

Read/Write at run time. Not available at design time.

Syntax

object.Value2 As Variant

The object placeholder represents an object expression that evaluates to the SGCondition object.

Remarks

This property has effect only if the property Operator is set to sgOpBetween.

Show Example
Copy Code [image] Show Me

The following example uses Between operator for row filtering. When you click on the button, it increases the Condition members Value1 and Value2 by 100 and applies new filter. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim cnd As SGCondition
   Dim sColKey As String

   sColKey = SGGrid1.Columns(1).Key

   With SGGrid1.RowFilters
      'clear last filter action
      .ClearMarkers .FilterAction
      'create filter object on the
      'first call
      If .Count = 0 Then _
         Call .Add("Filter", sColKey, sgOpBetween, -100, 0)
   End With

   Set cnd = SGGrid1.RowFilters("Filter").Condition
   'increase range in the filter criteria
   If cnd.Value2 = 1000 Then
      cnd.Value1 = -100
      cnd.Value2 = 0
   End If

   cnd.Set sgOpBetween, cnd.Value1 + 100, cnd.Value2 + 100
   'apply filter action
   SGGrid1.RowFilters.Apply sgFilterActionSelect

   Set cnd = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   With SGGrid1
      'create rows and cols
      .DataColCount = 1
      .DataRowCount = 50
      'hide GroupByBox
      .GroupByBoxVisible = False
      'fill grid's array with random data
      For i = 0 To .DataRowCount - 1
         .Array.Value(i, 0) = CLng(Rnd * 1000)
      Next
      'customize the FilteredRow style
      .Styles("FilteredRow").BackColor = vbBlack
      .Styles("FilteredRow").ForeColor = vbGreen
   End With

   Command1_Click
End Sub

Back to topic


SGCondition Methods

GetDefinition | Returns XML representation of the Condition object.
SetDefinition | Initializes Condition object with XML string.
Set | Sets condition parameters.


Set Method (SGCondition Object)

Set Method (SGCondition Object)
Sets condition parameters.
Syntax

object.Set(Op As sgOperator, Val1 As Variant, [Val2] As Variant, [CaseSensitive = -1] As Boolean)

Return Value None
Arguments
object | An object expression that evaluates to the SGCondition object.
Op | An sgOperator expression that sets the operator to be used when evaluating condition. Check out pattern syntax if you use regular expresion (sgOpRegEx). The possible values are listed in Settings.
Val1 | A Variant expression that contains the first right-side value to be used when evaluating condition criteria.
Val2 | Optional. A Variant expression that contains the second right-side value to be used for a condition criteria. This argument is used only if the operator is set to sgOpBetween.
CaseSensitive | Optional. A Boolean expression that indicating the kind of comparison to use when evaluating condition. Default value is -1.

Settings

The settings for Op are:

Name | Value | Description
sgOpFalse | 0 | Always fail.
sgOpTrue | 1 | Always succeed.
sgOpLessThan | 2 | Succeeds if the left-side value is smaller then the right-side value.
sgOpLessThanOrEqual | 3 | Succeeds if the left-side value is smaller than or equal to the right-side value.
sgOpGreaterThan | 4 | Succeeds if the left-side value is greater then the right-side value.
sgOpGreaterThanOrEqual | 5 | Succeeds if the left-side value is greater then or equal to the right-side value.
sgOpEqual | 6 | Succeeds if the left-side value is equal to the right-side value.
sgOpBetween | 7 | Succeeds if the left-side value is both greater then the first right-side value and smaller or equal to the second right-side value.
sgOpContains | 8 | Succeeds if left-side value is contained in the right-side value. Applies only to string and integral (byte, short, long, int64) types.
sgOpRegEx | 9 | Succeeds if regular expression is matched. Applies only to string values.
sgOpCallback | 10 | Uses IsgConditionTest interface to test a value.
sgOpNot | 16384 | Negates operator. Can be used only in combination with some other operator.

Remarks

Use the Set method to change condition parameters.

Note: value parameters should be of the same type to achieve max speed. When val1 and val2 params cannot be converted to the type of the valueSource value, style is not applied.

Show Example
Copy Code [image] Show Me

The following example uses Between operator for row filtering. When you click on the button, it increases the Condition members Value1 and Value2 by 100 and applies new filter. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim cnd As SGCondition
   Dim sColKey As String

   sColKey = SGGrid1.Columns(1).Key

   With SGGrid1.RowFilters
      'clear last filter action
      .ClearMarkers .FilterAction
      'create filter object on the
      'first call
      If .Count = 0 Then _
         Call .Add("Filter", sColKey, sgOpBetween, -100, 0)
   End With

   Set cnd = SGGrid1.RowFilters("Filter").Condition
   'increase range in the filter criteria
   If cnd.Value2 = 1000 Then
      cnd.Value1 = -100
      cnd.Value2 = 0
   End If

   cnd.Set sgOpBetween, cnd.Value1 + 100, cnd.Value2 + 100
   'apply filter action
   SGGrid1.RowFilters.Apply sgFilterActionSelect

   Set cnd = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   With SGGrid1
      'create rows and cols
      .DataColCount = 1
      .DataRowCount = 50
      'hide GroupByBox
      .GroupByBoxVisible = False
      'fill grid's array with random data
      For i = 0 To .DataRowCount - 1
         .Array.Value(i, 0) = CLng(Rnd * 1000)
      Next
      'customize the FilteredRow style
      .Styles("FilteredRow").BackColor = vbBlack
      .Styles("FilteredRow").ForeColor = vbGreen
   End With

   Command1_Click
End Sub

Back to topic

See Also

SGCondition


SGControl Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGControl Object

Name: | SGControl
Description: | SGControl is object that represents cell editor.
GUID: | {1DF77B31-C735-11D2-8F0D-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic

Referenced By

SGColumn.Control


SGControl Properties

AutoOpen | Determines whether control's popup window is opened when the user starts typing.
ButtonAlignment | Controls button's horizontal position.
ButtonPicture | Returns or sets control's button picture.
DroppedDown | Returns true if cell editor's popup window is open.
Grid | Returns parent SGGrid object.
Height | Returns or sets height of the control's popup window.
ItemHeight | Returns or sets control's item height type.
PopupAlignment | Controls horizontal position of the cell editor popup window.
PopupRows | Returns or sets number of rows that are visible in the combo's drop-dow window.
PopupStyle | Returns the SGStyle object for the control's popup window.
ShowButton | Returns or sets flag indicating when is the action button shown.
SortOrder | Returns or sets control's sorting order.
Type | Determines what type of control is used to edit the cell.
Width | Returns or sets width of the control's popup window.
Window | Returns cell editor's window handle (HWND).


AutoOpen Property (SGControl Object)

AutoOpen Property (SGControl Object)
Determines whether control's popup window is opened when the user starts typing.

Read/Write at run time and design time.

Syntax

object.AutoOpen As Boolean

The object placeholder represents an object expression that evaluates to the SGControl object.

Remarks

This property determines whether a built-in combo box is displayed in response to keyboard input. If it's True, the combo box automatically opens when the user types a character into a cell. Otherwise, the user can open the combo box by clicking the in-cell button or by pressing Alt + Down Arrow.

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.

Show Example
Copy Code [image] Show Me

The following example sets the AutoOpen property to true for all columns with the ValueItems count between 1 and 5.

Private Sub Command1_Click()
   Dim col As SGColumn

   For Each col In SGGrid1.Columns
      If col.ValueItems.Count > 0 And col.ValueItems < 5 Then
         col.Control.AutoOpen = True
      End If
   Next

End Sub

Back to topic


ButtonAlignment Property (SGControl Object)

ButtonAlignment Property (SGControl Object)
Controls button's horizontal position.

Read/Write at run time and design time.

Syntax

object.ButtonAlignment As sgButtonAlignment

The object placeholder represents an object expression that evaluates to the SGControl object.

Settings

The ButtonAlignment settings are:

Name | Value | Description
sgButtonLeft | 0 | Button is positioned on the left side of the cell.
sgButtonRight | 1 | Button is positioned on the right side of cell.

Remarks

This property has not effect if the control's ShowButton property is set to sgHideButton.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


ButtonPicture Property (SGControl Object)

ButtonPicture Property (SGControl Object)
Returns or sets control's button picture.

Read/Write at run time and design time.

Syntax

object.ButtonPicture As Variant

The object placeholder represents an object expression that evaluates to the SGControl object.

Remarks

The ButtonPicture property sets or returns the picture used to draw the in-cell button in the specified column. You can picture object, built-in picture or picture from an image list.

This property has not effect if the control's ShowButton property is set to sgHideButton.

Show Example
Copy Code [image] Show Me

The following code uses built-in picture as button picture.

Private Sub Command1_Click()

   SGGrid1.Columns(1).Control.ButtonPicture = sgbipFirst + 1
   SGGrid1.Redraw
End Sub

Back to topic


DroppedDown Property (SGControl Object)

DroppedDown Property (SGControl Object)
Returns true if cell editor's popup window is open.

Read-only at run time. Not available at design time.

Syntax

object.DroppedDown As Boolean

The object placeholder represents an object expression that evaluates to the SGControl object.

Remarks

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


Height Property (SGControl Object)

Height Property (SGControl Object)
Returns or sets height of the control's popup window.

Read/Write at run time. Not available at design time.

Syntax

object.Height As OLE_YSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGControl object.

Remarks

Return or set the height of a control pop up. This property is similar as the PopupRows property.

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


ItemHeight Property (SGControl Object)

ItemHeight Property (SGControl Object)
Returns or sets control's item height type.

Read/Write at run time. Not available at design time.

Syntax

object.ItemHeight As sgItemHeight

The object placeholder represents an object expression that evaluates to the SGControl object.

Settings

The ItemHeight settings are:

Name | Value | Description
sgItemHeightFixed | -1 | All items in the dropdown list are of same height.
sgItemHeightVariable | -2 | Each item in the dropdown list can have different height.

Remarks

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.


PopupAlignment Property (SGControl Object)

PopupAlignment Property (SGControl Object)
Controls horizontal position of the cell editor popup window.

Read/Write at run time and design time.

Syntax

object.PopupAlignment As sgPopupAlignment

The object placeholder represents an object expression that evaluates to the SGControl object.

Settings

The PopupAlignment settings are:

Name | Value | Description
sgPopupLeft | 0 | Popup window is aligned to the left cell border.
sgPopupRight | 1 | Popup window is aligned to the right cell border.

Remarks

The PopupAlignment determines on which side the cell editor's popup occurs.

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


PopupRows Property (SGControl Object)

PopupRows Property (SGControl Object)
Returns or sets number of rows that are visible in the combo's drop-down window.

Read/Write at run time and design time.

Syntax

object.PopupRows As Long

The object placeholder represents an object expression that evaluates to the SGControl object.

Remarks

The PopUpRows determines how many items would be displayed in the cell editor's popup. This property is similar as the Height property. If you use this property after Height, you will neutralize the Height property.

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.

Show Example
Copy Code [image] Show Me

The following example checks out the value items count for each a column. If the column has more then 5 value items the PopupRows is set to 5.

Private Sub Command1_Click()
   Dim col As SGColumn

   For Each col In SGGrid1.Columns
      If col.ValueItems.Count > 5 Then
         col.Control.PopupRows = 5
      End If
   Next
End Sub

Back to topic


PopupStyle Property (SGControl Object)

PopupStyle Property (SGControl Object)
Returns the SGStyle object for the control's popup window.

Read-only at run time. Not available at design time.

Syntax

object.PopupStyle As IsgStyle

The object placeholder represents an object expression that evaluates to the SGControl object.

Remarks

By default, the control use the Normal style.

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


ShowButton Property (SGControl Object)

ShowButton Property (SGControl Object)
Returns or sets flag indicating when is the action button shown.

Read/Write at run time and design time.

Syntax

object.ShowButton As sgShowButton

The object placeholder represents an object expression that evaluates to the SGControl object.

Settings

The ShowButton settings are:

Name | Value | Description
sgHideButton | 0 | Do not show cell's button.
sgShowButtonFocused | 1 | Show cell's button only when cell is focused.
sgShowButtonAlways | 2 | Always show cell's button.

Remarks

The ShowButton determines whether a button is displayed within the current cell, always or never.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


SortOrder Property (SGControl Object)

SortOrder Property (SGControl Object)
Returns or sets control's sorting order.

Read/Write at run time and design time.

Syntax

object.SortOrder As sgSortOrder

The object placeholder represents an object expression that evaluates to the SGControl object.

Settings

The SortOrder settings are:

Name | Value | Description
sgNoSorting | 0 | Do not sort.
sgSortAscending | 1 | Sort in ascending order.
sgSortDescending | 2 | Sort in descending order.

Remarks

The SortOrder determines how items will be sort into the cell editor's popup.

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


Type Property (SGControl Object)

Type Property (SGControl Object)
Determines what type of control is used to edit the cell.

Read/Write at run time and design time.

Syntax

object.Type As sgCellEditorType

The object placeholder represents an object expression that evaluates to the SGControl object.

Settings

The Type settings are:

Name | Value | Description
sgCellGeneral | 0 | The cell editor type is determined by the underlying data type.
sgCellTextBox | 1 | The cell editor is a text box.
sgCellCheckBox | 2 | The cell editor is a checkbox.
sgCellDropDown | 3 | The cell editor is a dropdown combo box.
sgCellDropList | 4 | The cell editor is a droplist combo box.

Remarks

Sets or returns the SGControl type of the column object. By default, the grid columns have control type set to sgCellGeneral.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


Width Property (SGControl Object)

Width Property (SGControl Object)
Returns or sets width of the control's popup window.

Read/Write at run time. Not available at design time.

Syntax

object.Width As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGControl object.

Remarks

Return or set the width of the cell editor's popup. Setting width to 0 pop up is align with a cell.

This property has effect only if the column control Type is set to sgCellDropList or sgCellDropDown.

Show Example
Copy Code [image] Show Me

The following example shows how to create combo box in the first column. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim ctl As SGControl
   Dim vis As SGValueItems
   Dim i As Integer

   Set ctl = SGGrid1.Columns(1).Control
   'create combo box control
   ctl.Type = sgCellDropDown
   'set size of combo list
   ctl.Height = 2200
   ctl.Width = 2200
   ctl.PopupAlignment = sgPopupLeft
   ctl.PopupStyle.BackColor = QBColor(14)
   ctl.PopupStyle.Font.Size = 15
   ctl.PopupStyle.Font.Name = "Arial"
   ctl.SortOrder = sgNoSorting
   'set value items
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 1 To 50
      vis.Add i, "Item " & i, Me.Icon
   Next

   Set vis = Nothing
   Set ctl = Nothing

End Sub

Back to topic


Window Property (SGControl Object)

Window Property (SGControl Object)
Returns cell editor's window handle (HWND).

Read-only at run time. Not available at design time.

Syntax

object.Window As Long

The object placeholder represents an object expression that evaluates to the SGControl object.

Remarks

This property returns a handle to the column's control window. Typically, this property is used with Windows API calls.

Note: Because the value of this property can change while a program is running, never store the Window value in a variable.

Show Example
Copy Code [image] Show Me

The following example draws ten "X" into the current cell when the user press the Back Space key. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Type RECT
   Left As Long
   Top As Long
   right As Long
   bottom As Long
End Type

Private Declare Function DrawText Lib "user32" Alias "DrawTextA" _
   (ByVal hdc As Long, ByVal lpStr As String, _
   ByVal nCount As Long, lpRect As RECT, _
   ByVal wFormat As Long) As Long

Private Declare Function GetDC Lib "user32" _
   (ByVal hwnd As Long) As Long

Private Sub SGGrid1_KeyPressEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   KeyASCII As Integer)
   Dim dc As Long
   Dim rc As RECT

   If KeyASCII <> vbKeyBack Then Exit Sub

   dc = GetDC(SGGrid1.Columns(ColIndex).Control.Window)

   rc.Left = 0: rc.Top = 0
   rc.right = SGGrid1.CurrentCell.Width / Screen.TwipsPerPixelX
   rc.bottom = SGGrid1.CurrentCell.Height / Screen.TwipsPerPixelY

   DrawText dc, String(10, "X"), 10, rc, 0
End Sub

Back to topic


SGDataObject Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGDataObject Object

Name: | SGDataObject
Description: | SGDataObject object represents formats and data used by OLE drag/drop operations.
GUID: | {5A77B361-9785-11D3-90C2-008048E27A77}

Remarks

The SGDataObject object is a container for data being transferred from a component source to a component target. The data is stored in the format defined by the method using the SGDataObject object.

Show Example
Copy Code [image] Show Me

The following example shows how to use custom data in the OLE drag/drop operation.

Private Sub SGGrid1_OLEDragDrop _
   (ByVal Data As IsgDataObject, Effect As Long, _
   ByVal Button As Integer, ByVal Shift As Integer, _
   ByVal x As Single, ByVal y As Single)
   Dim sData As String
   Dim iPos As Integer
   Dim sRow As String

   On Error Resume Next

   If Not Data.GetFormat(vbCFText) Then Exit Sub
   sData = Data.GetData(vbCFText)
   If Len(sData) = 0 Then Exit Sub

   iPos = InStr(sData, vbCrLf)

   Do Until iPos = 0
      sRow = Left$(sData, iPos - 1)
      sData = Right$(sData, Len(sData) - iPos - 1)

      SGGrid1.Rows.Add sgFormatCharSeparatedValue, sRow, vbTab
      iPos = InStr(1, sData, vbCrLf)
   Loop

   SGGrid1.Rows.Add sgFormatCharSeparatedValue, sData, vbTab
End Sub

Back to topic

Referenced By


SGDataObject Properties

Files Contains a collection of filenames used by a SGDataObject object.


Files Property (SGDataObject Object)

Files Property (SGDataObject Object)
Contains a collection of filenames used by a SGDataObject object.

Read/Write at run time. Not available at design time.

Syntax

object.Files As Object

The object placeholder represents an object expression that evaluates to the SGDataObject object.

Remarks

The Files collection is filled with filenames only when the DataObject object contains data of type vbCFFiles. (The DataObject object can contain several different types of data.) You can iterate through the collection to retrieve the list of file names.

Note: This property has yet to be implemented.


SGDataObject Methods

Clear | Clears all data and formats in the SGDataObject
GetData | Retrieves data of a specified format from the SGDataObject
GetFormat | Determines if a specified clipboard format is supported by the SGDataObject
SetData | Adds a supported format and possibly its data to the SGDataObject


Clear Method (SGDataObject Object)

Clear Method (SGDataObject Object)
Clears all data and formats in the SGDataObject
Syntax | object.Clear
Return Value | None
Arguments | None

Remarks

This method is available only for component drag sources. If Clear is called from a component drop target, an error is generated.

Show Example
Copy Code [image] Show Me

The following example shows how to use the OLESetData event to control data for drag-drop.

Private Sub SGGrid1_OLESetData( _
   ByVal Data As IsgDataObject, _
   dataFormat As Integer)
   Dim rng As SGRange, i As Integer
   Dim sData As String, sgCol As SGColumn

   Data.Clear

   For Each rng In SGGrid1.Selection.Ranges
      For i = rng.TopRow To rng.BottomRow
         sData = sData & SGGrid1.Rows.At(i).GetData _
            (sgFormatCharSeparatedValue, vbTab) & vbCrLf
      Next
   Next

   Set rng = Nothing

   If Len(sData) = 0 Then Exit Sub

   sData = Left$(sData, Len(sData) - 2)
   Data.SetData sData, vbCFText

End Sub

Back to topic


GetData Method (SGDataObject Object)

GetData Method (SGDataObject Object)
Retrieves data of a specified format from the SGDataObject
Syntax

object.GetData(Format As Integer)

Return Value A Variant containing data from a SGDataObject.
Arguments
object | An object expression that evaluates to the SGDataObject object.
Format | Optional. A Variant that specifies the format of the data being passed.

Remarks

The GetData returns data from a SGDataObject object in the form of a variant.

Show Example
Copy Code [image] Show Me

The following example shows how to use custom data in the OLE drag/drop operation.

Private Sub SGGrid1_OLEDragDrop _
   (ByVal Data As IsgDataObject, Effect As Long, _
   ByVal Button As Integer, ByVal Shift As Integer, _
   ByVal x As Single, ByVal y As Single)
   Dim sData As String
   Dim iPos As Integer
   Dim sRow As String

   On Error Resume Next

   If Not Data.GetFormat(vbCFText) Then Exit Sub
   sData = Data.GetData(vbCFText)
   If Len(sData) = 0 Then Exit Sub

   iPos = InStr(sData, vbCrLf)

   Do Until iPos = 0
      sRow = Left$(sData, iPos - 1)
      sData = Right$(sData, Len(sData) - iPos - 1)

      SGGrid1.Rows.Add sgFormatCharSeparatedValue, sRow, vbTab
      iPos = InStr(1, sData, vbCrLf)
   Loop

   SGGrid1.Rows.Add sgFormatCharSeparatedValue, sData, vbTab
End Sub

Back to topic


GetFormat Method (SGDataObject Object)

GetFormat Method (SGDataObject Object)
Determines if a specified clipboard format is supported by the SGDataObject
Syntax

object.GetFormat(Format As Integer)

Return Value An Boolean value indicating whether an item in the SGDataObject matches a specified format.
Arguments
object | An object expression that evaluates to the SGDataObject object.
Format | Optional. A Variant that specifies the format of the data being passed.

Remarks

The GetFormat method returns True if an item in the SGDataObject object matches the specified format. Otherwise, it returns False.

Show Example
Copy Code [image] Show Me

The following example shows how to use custom data in the OLE drag/drop operation.

Private Sub SGGrid1_OLEDragDrop _
   (ByVal Data As IsgDataObject, Effect As Long, _
   ByVal Button As Integer, ByVal Shift As Integer, _
   ByVal x As Single, ByVal y As Single)
   Dim sData As String
   Dim iPos As Integer
   Dim sRow As String

   On Error Resume Next

   If Not Data.GetFormat(vbCFText) Then Exit Sub
   sData = Data.GetData(vbCFText)
   If Len(sData) = 0 Then Exit Sub

   iPos = InStr(sData, vbCrLf)

   Do Until iPos = 0
      sRow = Left$(sData, iPos - 1)
      sData = Right$(sData, Len(sData) - iPos - 1)

      SGGrid1.Rows.Add sgFormatCharSeparatedValue, sRow, vbTab
      iPos = InStr(1, sData, vbCrLf)
   Loop

   SGGrid1.Rows.Add sgFormatCharSeparatedValue, sData, vbTab
End Sub

Back to topic


SetData Method (SGDataObject Object)

SetData Method (SGDataObject Object)
Adds a supported format and possibly its data to the SGDataObject
Syntax

object.SetData([Value] As Variant, [Format] As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGDataObject object.
Value | Optional. A variant containing the data to be passed to the SGDataObject object.
Format | Optional. A Variant that specifies the format of the data being passed.

Remarks

This method allows you to set several different formats that the source component can support without having to load the data separately for each format. Multiple formats are set by calling SetData several times, each time using a different format. If you wish to start fresh, use the Clear method to clear all data and format information from the SGDataObject.

Show Example
Copy Code [image] Show Me

The following example shows how to use the OLESetData event to control data for drag-drop.

Private Sub SGGrid1_OLESetData( _
   ByVal Data As IsgDataObject, _
   dataFormat As Integer)
   Dim rng As SGRange, i As Integer
   Dim sData As String, sgCol As SGColumn

   Data.Clear

   For Each rng In SGGrid1.Selection.Ranges
      For i = rng.TopRow To rng.BottomRow
         sData = sData & SGGrid1.Rows.At(i).GetData _
            (sgFormatCharSeparatedValue, vbTab) & vbCrLf
      Next
   Next

   Set rng = Nothing

   If Len(sData) = 0 Then Exit Sub

   sData = Left$(sData, Len(sData) - 2)
   Data.SetData sData, vbCFText

End Sub

Back to topic


SGFilter Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGFilter Object

Name: | SGFilter
Description: | SGFilter object represents row filter definition.
GUID: | {C9CEE36A-4D4C-401A-A7DA-217D43957FFE}

Show Example
Copy Code [image] Show Me

The following example shows how to use the SGFilters object. Two SGFilter objects are added to the collection. The "All" button apply both filters, the "First Filter" button apply the first one and the "Second Filter" button second one. The button "Clear" remove filters action. To try the example, place SGGrid and three CommandButton controls on a form. Paste the code into the Declarations section, press F5 and click each button.

Private Sub Command1_Click()
   SGGrid1.RowFilters.ClearMarkers sgFilterActionSelect
End Sub

Private Sub Command2_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .EnableAll
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Command3_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .DisableAll
      .Item(1).Enabled = True
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Command4_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .DisableAll
      .Item(2).Enabled = True
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Form_Load()
   Command1.Caption = "Clear"
   Command2.Caption = "All"
   Command3.Caption = "First Filter"
   Command4.Caption = "Second Filter"
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.Columns.RemoveAll
   SGGrid1.DataRowCount = 20

   With SGGrid1.Columns.Add("C1")
      .DataType = sgtLong
   End With

   With SGGrid1.Columns.Add("C2")
      .DataType = sgtLong
   End With

   With SGGrid1.Styles("FilteredRow")
      .BackColor = vbYellow
      .Font.Bold = True
      .ForeColor = vbBlue
   End With

   For i = 0 To SGGrid1.Array.RowCount - 1
      SGGrid1.Array.Value(i, 0) = i * 10
      SGGrid1.Array.Value(i, 1) = i * 100
   Next

   With SGGrid1.RowFilters
      .Add "MyFilter1", "C1", sgOpBetween, 10, 100
      .Add "MyFilter2", "C2", sgOpGreaterThanOrEqual, 800
      .Apply sgFilterActionSelect
   End With
End Sub

Back to topic

Referenced By

SGFilters.Item


SGFilter Properties

Condition | Returns filter condition object.
Enabled | Enables or disables filter.
FilterColumn | Returns or sets the key of the filtered column.
Grid | Returns parent SGGrid object.
Index | Returns the index of a filter in a collection.
Name | Returns filter's name.


Condition Property (SGFilter Object)

Condition Property (SGFilter Object)
Returns filter condition object.

Read-only at run time. Not available at design time.

Syntax

object.Condition As IsgCondition

The object placeholder represents an object expression that evaluates to the SGFilter object.

Remarks

This property returns the SGCondition object.


Enabled Property (SGFilter Object)

Enabled Property (SGFilter Object)
Enables or disables filter.

Read/Write at run time. Not available at design time.

Syntax

object.Enabled As Boolean

The object placeholder represents an object expression that evaluates to the SGFilter object.

Remarks

If it set to True filter will be applied when you call Apply method of SGFilters collection.

You can use the EnableAll and the DisableAll properties to enable/disable all Filter objects in the SGFilters collection.


FilterColumn Property (SGFilter Object)

FilterColumn Property (SGFilter Object)
Returns or sets the key of the filtered column.

Read/Write at run time. Not available at design time.

Syntax

object.FilterColumn As String

The object placeholder represents an object expression that evaluates to the SGFilter object.

Remarks

If you set this property to empty string (""), the filter action will be applied on all columns.

See Also

SGFilter


Index Property (SGFilter Object)

Index Property (SGFilter Object)
Returns the index of a filter in a collection.

Read-only at run time. Not available at design time.

Syntax

object.Index As Integer

The object placeholder represents an object expression that evaluates to the SGFilter object.

Remarks

Rather use the Name property to reference an object in the SGFilters collection. When you remove object from the collection the Index will be changed.


Name Property (SGFilter Object)

Name Property (SGFilter Object)
Returns filter's name.

Read-only at run time. Not available at design time.

Syntax

object.Name As String

The object placeholder represents an object expression that evaluates to the SGFilter object.

Remarks

Use this property to reference the SGFilter object.

   SGGrid1.RowFilters(FilterName)


SGFilters Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGFilters Object

Name: | SGFilters
Description: | Collection of SGFilter objects.
GUID: | {ED32A589-3A0B-4B7C-AEC3-FD77BE997FEE}

Remarks

You can manipulate SGFilter objects by using standard collection methods. Each filter in the collection can be accessed by its Index or by its Name. If you refer item with its name, note that name is case sensitive. Use the For Each...Next statement to enumerate items in the collection.

   Dim flt As SGFilter

   For Each flt In SGGrid1.RowFilters
      Debug.Print flt.Name
   Next

For more information, see the SGFilter section.

Show Example
Copy Code [image] Show Me

The following example shows how to use the SGFilters object. Two SGFilter objects are added to the collection. The "All" button apply both filters, the "First Filter" button apply the first one and the "Second Filter" button second one. The button "Clear" remove filters action. To try the example, place SGGrid and three CommandButton controls on a form. Paste the code into the Declarations section, press F5 and click each button.

Private Sub Command1_Click()
   SGGrid1.RowFilters.ClearMarkers sgFilterActionSelect
End Sub

Private Sub Command2_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .EnableAll
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Command3_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .DisableAll
      .Item(1).Enabled = True
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Command4_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .DisableAll
      .Item(2).Enabled = True
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Form_Load()
   Command1.Caption = "Clear"
   Command2.Caption = "All"
   Command3.Caption = "First Filter"
   Command4.Caption = "Second Filter"
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.Columns.RemoveAll
   SGGrid1.DataRowCount = 20

   With SGGrid1.Columns.Add("C1")
      .DataType = sgtLong
   End With

   With SGGrid1.Columns.Add("C2")
      .DataType = sgtLong
   End With

   With SGGrid1.Styles("FilteredRow")
      .BackColor = vbYellow
      .Font.Bold = True
      .ForeColor = vbBlue
   End With

   For i = 0 To SGGrid1.Array.RowCount - 1
      SGGrid1.Array.Value(i, 0) = i * 10
      SGGrid1.Array.Value(i, 1) = i * 100
   Next

   With SGGrid1.RowFilters
      .Add "MyFilter1", "C1", sgOpBetween, 10, 100
      .Add "MyFilter2", "C2", sgOpGreaterThanOrEqual, 800
      .Apply sgFilterActionSelect
   End With
End Sub

Back to topic

Referenced By

RowFilters


SGFilters Properties

Count | Returns the number of SGFilter objects in the collection
Expression | Not yet implemented.
FilterAction | Returns current filter action as set by last call to the Apply function.
Grid | Returns parent SGGrid object.
Item | Returns specified filter object


FilterAction Property (SGFilters Collection)

FilterAction Property (SGFilters Collection)
Returns current filter action as set by last call to the Apply function.

Read-only at run time. Not available at design time.

Syntax

object.FilterAction As sgFilterAction

The object placeholder represents an object expression that evaluates to the SGFilters object.

Settings

The FilterAction settings are:

Name | Value | Description
sgFilterActionDefault | 0 | Use actions already stored in the Filters object.
sgFilterActionMarkHidden | 1 | Mark row as hidden.
sgFilterActionMarkReadOnly | 2 | Mark row as read-only.
sgFilterActionSelect | 4 | Select row.
sgFilterActionCustom | 8 | Custom action. BeeGrid does not use it.

Remarks

You can use this property in conjunction with the ClearMarkers method to clear result of the last filter.

Show Example
Copy Code [image] Show Me

The following example uses the FilterAction property to clear old filter and applies new one.

Private Sub Command2_Click()
   With SGGrid1.RowFilters
      .ClearMarkers .FilterAction
      .EnableAll
      .Apply sgFilterActionSelect
   End With
End Sub

Back to topic


SGFilters Methods

Add | Adds new filter.
Apply | Applies all enabled filters.
ClearMarkers | Clears specified markers from all filtered rows.
DisableAll | Disables all filters.
EnableAll | Enables all filters.
GetDefinition | Returns XML representation of the Filters collection.
RemoveAll | Removes all filters from the collection.
Remove | Removes specified filter from the collection.
SetDefinition | Initializes Filters collection with XML string.


Add Method (SGFilters Collection)

Add Method (SGFilters Collection)
Adds new filter.
Syntax

object.Add(FilterName As String, ColKey As String, Op As sgOperator, Val1 As Variant, [Val2] As Variant)

Return Value A SGFilter object.
Arguments
object | An object expression that evaluates to the SGFilters object.
FilterName | A unique string that can be used to retrieve the SGFilter with the Item method.
ColKey | A String expression that represents the Key of the column. If you want to filter all columns set this parameter to the empty string ("").
Op | An sgOperator expression that sets the operator to be used when evaluating condition. Check out pattern syntax if you use regular expression (sgOpRegEx). The possible values are listed in Settings.
Val1 | A Variant expression that contains the first right-side value to be used when evaluating condition criteria.
Val2 | Optional. A Variant expression that contains the second right-side value to be used for a condition criteria. This argument is used only if the operator is set to sgOpBetween.

Settings

The settings for Op are:

Name | Value | Description
sgOpFalse | 0 | Always fail.
sgOpTrue | 1 | Always succeed.
sgOpLessThan | 2 | Succeeds if the left-side value is smaller then the right-side value.
sgOpLessThanOrEqual | 3 | Succeeds if the left-side value is smaller than or equal to the right-side value.
sgOpGreaterThan | 4 | Succeeds if the left-side value is greater then the right-side value.
sgOpGreaterThanOrEqual | 5 | Succeeds if the left-side value is greater then or equal to the right-side value.
sgOpEqual | 6 | Succeeds if the left-side value is equal to the right-side value.
sgOpBetween | 7 | Succeeds if the left-side value is both greater then the first right-side value and smaller or equal to the second right-side value.
sgOpContains | 8 | Succeeds if left-side value is contained in the right-side value. Applies only to string and integral (byte, short, long, int64) types.
sgOpRegEx | 9 | Succeeds if regular expression is matched. Applies only to string values.
sgOpCallback | 10 | Uses IsgConditionTest interface to test a value.
sgOpNot | 16384 | Negates operator. Can be used only in combination with some other operator.

Remarks

By default, if there are more then one SGFilter objects to the collection, the grid will perform the AND operator between them.

Show Example
Copy Code [image] Show Me

The following example fills grid with sample data. Ads two SGFilter objects to the collection and apply filter. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.Columns.RemoveAll
   SGGrid1.DataRowCount = 20

   With SGGrid1.Columns.Add("C1")
      .DataType = sgtLong
   End With

   With SGGrid1.Columns.Add("C2")
      .DataType = sgtLong
   End With

   With SGGrid1.Styles("FilteredRow")
      .BackColor = &HDDFFFF
      .ForeColor = &H880000
      .Font.Bold = True
      .BorderColor = vbBlack
      .BorderSize = 1
      .Borders = sgCellBorderBottom
   End With

   For i = 0 To SGGrid1.Array.RowCount - 1
      SGGrid1.Array.Value(i, 0) = i * 10
      SGGrid1.Array.Value(i, 1) = i * 100
   Next

   With SGGrid1.RowFilters
      .Add "MyFilter1", "C1", sgOpBetween, 10, 100
      .Add "MyFilter2", "C2", sgOpGreaterThanOrEqual, 800
      .Apply sgFilterActionSelect
   End With
End Sub

Back to topic


Apply Method (SGFilters Collection)

Apply Method (SGFilters Collection)
Applies all enabled filters.
Syntax

object.Apply(Action As sgFilterAction, [SearchFlags = sgSearchDefault] As sgSearchFlag)

Return Value None
Arguments
object | An object expression that evaluates to the SGFilters object.
Action | A sgFilterAction expression that indicating the kind of filter action to use. The possible values are listed in Settings.
SearchFlags | Optional. An sgSearchFlag expression indicating the kind of comparison to use when evaluating cell's values. Default value is sgSearchDefault.

Settings

The settings for Action are:

Name | Value | Description
sgFilterActionDefault | 0 | Use actions already stored in the Filters object.
sgFilterActionMarkHidden | 1 | Mark row as hidden.
sgFilterActionMarkReadOnly | 2 | Mark row as read-only.
sgFilterActionSelect | 4 | Select row.
sgFilterActionCustom | 8 | Custom action. BeeGrid does not use it.
The settings for SearchFlags are:

Name | Value | Description
sgSearchDefault | 0 | Do not use any special processing when comparing values.
sgSearchText | 1 | Use formatted text when comparing values.
sgSearchCaseSensitive | 2 | Text comparasion is case sensitive.

Remarks

This method applies all enabled filter in the SGFilters collection. By default, if there are more then one SGFilter objects to the collection, the grid will perform the AND operator between them. You can use the Enabled property to enable/disable each SGFilter object.

The opposite action is the ClearMarkers.

Show Example
Copy Code [image] Show Me

The following example shows how to use the SGFilters object. Two SGFilter objects are added to the collection. The "All" button apply both filters, the "First Filter" button apply the first one and the "Second Filter" button second one. The button "Clear" remove filters action. To try the example, place BeeGrid and three CommandButton controls on a form. Paste the code into the Declarations section, press F5 and click each button.

Private Sub Command1_Click()
   SGGrid1.RowFilters.ClearMarkers sgFilterActionSelect
End Sub

Private Sub Command2_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .EnableAll
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Command3_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .DisableAll
      .Item(1).Enabled = True
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Command4_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .DisableAll
      .Item(2).Enabled = True
      .Apply sgFilterActionSelect
   End With
End Sub

Private Sub Form_Load()
   Command1.Caption = "Clear"
   Command2.Caption = "All"
   Command3.Caption = "First Filter"
   Command4.Caption = "Second Filter"
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.Columns.RemoveAll
   SGGrid1.DataRowCount = 20

   With SGGrid1.Columns.Add("C1")
      .DataType = sgtLong
   End With

   With SGGrid1.Columns.Add("C2")
      .DataType = sgtLong
   End With

   With SGGrid1.Styles("FilteredRow")
      .BackColor = vbYellow
      .Font.Bold = True
      .ForeColor = vbBlue
   End With

   For i = 0 To SGGrid1.Array.RowCount - 1
      SGGrid1.Array.Value(i, 0) = i * 10
      SGGrid1.Array.Value(i, 1) = i * 100
   Next

   With SGGrid1.RowFilters
      .Add "MyFilter1", "C1", sgOpBetween, 10, 100
      .Add "MyFilter2", "C2", sgOpGreaterThanOrEqual, 800
      .Apply sgFilterActionSelect
   End With
End Sub

Back to topic


ClearMarkers Method (SGFilters Collection)

ClearMarkers Method (SGFilters Collection)
Clears specified markers from all filtered rows.
Syntax

object.ClearMarkers(Action As sgFilterAction)

Return Value None
Arguments
object | An object expression that evaluates to the SGFilters object.
Action | A sgFilterAction expression that indicating the kind of filter action to use. The possible values are listed in Settings.

Settings

The settings for Action are:

Name | Value | Description
sgFilterActionDefault | 0 | Use actions already stored in the Filters object.
sgFilterActionMarkHidden | 1 | Mark row as hidden.
sgFilterActionMarkReadOnly | 2 | Mark row as read-only.
sgFilterActionSelect | 4 | Select row.
sgFilterActionCustom | 8 | Custom action. BeeGrid does not use it.

Remarks

Use the ClearMarkers method before apply new filter.

You can use the FilterAction property to clear last applied filter action

   With SGGrid1.RowFilters
      .ClearMarkers .FilterAction
   End With

Show Example
Copy Code [image] Show Me

The following example clear all filtered rows, disables all items in the Filters collection, enables the first one and applies the filter.

Private Sub Command3_Click()
   With SGGrid1.RowFilters
      .ClearMarkers .FilterAction
      .DisableAll
      .Item(1).Enabled = True
      .Apply sgFilterActionSelect
   End With
End Sub

Back to topic


DisableAll Method (SGFilters Collection)

DisableAll Method (SGFilters Collection)
Disables all filters.
Syntax | object.DisableAll
Return Value | None
Arguments | None

Remarks

This method disables all SGFilter objects in the SGFilters collection. You can set the filter's Enabled property to False to disable each SGFilter item.

The Apply method performs filter action only for enabled SGFilter objects.

Show Example
Copy Code [image] Show Me

The following example disables all items in the Filters collection, enables the first one and applies the filter.

Private Sub Command3_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .DisableAll
      .Item(1).Enabled = True
      .Apply sgFilterActionSelect
   End With
End Sub

Back to topic


EnableAll Method (SGFilters Collection)

EnableAll Method (SGFilters Collection)
Enables all filters.
Syntax | object.EnableAll
Return Value | None
Arguments | None

Remarks

This method enables all SGFilter objects in the SGFilters collection. You can set the filter's Enabled property to True to enable each SGFilter item.

The Apply method performs filter action only for enabled SGFilter objects.

Show Example
Copy Code [image] Show Me

The following example enables all items in the Filters collection and applies the filter.

Private Sub Command2_Click()
   With SGGrid1.RowFilters
      .ClearMarkers sgFilterActionSelect
      .EnableAll
      .Apply sgFilterActionSelect
   End With
End Sub

Back to topic


Remove Method (SGFilters Collection)

Remove Method (SGFilters Collection)
Removes specified filter from the collection.
Syntax

object.Remove(Index As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGFilters object.
Index | An integer or string that uniquely identifies the object within the collection. Use an integer to specify the value of the Index property; use a string to specify the value of the Key property.

Remarks

To remove all SGFilter objects from the SGFilters collection use the RemoveAll method.

Show Example
Copy Code [image] Show Me

The following example remove all items from the Filters collection except the first one.

Private Sub Command1_Click()
   Dim i As Integer

   For i = 2 To SGGrid1.Filters.Count
      SGGrid1.Filters.Remove 2
   Next

   SGGrid1.Filters.Apply sgFilterActionSelect
End Sub

Back to topic


RemoveAll Method (SGFilters Collection)

RemoveAll Method (SGFilters Collection)
Removes all filters from the collection.
Syntax | object.RemoveAll
Return Value | None
Arguments | None

Remarks

To remove a particular SGFilter object from the SGFilters collection use the Remove method.


SGGroup Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGGroup Object

Name: | SGGroup
Description: | SGGroup is a definition of one hierarchy level.
GUID: | {5483FE44-2A22-11D3-B729-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example fills the grid with file names from the Windows directory and group them by year created. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim sFile As String
   Dim sgCol As SGColumn
   Dim sWinDir As String
   Dim dtFileDate As Date
   Dim i As Integer
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   'misc stuff
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.ColumnClickSort = True
   'Column creations
   Set sgCol = SGGrid1.Columns.Add("File")
   sgCol.Caption = "File name"
   sgCol.Width = 2200
   Set sgCol = SGGrid1.Columns.Add("FileDate")
   sgCol.Caption = "File date"
   sgCol.Width = 2200
   sgCol.DataType = sgtDateTime
   sgCol.SortType = sgSortTypeDateTime
   Set sgCol = SGGrid1.Columns.Add("Size")
   sgCol.Caption = "Size"
   sgCol.DataType = sgtLong
   Set sgCol = SGGrid1.Columns.Add("FileYear")
   sgCol.Hidden = True
   sgCol.Caption = "File year"

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.*", vbNormal)

   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      dtFileDate = FileDateTime(sWinDir & sFile)
      SGGrid1.Rows.At(i).Cells(1).Value = dtFileDate
      SGGrid1.Rows.At(i).Cells(2).Value = FileLen(sWinDir & sFile)
      SGGrid1.Rows.At(i).Cells(3).Value = Year(dtFileDate)
      sFile = Dir
   Loop

   SGGrid1.Groups.Add "FileYear", sgSortAscending, sgSortTypeNumber, , True

   SGGrid1.CollapseAll
End Sub

Back to topic

Referenced By


SGGroup Properties

Calculations | Returns the collection that contains group calculation settings.
FetchFooterStyle | Returns or sets a value indicating whether FetchGroupFooterStyle event will be fired for a group.
FetchHeaderStyle | Returns or sets a value indicating whether FetchGroupHeaderStyle event will be fired for a group.
FooterCaption | Returns or sets group footer caption text.
FooterFormula | Returns or sets group footer formula text.
FooterTextSource | Returns or sets a value representing the group footer type.
FooterVisible | Returns or sets a value indicating whether group will show footer row.
Grid | Returns parent SGGrid object.
GroupingColumn | Returns or sets the key of the column referenced by a group.
HeaderCaption | Returns or sets the group header's caption text.
HeaderFormula | Returns or sets the group header's formula text.
HeaderTextSource | Returns or sets a value indicating how to obtain group header text.
Index | Returns the index of a group in a collection.
PictureCollapsed | Returns or sets the group's collapsed picture.
PictureExpanded | Returns or sets the group's expanded picture.


Calculations Property (SGGroup Object)

Calculations Property (SGGroup Object)
Returns the collection that contains group calculation settings.

Read-only at run time. Not available at design time.

Syntax

object.Calculations As IsgCalculations

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

This Calculations property returns reference to the SGCalculations collection. Use the Add method to add a new calculation object to the collection. Typically, you use calculations as a part of the header or footer formula. The GroupCalc(n) formula keyword returns the value of a group's calculation. In addition, you can use the CalculationResult property of the SGGroupHeading object to get result of a particular calculation.

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   'use calculations in formulas
   grp.HeaderFormula = "GroupingValue & ' from ' " & _
      "& GroupCalc(1) & ' to ' & GroupCalc(2)"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(3),'#.00') & " & _
      "' Total: ' & Format(GroupCalc(4),'#.00')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


FetchFooterStyle Property (SGGroup Object)

FetchFooterStyle Property (SGGroup Object)
Returns or sets a value indicating whether FetchGroupFooterStyle event will be fired for a group.

Read/Write at run time and design time.

Syntax

object.FetchFooterStyle As Boolean

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

Set the FetchFooterStyle property to True to fire the FetchGroupFooterStyle event.

Show Example
Copy Code [image] Show Me

The following example fills the grid with random numbers. Groups them by odd and even. It uses the FetchGroupFooterStyle event to set style and the FetchGroupFooterText event to set a footer text. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupFooterStyle _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   ByVal FooterStyle As IsgStyle)

   With FooterStyle
      If SGGrid1.Rows(RowKey).Parent.GroupingValue = 0 Then
         .ForeColor = &H88
      Else
         .ForeColor = &H880000
      End If
      .TextAlignment = sgAlignCenterCenter
      .Font.Bold = True
   End With
End Sub

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)

   Text = SGGrid1.Rows(RowKey).Parent.Row.Cells(0).Value
   Text = Text & ". The average value is " & _
      Round(SGGrid1.Rows(RowKey).Parent.CalculationResult(1), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim lCount As Long

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then
      lCount = SGGrid1.GroupHeadings(1).CalculationResult(2)
      Text = "There are " & lCount & " even numbers"
   Else
      lCount = SGGrid1.GroupHeadings(2).CalculationResult(2)
      Text = "There are " & lCount & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .DataType = sgtLong
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 12

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 100)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue
   Next

   Set ar = Nothing

   With SGGrid1.Groups.Add("EvenOdd", sgSortAscending, _
      sgSortTypeNumber, True, True)
      .HeaderTextSource = sgGrpHdrFireFetchText
      .FetchFooterStyle = True
      .FooterTextSource = sgGrpFooterFireFetchText
      .Calculations.Add sgCalcAverage, "Number"
      .Calculations.Add sgCalcCount, "EvenOdd"
   End With

   SGGrid1.CollapseAll
End Sub

Back to topic


FetchHeaderStyle Property (SGGroup Object)

FetchHeaderStyle Property (SGGroup Object)
Returns or sets a value indicating whether FetchGroupHeaderStyle event will be fired for a group.

Read/Write at run time and design time.

Syntax

object.FetchHeaderStyle As Boolean

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

Set the FetchHeaderStyle property to True to fire the FetchGroupHeaderStyle event.

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers. It creates two groups, by odd/even numbers and by mod of seven. It uses the GroupHeadings property to create the group header caption. Paints group headers using the FetchGroupHeaderStyle event. Use the CommandButton to remove the current row. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim lKey As Long

   If SGGrid1.DataRowCount = 0 Then Exit Sub

   lKey = SGGrid1.Rows.Current.Key

   Select Case SGGrid1.Rows.Current.Type
      Case sgGroupHeader
         SGGrid1.GroupHeadings.RemoveGroup lKey
      Case sgSimpleRow
         SGGrid1.Rows.Remove lKey
   End Select
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim lCount As Long, gh As SGGroupHeading

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then

      For Each gh In SGGrid1.GroupHeadings(1).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " even numbers"
   Else
      For Each gh In SGGrid1.GroupHeadings(2).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_FetchGroupHeaderStyle _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   ByVal HeaderStyle As IsgStyle)

   With HeaderStyle
      .BackColor = QBColor(SGGrid1.Rows(RowKey).Cells(0).Value)
      .ForeColor = vbWhite
      .TextAlignment = sgAlignCenterCenter
      .Font.Bold = True
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("ModSeven")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 120

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue Mod 7
      ar.Value(i, 2) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrFireFetchText

   With SGGrid1.Groups.Add("ModSeven", sgSortAscending, _
      sgSortTypeNumber, False, False)
      .FetchHeaderStyle = True
      .HeaderTextSource = sgGrpHdrFormula
      .HeaderFormula = "GroupingValue"
   End With

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic


FooterCaption Property (SGGroup Object)

FooterCaption Property (SGGroup Object)
Returns or sets group footer caption text.

Read/Write at run time and design time.

Syntax

object.FooterCaption As String

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

The FooterCaption has effect only if the FooterTextSource property is set to sgGrpFooterCaption.

Show Example
Copy Code [image] Show Me

The following example demonstrates the HeaderCaption and the FooterCaption properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .FitLastColumn = True
      .DataColCount = 1
      .DataRowCount = 1
      .Array.Value(0, 0) = "This is cell."
      With .Groups.Add(.Columns(1).Key)
         .FooterVisible = True
         .FooterCaption = "This is footer."
         .FooterTextSource = sgGrpFooterCaption
         .HeaderCaption = "This is header."
         .HeaderTextSource = sgGrpHdrCaption
      End With
      .RefreshGroups sgExpandGroups
   End With
End Sub

Back to topic


FooterFormula Property (SGGroup Object)

FooterFormula Property (SGGroup Object)
Returns or sets group footer formula text.

Read/Write at run time and design time.

Syntax

object.FooterFormula As String

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

Create formula string using text and special keywords. Text should be enclosed in single quotation marks (') or in " or in double quotation marks (").
You can use the following keywords:

  • GroupingValue: grouping value.
  • TotalChildCount: number of rows in the group. In all sublevels.
  • ChildCount: number of first level child rows.
  • HeaderCaption: group's header caption.
  • FooterCaption: group's footer caption.
  • GroupColCaption: grouped column's heading.
  • GroupCalc(n): result of the group calculation. 'n' is one-based calculation index.
  • Format(val, fmt) : text formatting function. 'val' is value to format and 'fmt' is formatting string
    Note: the BeeGrid formatting uses Visual Basic formatting capabilities. If container does not provide this functionality, cell's data will not be formatted.

The FooterFormula property has effect only if the FooterTextSource is set to sgGrpFooterFormula.

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   'use calculations in formulas
   grp.HeaderFormula = "GroupingValue & ' from ' " & _
      "& GroupCalc(1) & ' to ' & GroupCalc(2)"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(3),'#.00') & " & _
      "' Total: ' & Format(GroupCalc(4),'#.00')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


FooterTextSource Property (SGGroup Object)

FooterTextSource Property (SGGroup Object)
Returns or sets a value representing the group footer type.

Read/Write at run time and design time.

Syntax

object.FooterTextSource As sgGroupFooterText

The object placeholder represents an object expression that evaluates to the SGGroup object.

Settings

The FooterTextSource settings are:

Name | Value | Description
sgGrpFooterEmpty | 0 | Footer without any text or picture.
sgGrpFooterCaption | 1 | Uses group footer caption.
sgGrpFooterFormula | 2 | Uses group footer formula.
sgGrpFooterFireFetchText | 3 | Uses an event to fetch group footer text.

Remarks

If you set this property to sgGrpFooterFireFetchText, use the FetchGroupFooterText event to set footer text.

You can use a group's calculations if you set this property either to sgGrpFooterFormula or sgGrpFooterFireFetchText.

The FooterFormula property has effect only if the FooterVisible is set to True.

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   'use calculations in formulas
   grp.HeaderFormula = "GroupingValue & ' from ' " & _
      "& GroupCalc(1) & ' to ' & GroupCalc(2)"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(3),'#.00') & " & _
      "' Total: ' & Format(GroupCalc(4),'#.00')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


FooterVisible Property (SGGroup Object)

FooterVisible Property (SGGroup Object)
Returns or sets a value indicating whether group will show footer row.

Read/Write at run time and design time.

Syntax

object.FooterVisible As Boolean

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

You can use the ShowFooter parameter of the Add method to show/hide footer.

Show Example
Copy Code [image] Show Me

The following example demonstrates the HeaderCaption and the FooterCaption properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .FitLastColumn = True
      .DataColCount = 1
      .DataRowCount = 1
      .Array.Value(0, 0) = "This is cell."
      With .Groups.Add(.Columns(1).Key)
         .FooterVisible = True
         .FooterCaption = "This is footer."
         .FooterTextSource = sgGrpFooterCaption
         .HeaderCaption = "This is header."
         .HeaderTextSource = sgGrpHdrCaption
      End With
      .RefreshGroups sgExpandGroups
   End With
End Sub

Back to topic


GroupingColumn Property (SGGroup Object)

GroupingColumn Property (SGGroup Object)
Returns or sets the key of the column referenced by a group.

Read/Write at run time and design time.

Syntax

object.GroupingColumn As String

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

You should refresh groups by calling the RefreshGroups method after the GroupingColumn property has been changed.

If you set this property to a value that does not represent any column, an error occurs.

Show Example
Copy Code [image] Show Me

Private Sub Command1_Click()
   Dim i As Integer

   For i = 1 To SGGrid1.Groups.Count
      If SGGrid1.Groups(i).GroupingColumn = "FileYear" Then
         SGGrid1.Groups.Remove i
         Exit For
      End If
   Next
End Sub

Back to topic


HeaderCaption Property (SGGroup Object)

HeaderCaption Property (SGGroup Object)
Returns or sets the group header's caption text.

Read/Write at run time and design time.

Syntax

object.HeaderCaption As String

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

The HeaderCaption has effect if the HeaderTextSource property is set to sgGrpHdrCaption or sgGrpHdrCaptionAndValue.

Show Example
Copy Code [image] Show Me

The following example demonstrates the HeaderCaption and the FooterCaption properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .FitLastColumn = True
      .DataColCount = 1
      .DataRowCount = 1
      .Array.Value(0, 0) = "This is cell."
      With .Groups.Add(.Columns(1).Key)
         .FooterVisible = True
         .FooterCaption = "This is footer."
         .FooterTextSource = sgGrpFooterCaption
         .HeaderCaption = "This is header."
         .HeaderTextSource = sgGrpHdrCaption
      End With
      .RefreshGroups sgExpandGroups
   End With
End Sub

Back to topic


HeaderFormula Property (SGGroup Object)

HeaderFormula Property (SGGroup Object)
Returns or sets the group header's formula text.

Read/Write at run time and design time.

Syntax

object.HeaderFormula As String

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

Create formula string using text and special keywords. Text should be enclosed in single quotation marks (') or in " or in double quotation marks (").
You can use the following keywords:

  • GroupingValue: grouping value.
  • TotalChildCount: number of rows in the group. In all sublevels.
  • ChildCount: number of first level child rows.
  • HeaderCaption: group's header caption.
  • FooterCaption: group's footer caption.
  • GroupColCaption: grouped column's heading.
  • GroupCalc(n): result of the group calculation. 'n' is one-based calculation index.
  • Format(val, fmt) : text formatting function. 'val' is value to format and 'fmt' is formatting string
    Note: the BeeGrid formatting uses Visual Basic formatting capabilities. If container does not provide this functionality, cell's data will not be formatted.

The HeaderFormula property has effect only if the HeaderTextSource is set to sgGrpHdrFormula.

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   'use calculations in formulas
   grp.HeaderFormula = "GroupingValue & ' from ' " & _
      "& GroupCalc(1) & ' to ' & GroupCalc(2)"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(3),'#.00') & " & _
      "' Total: ' & Format(GroupCalc(4),'#.00')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


HeaderTextSource Property (SGGroup Object)

HeaderTextSource Property (SGGroup Object)
Returns or sets a value indicating how to obtain group header text.

Read/Write at run time and design time.

Syntax

object.HeaderTextSource As sgGroupHeaderText

The object placeholder represents an object expression that evaluates to the SGGroup object.

Settings

The HeaderTextSource settings are:

Name | Value | Description
sgGrpHdrEmpty | 0 | Group header without any text.
sgGrpHdrColCaptionAndValue | 1 | Uses column caption and grouping value.
sgGrpHdrCaptionAndValue | 2 | Uses group header caption and grouping value.
sgGrpHdrCaption | 3 | Uses group header caption.
sgGrpHdrFormula | 4 | Uses group header formula.
sgGrpHdrFireFetchText | 5 | Uses an event to fetch group header text.

Remarks

If you set this property to sgGrpHdrFireFetchText, use the FetchGroupHeaderData event to provide header text.

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the HeaderFormula and FooterFormula properties to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.FooterTextSource = sgGrpFooterFormula
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   'use calculations in formulas
   grp.HeaderFormula = "GroupingValue & ' from ' " & _
      "& GroupCalc(1) & ' to ' & GroupCalc(2)"
   grp.FooterFormula = "'Average: ' & Format(GroupCalc(3),'#.00') & " & _
      "' Total: ' & Format(GroupCalc(4),'#.00')"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


Index Property (SGGroup Object)

Index Property (SGGroup Object)
Returns the index of a group in a collection.

Read-only at run time. Not available at design time.

Syntax

object.Index As Integer

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

This property returns the one-based index that uniquely identifies the SGGroup object in the SGGroups collection.

The Index property is set to the order of the creation of objects in a collection. The index for the first object in a collection will always be one (1).

See Also

SGGroup


PictureCollapsed Property (SGGroup Object)

PictureCollapsed Property (SGGroup Object)
Returns or sets the group's collapsed picture.

Read/Write at run time and design time.

Syntax

object.PictureCollapsed As Variant

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

The PictureCollapsed property determines a picture that will be displayed in the collapsed group's header. Its value is interpreted like this:

Value | Picture used
Empty | No picture is displayed
sgGroupHeaderColumnPicture | Uses a picture defined by the grouped column's HeadingPicture property.
sgGroupHeaderFetchPicture | Fires the FetchGroupHeaderData event in which you can set the PictureCollapsed parameter to a value that is a Picture object or an image list index.
Long expression | Uses a picture from one of the grid's image lists. If this value is in a range from sgbipFirst to sgbipLast, a picture from the grid's built-in image list is used. If this value is greater than zero, a picture from the Images image list is used.
Picture object | Uses a picture represented with the Picture object. Visual Basic's LoadPicture function can be used to load an image file.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to set the group collapsed and expanded pictures by using the FetchGroupHeaderData event. Note that you have to assign a picture source with the sgGroupHeaderFetchPicture constant. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim sGroupValue As String

   sGroupValue = SGGrid1.Rows(RowKey).GroupHeading.GroupingValue

   Select Case sGroupValue
      Case "North"
         PictureExpanded = sgbipFirst + 3
         PictureCollapsed = sgbipFirst + 3
      Case "South"
         PictureExpanded = sgbipFirst + 2
         PictureCollapsed = sgbipFirst + 2
      Case "West"
         PictureExpanded = sgbipFirst + 1
         PictureCollapsed = sgbipFirst + 1
      Case "East"
         PictureExpanded = sgbipFirst
         PictureCollapsed = sgbipFirst
   End Select

   Text = sGroupValue
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .FitLastColumn = True
      .Columns.RemoveAll True
      .Rows.RemoveAll False
      With .Columns.Add("Side")
         .Hidden = True
      End With
      .Columns.Add "City"
      .Rows.Add sgFormatCharSeparatedValue, "North,Oslo"
      .Rows.Add sgFormatCharSeparatedValue, "North,Toronto"
      .Rows.Add sgFormatCharSeparatedValue, "West,New York"
      .Rows.Add sgFormatCharSeparatedValue, "West,London"
      .Rows.Add sgFormatCharSeparatedValue, "North,Berlin"
      .Rows.Add sgFormatCharSeparatedValue, "South,Roma"
      .Rows.Add sgFormatCharSeparatedValue, "East,Peking"
      .Rows.Add sgFormatCharSeparatedValue, "East,Tokyo"
      .Rows.Add sgFormatCharSeparatedValue, "South,Sydney"
      With .Groups.Add("Side")
         .HeaderTextSource = sgGrpHdrFireFetchText
         .PictureCollapsed = sgGroupHeaderFetchPicture
         .PictureExpanded = sgGroupHeaderFetchPicture
      End With
   End With
End Sub

Back to topic


PictureExpanded Property (SGGroup Object)

PictureExpanded Property (SGGroup Object)
Returns or sets the group's expanded picture.

Read/Write at run time and design time.

Syntax

object.PictureExpanded As Variant

The object placeholder represents an object expression that evaluates to the SGGroup object.

Remarks

The PictureExpanded property determines a picture that will be displayed in the expanded group's header. Its value is interpreted like this:

Value | Picture used
Empty | No picture is displayed
sgGroupHeaderColumnPicture | Uses a picture defined by the grouped column's HeadingPicture property.
sgGroupHeaderFetchPicture | Fires the FetchGroupHeaderData event in which you can set the PictureExpanded parameter to a value that is a Picture object or an image list index.
Long expression | Uses a picture from one of the grid's image lists. If this value is in a range from sgbipFirst to sgbipLast, a picture from the grid's built-in image list is used. If this value is greater than zero, a picture from the Images image list is used.
Picture object | Uses a picture represented with the Picture object. Visual Basic's LoadPicture function can be used to load an image file.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to set the group collapsed and expanded pictures by using the FetchGroupHeaderData event. Note that you have to assign a picture source with the sgGroupHeaderFetchPicture constant. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim sGroupValue As String

   sGroupValue = SGGrid1.Rows(RowKey).GroupHeading.GroupingValue

   Select Case sGroupValue
      Case "North"
         PictureExpanded = sgbipFirst + 3
         PictureCollapsed = sgbipFirst + 3
      Case "South"
         PictureExpanded = sgbipFirst + 2
         PictureCollapsed = sgbipFirst + 2
      Case "West"
         PictureExpanded = sgbipFirst + 1
         PictureCollapsed = sgbipFirst + 1
      Case "East"
         PictureExpanded = sgbipFirst
         PictureCollapsed = sgbipFirst
   End Select

   Text = sGroupValue
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .FitLastColumn = True
      .Columns.RemoveAll True
      .Rows.RemoveAll False
      With .Columns.Add("Side")
         .Hidden = True
      End With
      .Columns.Add "City"
      .Rows.Add sgFormatCharSeparatedValue, "North,Oslo"
      .Rows.Add sgFormatCharSeparatedValue, "North,Toronto"
      .Rows.Add sgFormatCharSeparatedValue, "West,New York"
      .Rows.Add sgFormatCharSeparatedValue, "West,London"
      .Rows.Add sgFormatCharSeparatedValue, "North,Berlin"
      .Rows.Add sgFormatCharSeparatedValue, "South,Roma"
      .Rows.Add sgFormatCharSeparatedValue, "East,Peking"
      .Rows.Add sgFormatCharSeparatedValue, "East,Tokyo"
      .Rows.Add sgFormatCharSeparatedValue, "South,Sydney"
      With .Groups.Add("Side")
         .HeaderTextSource = sgGrpHdrFireFetchText
         .PictureCollapsed = sgGroupHeaderFetchPicture
         .PictureExpanded = sgGroupHeaderFetchPicture
      End With
   End With
End Sub

Back to topic


SGGroups Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGGroups Object

Name: | SGGroups
Description: | Collection of SGGroup objects.
GUID: | {5483FE45-2A22-11D3-B729-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example groups all files from the windows directory. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim sFile As String
   Dim sgCol As SGColumn
   Dim SGGroup As SGGroup
   Dim sWinDir As String
   Dim dtFileDate As Date
   Dim i As Integer
   'change default groups style
   With SGGrid1
      .Styles("Heading").BackColor = RGB(165, 142, 107)
      .Styles("Selection").BackColor = RGB(181, 154, 115)
      .Styles("InactiveSelection").BackColor = RGB(132, 190, 173)
      .Styles("GroupHeader").BackColor = RGB(231, 203, 123)
      .BackColor = RGB(214, 207, 189)
      .SpecialMode = sgModeListBox
   End With
   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   'ColumnClickSort needs CacheAllRecords
   SGGrid1.CacheAllRecords = True
   SGGrid1.ColumnClickSort = True
   SGGrid1.GroupByBoxVisible = False
   'Column creations
   Set sgCol = SGGrid1.Columns.Add("File")
   sgCol.Caption = "File name"
   sgCol.Width = 2200
   Set sgCol = SGGrid1.Columns.Add("FileDate")
   sgCol.Caption = "File date"
   sgCol.Width = 2200
   sgCol.DataType = sgtDateTime
   sgCol.SortType = sgSortTypeDateTime
   Set sgCol = SGGrid1.Columns.Add("Size")
   sgCol.Caption = "Size"
   sgCol.DataType = sgtLong

   Set sgCol = SGGrid1.Columns.Add("FileYear")
   sgCol.Hidden = True
   sgCol.Caption = "File year"
   Set sgCol = SGGrid1.Columns.Add("FileMonth")
   sgCol.Hidden = True
   sgCol.Caption = "File month"

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.*", vbNormal)
   'add files to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      dtFileDate = FormatDateTime(FileDateTime(sWinDir & sFile), vbShortDate)
      SGGrid1.Rows.At(i).Cells(1).Value = dtFileDate
      SGGrid1.Rows.At(i).Cells(2).Value = FileLen(sWinDir & sFile)
      SGGrid1.Rows.At(i).Cells(3).Value = Year(dtFileDate)
      SGGrid1.Rows.At(i).Cells(4).Value = Month(dtFileDate)
      sFile = Dir
   Loop
   'group grid by year and month
   Set SGGroup = SGGrid1.Groups.Add("FileYear", sgSortAscending, _
      sgSortTypeNumber, True, False)
   Call SGGrid1.Groups.Add("FileMonth", sgSortAscending, _
      sgSortTypeNumber, False, False)
   'show formula result in header and footer
   SGGroup.HeaderTextSource = sgGrpHdrFormula
   SGGroup.FooterTextSource = sgGrpFooterFormula
   'create calculations for header and footer
   SGGroup.Calculations.Add sgCalcSum, "Size"
   SGGroup.Calculations.Add sgCalcAverage, "Size"
   'create formula
   SGGroup.HeaderFormula = "'Total size for ' & GroupingValue & ' is ' & Format((GroupCalc(1) / 1024),'Standard') & ' KB (' & TotalChildCount & ' files)'"
   SGGroup.FooterFormula = "'The average file size for ' & GroupingValue & ' is ' & Format((GroupCalc(2) / 1024),'Standard') & ' KB'"

   Set SGGroup = Nothing
   'the argument doRefresh in the Groups.Add method is false so
   'grouping need refresh
   SGGrid1.RefreshGroups
   'redrow grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

Referenced By

Groups


SGGroups Properties

Count | Returns the number of SGGroup objects in the collection
Grid | Returns parent SGGrid object.
Item | Returns specified SGGroup object


SGGroups Methods

Add | Adds new SGGroup object to the collection and returns a reference to the newly created object.
GetDefinition | Returns XML presentation of the Groups collection.
RemoveAll | Removes all groups from the collection.
Remove | Removes specified group from the collection.
SetDefinition | Initializes Groups collection with XML string.


Add Method (SGGroups Collection)

Add Method (SGGroups Collection)
Adds new SGGroup object to the collection and returns a reference to the newly created object.
Syntax

object.Add(Column As Variant, [SortOrder = sgSortAscending] As sgSortOrder, [SortType = sgSortTypeDefault] As sgSortType, [ShowFooter = 0] As Boolean, [DoRefresh = -1] As Boolean)

Return Value A SGGroup object.
Arguments
object | An object expression that evaluates to the SGGroups object.
Column | A String expression that represents the Key of the column.
SortOrder | Optional. A sgSortOrder expression sets sort order. Default value is sgSortAscending. The possible values are listed in Settings.
SortType | Optional. A sgSortType expression sets data type used when sorting. Default value is sgSortTypeDefault. The possible values are listed in Settings.
ShowFooter | Optional. A Boolean expression indicates whether the Group footer is shown. Default value is 0.
DoRefresh | Optional. A Boolean expression that indicates if the group settings are refreshed automatically. If it is False, you should refresh groups by calling RefreshGroups method. Default value is True.

Settings

The settings for SortType are:

Name | Value | Description
sgSortTypeDefault | 0 | Convert values to the column's data type before comparing.
sgSortTypeCustom | 1 | Fire the CompareCell event to compare two values.
sgSortTypeNumber | 2 | Convert to double-precision values before comparing.
sgSortTypeString | 3 | Convert to string values before comparing.
sgSortTypeNoCaseString | 4 | Convert to string values before comparing. Ignore case.
sgSortTypeDateTime | 5 | Convert to date-time values before comparing.
The settings for SortOrder are:

Name | Value | Description
sgNoSorting | 0 | Do not sort.
sgSortAscending | 1 | Sort in ascending order.
sgSortDescending | 2 | Sort in descending order.

Remarks

When a SGGroup object is added to the collection, a reference to the newly created object is returned. You can use the reference to set other properties of the SGGroup.

If you set the SortOrder parameter to sgNoSorting grouping operation will be much faster.

Show Example
Copy Code [image] Show Me

The following example adds or removes the CategoryName group.

Private Sub Command1_Click()
   Dim grp As SGGroup, i As Integer
   'check if CategoryName group exist
   For i = 1 To SGGrid1.Groups.Count
      If SGGrid1.Groups(i).GroupingColumn = "CategoryName" Then
         'remove group end exit sub
         SGGrid1.Groups.Remove i
         SGGrid1.RefreshGroups
         Exit Sub
      End If
   Next
   'add group to the collection
   Set grp = SGGrid1.Groups.Add("CategoryName", _
      sgSortAscending, sgSortTypeNumber, False, False)

   grp.FetchHeaderStyle = True
   grp.HeaderTextSource = sgGrpHdrColCaptionAndValue

   SGGrid1.RefreshGroups
End Sub

Back to topic


Remove Method (SGGroups Collection)

Remove Method (SGGroups Collection)
Removes specified group from the collection.
Syntax

object.Remove(Index As Integer)

Return Value None
Arguments
object | An object expression that evaluates to the SGGroups object.
Index | An integer that uniquely identifies the object within the collection.

Remarks

To remove all SGGroup objects from the SGGroups collection use the RemoveAll method.

Show Example
Copy Code [image] Show Me

The following example adds or removes the CategoryName group.

Private Sub Command1_Click()
   Dim grp As SGGroup, i As Integer
   'check if CategoryName group exist
   For i = 1 To SGGrid1.Groups.Count
      If SGGrid1.Groups(i).GroupingColumn = "CategoryName" Then
         'remove group end exit sub
         SGGrid1.Groups.Remove i
         SGGrid1.RefreshGroups
         Exit Sub
      End If
   Next
   'add group to the collection
   Set grp = SGGrid1.Groups.Add("CategoryName", _
      sgSortAscending, sgSortTypeNumber, False, False)

   grp.FetchHeaderStyle = True
   grp.HeaderTextSource = sgGrpHdrColCaptionAndValue

   SGGrid1.RefreshGroups
End Sub

Back to topic


RemoveAll Method (SGGroups Collection)

RemoveAll Method (SGGroups Collection)
Removes all groups from the collection.
Syntax | object.RemoveAll
Return Value | None
Arguments | None

Remarks

To remove a particular SGGroup object from the SGGroups collection use the Remove method.

Show Example
Copy Code [image] Show Me

The following example swap the first and the second group.

Private Sub Command1_Click()
   Dim sCol1 As String, sCol2 As String

   sCol1 = SGGrid1.Groups(1).GroupingColumn
   sCol2 = SGGrid1.Groups(2).GroupingColumn

   SGGrid1.Groups.RemoveAll

   SGGrid1.Groups.Add sCol2
   SGGrid1.Groups.Add sCol1

   SGGrid1.RefreshGroups
End Sub

Back to topic


SGGroupHeading Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGGroupHeading Object

Name: | SGGroupHeading
Description: | SGGroupHeading object represents group header row.
GUID: | {35B30F04-3496-11D3-B734-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers. It creates two groups, by odd/even numbers and by mod of seven. It uses the GroupHeadings property to create the group header caption. Paints group headers using the FetchGroupHeaderStyle event. Use the CommandButton to remove the current row. To try the example, place SGGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim lKey As Long

   If SGGrid1.DataRowCount = 0 Then Exit Sub

   lKey = SGGrid1.Rows.Current.Key

   Select Case SGGrid1.Rows.Current.Type
      Case sgGroupHeader
         SGGrid1.GroupHeadings.RemoveGroup lKey
      Case sgSimpleRow
         SGGrid1.Rows.Remove lKey
   End Select
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim lCount As Long, gh As SGGroupHeading

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then

      For Each gh In SGGrid1.GroupHeadings(1).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " even numbers"
   Else
      For Each gh In SGGrid1.GroupHeadings(2).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_FetchGroupHeaderStyle _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   ByVal HeaderStyle As IsgStyle)

   With HeaderStyle
      .BackColor = QBColor(SGGrid1.Rows(RowKey).Cells(0).Value)
      .ForeColor = vbWhite
      .TextAlignment = sgAlignCenterCenter
      .Font.Bold = True
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("ModSeven")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 120

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue Mod 7
      ar.Value(i, 2) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrFireFetchText

   With SGGrid1.Groups.Add("ModSeven", sgSortAscending, _
      sgSortTypeNumber, False, False)
      .FetchHeaderStyle = True
      .HeaderTextSource = sgGrpHdrFormula
      .HeaderFormula = "GroupingValue"
   End With

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic

Referenced By


SGGroupHeading Properties

CalculationResult | Returns result of the group calculation.
CalculationsCount | Returns the number of calculations associated with a group.
ChildRows | Returns the collection of child rows (without group headers).
Expanded | Returns True if this group is expanded.
Grid | Returns parent SGGrid object.
GroupDef | Returns group definition object for this group heading.
GroupingValue | Returns grouping value.
Headings | Returns the collection of child group-heading objects.
Row | Returns group heading as an SGRow object.


CalculationResult Property (SGGroupHeading Object)

CalculationResult Property (SGGroupHeading Object)
Returns result of the group calculation.

Read-only at run time. Not available at design time.

Syntax

object.CalculationResult As Variant

The object placeholder represents an object expression that evaluates to the SGGroupHeading object.

Remarks

Use the Add method of the SGCalculations collection to add new calculation to the group. The code below add a calculation object into the SGCalculations collection:

   SGGrid1.Groups(1).Calculations.Add sgCalcMaximum, ColKey

Typically, you use this property in the FetchGroupHeaderData and the FetchGroupFooterText events.

Use the CalculationsCount property to get count of the SGCalculation object in the SGCalculations collection associated with a group.

Show Example
Copy Code [image] Show Me

The following example creates tree columns: Month, Day and Amount and fills them with random data. It uses Month column to create group object and creates four group's calculations. It uses the FetchGroupFooterText and FetchGroupHeaderData events to display result of calculations in the group's footer and header. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).Parent.Row.GroupHeading

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100
   SGGrid1.FitLastColumn = True

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFireFetchText
   grp.FooterTextSource = sgGrpFooterFireFetchText
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


CalculationsCount Property (SGGroupHeading Object)

CalculationsCount Property (SGGroupHeading Object)
Returns the number of calculations associated with a group.

Read-only at run time. Not available at design time.

Syntax

object.CalculationsCount As Integer

The object placeholder represents an object expression that evaluates to the SGGroupHeading object.

Remarks

Use the CalculationResult property to get result of a particular calculation.


ChildRows Property (SGGroupHeading Object)

ChildRows Property (SGGroupHeading Object)
Returns the collection of child rows (without group headers).

Read-only at run time. Not available at design time.

Syntax

object.ChildRows As IsgRowCollection

The object placeholder represents an object expression that evaluates to the SGGroupHeading object.

Remarks

This property returns the SGRowCollection collection associated with a group. This collection include simple and group footer rows, but group headers are not included.


Expanded Property (SGGroupHeading Object)

Expanded Property (SGGroupHeading Object)
Returns True if this group is expanded.
Syntax

object.Expanded As Boolean

The object placeholder represents an object expression that evaluates to the SGGroupHeading object.

Remarks

You can use the Expand and the Collapse methods of the SGGroupHeading object to expand/collapse group headings.

Show Example
Copy Code [image] Show Me

The following example demonstrates the Expanded property and the Expand and the Collapse methods of the SGGroupHeading object. It expands collapsed rows and collapses expanded rows. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim gh As SGGroupHeading

   SGGrid1.RedrawEnabled = False

   For Each gh In SGGrid1.GroupHeadings
      If gh.Expanded Then
         gh.Collapse
      Else
         gh.Expand
      End If
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .FitLastColumn = True
      .GroupByBoxVisible = False
      .Columns.RemoveAll True
      .Rows.RemoveAll False
      With .Columns.Add("Side")
         .Hidden = True
      End With
      .Columns.Add "City"
      .Rows.Add sgFormatCharSeparatedValue, "North,Oslo"
      .Rows.Add sgFormatCharSeparatedValue, "North,Toronto"
      .Rows.Add sgFormatCharSeparatedValue, "West,New York"
      .Rows.Add sgFormatCharSeparatedValue, "West,London"
      .Rows.Add sgFormatCharSeparatedValue, "North,Berlin"
      .Rows.Add sgFormatCharSeparatedValue, "South,Roma"
      .Rows.Add sgFormatCharSeparatedValue, "East,Peking"
      .Rows.Add sgFormatCharSeparatedValue, "East,Tokyo"
      .Rows.Add sgFormatCharSeparatedValue, "South,Sydney"
      .Groups.Add "Side"
      .RefreshGroups sgCollapseGroups
   End With
End Sub

Back to topic


GroupDef Property (SGGroupHeading Object)

GroupDef Property (SGGroupHeading Object)
Returns group definition object for this group heading.

Read-only at run time. Not available at design time.

Syntax

object.GroupDef As IsgGroup

The object placeholder represents an object expression that evaluates to the SGGroupHeading object.

Remarks

The GroupDef property returns reference to the SGGroup object.
The first and the second line returns the same reference:

SGGrid1.GroupHeadings(1).GroupDef

- or -

SGGrid1.Groups(1)

See Also

SGGroupHeading


GroupingValue Property (SGGroupHeading Object)

GroupingValue Property (SGGroupHeading Object)
Returns grouping value.

Read-only at run time. Not available at design time.

Syntax

object.GroupingValue As Variant

The object placeholder represents an object expression that evaluates to the SGGroupHeading object.

Remarks

The GroupingValue property returns a grouping value. This property could be useful in FetchGroupHeaderData, FetchGroupHeaderStyle, FetchGroupFooterStyle and the FetchGroupFooterText events.

Show Example
Copy Code [image] Show Me

The following example uses the GroupingValue property to create group's header text.

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Back to topic

See Also

SGGroupHeading


Headings Property (SGGroupHeading Object)

Headings Property (SGGroupHeading Object)
Returns the collection of child group-heading objects.

Read-only at run time. Not available at design time.

Syntax

object.Headings As IsgGroupHeadings

The object placeholder represents an object expression that evaluates to the SGGroupHeading object.

Remarks

The Headings property returns SGGroupHeadings collection of child group heading objects.

This property make sense only if there are more then one group object in the SGGroup collection.

Show Example
Copy Code [image] Show Me

The following example prints a group heading text and rows count of each group heading.

Private Sub EnumGroupHeadings(ghs As SGGroupHeadings)
   Dim gh As SGGroupHeading

   For Each gh In ghs
      Debug.Print gh.Row.Cells(0).Value & _
         " (" & gh.ChildRows.Count & ")"
      EnumGroupHeadings gh.Headings
   Next
End Sub

Back to topic


Row Property (SGGroupHeading Object)

Row Property (SGGroupHeading Object)
Returns group heading as an SGRow object.

Read-only at run time. Not available at design time.

Syntax

object.Row As IsgRow

The object placeholder represents an object expression that evaluates to the SGGroupHeading object.

Remarks

This property is reference to the SGRow object. You can use the Row property to change height of the row or to hide a row.
The code below hide the first group heading:

   SGGrid1.GroupHeadings(1).Row.Hidden = True

Show Example
Copy Code [image] Show Me

The following example prints contents of the group heading rows.

Private Sub SGGrid1_OnInit()
   Dim gh As SGGroupHeading

   For Each gh In SGGrid1.GroupHeadings
      Debug.Print gh.Row.Cells(0).Value
   Next
End Sub

Back to topic

See Also

SGGroupHeading


SGGroupHeading Methods

Collapse | Collapses this group.
Expand | Expands this group.


Collapse Method (SGGroupHeading Object)

Collapse Method (SGGroupHeading Object)
Collapses this group.
Syntax | object.Collapse
Return Value | None
Arguments | None

Remarks

You can use the CollapseAll method to collapse all group headings.

Show Example
Copy Code [image] Show Me

The following example demonstrates the Expanded property and the Expand and the Collapse methods of the SGGroupHeading object. It expands collapsed rows and collapses expanded rows. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim gh As SGGroupHeading

   SGGrid1.RedrawEnabled = False

   For Each gh In SGGrid1.GroupHeadings
      If gh.Expanded Then
         gh.Collapse
      Else
         gh.Expand
      End If
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .FitLastColumn = True
      .GroupByBoxVisible = False
      .Columns.RemoveAll True
      .Rows.RemoveAll False
      With .Columns.Add("Side")
         .Hidden = True
      End With
      .Columns.Add "City"
      .Rows.Add sgFormatCharSeparatedValue, "North,Oslo"
      .Rows.Add sgFormatCharSeparatedValue, "North,Toronto"
      .Rows.Add sgFormatCharSeparatedValue, "West,New York"
      .Rows.Add sgFormatCharSeparatedValue, "West,London"
      .Rows.Add sgFormatCharSeparatedValue, "North,Berlin"
      .Rows.Add sgFormatCharSeparatedValue, "South,Roma"
      .Rows.Add sgFormatCharSeparatedValue, "East,Peking"
      .Rows.Add sgFormatCharSeparatedValue, "East,Tokyo"
      .Rows.Add sgFormatCharSeparatedValue, "South,Sydney"
      .Groups.Add "Side"
      .RefreshGroups sgCollapseGroups
   End With
End Sub

Back to topic


Expand Method (SGGroupHeading Object)

Expand Method (SGGroupHeading Object)
Expands this group.
Syntax

object.Expand([Levels = -1] As Integer)

Return Value None
Arguments
object | An object expression that evaluates to the SGGroupHeading object.
Levels | Optional. An Integer expression that specifies the number of levels to expand. Default value is -1, which expands all levels.

Remarks

You can use the ExpandAll method to expand all group headings.

Show Example
Copy Code [image] Show Me

The following example demonstrates the Expanded property and the Expand and the Collapse methods of the SGGroupHeading object. It expands collapsed rows and collapses expanded rows. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim gh As SGGroupHeading

   SGGrid1.RedrawEnabled = False

   For Each gh In SGGrid1.GroupHeadings
      If gh.Expanded Then
         gh.Collapse
      Else
         gh.Expand
      End If
   Next

   SGGrid1.RedrawEnabled = False
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .FitLastColumn = True
      .GroupByBoxVisible = False
      .Columns.RemoveAll True
      .Rows.RemoveAll False
      With .Columns.Add("Side")
         .Hidden = True
      End With
      .Columns.Add "City"
      .Rows.Add sgFormatCharSeparatedValue, "North,Oslo"
      .Rows.Add sgFormatCharSeparatedValue, "North,Toronto"
      .Rows.Add sgFormatCharSeparatedValue, "West,New York"
      .Rows.Add sgFormatCharSeparatedValue, "West,London"
      .Rows.Add sgFormatCharSeparatedValue, "North,Berlin"
      .Rows.Add sgFormatCharSeparatedValue, "South,Roma"
      .Rows.Add sgFormatCharSeparatedValue, "East,Peking"
      .Rows.Add sgFormatCharSeparatedValue, "East,Tokyo"
      .Rows.Add sgFormatCharSeparatedValue, "South,Sydney"
      .Groups.Add "Side"
      .RefreshGroups sgCollapseGroups
   End With
End Sub

Back to topic


SGGroupHeadings Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGGroupHeadings Object

Name: | SGGroupHeadings
Description: | Collection of SGGroupHeading objects.
GUID: | {35B30F05-3496-11D3-B734-008048E27A77}

Show Example
Copy Code [image] Show Me

Private Sub EnumGroupHeadings(ghs As SGGroupHeadings)
   Dim gh As SGGroupHeading

   For Each gh In ghs
      Debug.Print gh.Row.Cells(0).Value & _
         " (" & gh.ChildRows.Count & ")"
      EnumGroupHeadings gh.Headings
   Next
End Sub

Private Sub Command1_Click()
   EnumGroupHeadings SGGrid1.GroupHeadings
End Sub

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).Parent.Row.GroupHeading

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 1000
   SGGrid1.FitLastColumn = True

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFireFetchText
   grp.FooterTextSource = sgGrpFooterFireFetchText
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"

   Set grp = SGGrid1.Groups.Add("Day", _
      sgSortAscending, sgSortTypeNumber, False, False)
   grp.Calculations.Add sgCalcMaximum, "Amount"
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.HeaderFormula = "GroupingValue & '    Total: ' & GroupCalc(1)"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic

Referenced By


SGGroupHeadings Properties

Count | Returns the number of group heading child objects.
Grid | Returns parent SGGrid object.
Item | Returns specified group heading object.


SGGroupHeadings Methods

RemoveGroup Removes specified group heading and all of its child rows.


RemoveGroup Method (SGGroupHeadings Collection)

RemoveGroup Method (SGGroupHeadings Collection)
Removes specified group heading and all of its child rows.
Syntax

object.RemoveGroup(RowKey As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGGroupHeadings object.
RowKey | A Long that represents the Key of the row.

Remarks

The RemoveGroup method removes specified group heading and all of its child rows. With this method you can remove only rows with the Type property set to sgGroupHeader. Use the Remove method of the SGRows collection or Delete method to remove a simple row.

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers. It creates two groups, by odd/even numbers and by mod of seven. It uses the GroupHeadings property to create the group header caption. Paints group headers using the FetchGroupHeaderStyle event. Use the CommandButton to remove the current row. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim lKey As Long

   If SGGrid1.DataRowCount = 0 Then Exit Sub

   lKey = SGGrid1.Rows.Current.Key

   Select Case SGGrid1.Rows.Current.Type
      Case sgGroupHeader
         SGGrid1.GroupHeadings.RemoveGroup lKey
      Case sgSimpleRow
         SGGrid1.Rows.Remove lKey
   End Select
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim lCount As Long, gh As SGGroupHeading

   If RowKey = SGGrid1.GroupHeadings(1).Row.Key Then

      For Each gh In SGGrid1.GroupHeadings(1).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " even numbers"
   Else
      For Each gh In SGGrid1.GroupHeadings(2).Headings
         lCount = lCount + gh.ChildRows.Count
      Next

      Text = "There are " & lCount & " odd numbers"
   End If
End Sub

Private Sub SGGrid1_FetchGroupHeaderStyle _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   ByVal HeaderStyle As IsgStyle)

   With HeaderStyle
      .BackColor = QBColor(SGGrid1.Rows(RowKey).Cells(0).Value)
      .ForeColor = vbWhite
      .TextAlignment = sgAlignCenterCenter
      .Font.Bold = True
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   SGGrid1.Columns.RemoveAll
   SGGrid1.FitLastColumn = True
   SGGrid1.GroupByBoxVisible = False

   With SGGrid1.Columns.Add("EvenOdd")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("ModSeven")
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 120

   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue Mod 7
      ar.Value(i, 2) = lRndValue
   Next

   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrFireFetchText

   With SGGrid1.Groups.Add("ModSeven", sgSortAscending, _
      sgSortTypeNumber, False, False)
      .FetchHeaderStyle = True
      .HeaderTextSource = sgGrpHdrFormula
      .HeaderFormula = "GroupingValue"
   End With

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic


SGRange Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGRange Object

Name: | SGRange
Description: | SGRange object represents a range of rows, columns or cells.
GUID: | {AC43EBBA-99CE-474D-BAC9-DBF0F701F69F}

Show Example
Copy Code [image] Show Me

The following example paints heading row and column cells to black and white. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer

   SGGrid1.RedrawEnabled = False

   SGGrid1.DataColCount = 20
   SGGrid1.DataRowCount = 20

   SGGrid1.RowNumbering = True
   SGGrid1.Appearance = sgFlat

   With SGGrid1.Styles.Add("Black")
      .BaseStyle = "Normal"
      .BackColor = vbBlack
      .ForeColor = vbWhite
   End With

   For i = 1 To SGGrid1.DataColCount - 1
      SGGrid1.Columns.At(i).Caption = "Column " & Trim(i)
      With SGGrid1.CreateRange(sgRangeFree, i, 0, i, 0)
         If i Mod 2 Then
            .ApplyStyle "Black"
         Else
            .ApplyStyle "Normal"
         End If
      End With
   Next

   For i = 1 To SGGrid1.DataRowCount
      With SGGrid1.CreateRange(sgRangeFree, 0, i, 0, i)
         If i Mod 2 Then
            .ApplyStyle "Black"
         Else
            .ApplyStyle "Normal"
         End If
      End With
   Next

   With SGGrid1.CreateRange(sgRangeFree, 0, 0, 0, 0)
      .ApplyStyle "Normal"
   End With

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

Referenced By


SGRange Properties

BottomRow | Returns position of the bottom-most row in the range.
Grid | Returns parent SGGrid object.
LeftCol | Returns position of the left-most column in the range.
Name | Returns or sets range's name.
RightCol | Returns position of the right-most column in the range.
TopRow | Returns position of the top-most row in the range.
Type | Returns range type.


BottomRow Property (SGRange Object)

BottomRow Property (SGRange Object)
Returns position of the bottom-most row in the range.

Read-only at run time. Not available at design time.

Syntax

object.BottomRow As Long

The object placeholder represents an object expression that evaluates to the SGRange object.

Remarks

The BottomRow property is ignored if the Type property of the SGRange object is set to sgRangeColumn.

Show Example
Copy Code [image] Show Me

The following example creates four ranges and applies style for each object entire ranges. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim rng As SGRange
   Dim i As Integer, j As Integer
   Dim row As SGRow

   SGGrid1.Styles.RemoveCustom

   For Each rng In SGGrid1.Selection.Ranges
      Select Case rng.Type
         Case sgRangeRow
            For i = rng.TopRow To rng.BottomRow
               SGGrid1.Rows.At(i).Style = "SelRow"
            Next
         Case sgRangeColumn
            For i = rng.LeftCol To rng.RightCol
               SGGrid1.Columns.At(i).Style = "SelCol"
            Next
         Case sgRangeFree
            For i = rng.TopRow To rng.BottomRow
               Set row = SGGrid1.Rows.At(i)
               For j = rng.LeftCol To rng.RightCol
                  row.Cells(j).Style = "SelFree"
               Next
            Next
      End Select
   Next

   SGGrid1.Selection.Clear
End Sub

Private Sub SGGrid1_OnInit()

   With SGGrid1
      .FitLastColumn = True
      .GroupByBoxVisible = False
      .Columns.RemoveAll False
      .DataRowCount = 12

      With .Styles.Add("SelRow")
         .BackColor = vbYellow
      End With

      With .Styles.Add("SelCol")
         .BackColor = vbGreen
      End With

      With .Styles.Add("SelFree")
         .BackColor = vbMagenta
      End With

      With .Columns.Add("Row")
         .HeadingStyle = "SelRow"
      End With
      With .Columns.Add("Column")
         .HeadingStyle = "SelCol"
      End With
      With .Columns.Add("Free")
         .HeadingStyle = "SelFree"
      End With

      .Columns.Add
      .Columns.Add
      .Columns.Add

      .MultiSelect = sgMultiSelectExtended
      .SelectionMode = sgSelectionModeAll

      SGGrid1.Selection.Ranges.Add sgRangeFree, 1, 7, 2, 10
      SGGrid1.Selection.Ranges.Add sgRangeFree, 2, 4, 2, 4
      SGGrid1.Selection.Ranges.Add sgRangeRow, 0, 2, 0, 2
      SGGrid1.Selection.Ranges.Add sgRangeColumn, 4, 0, 4, 0

   End With

   Command1_Click
End Sub

Back to topic


LeftCol Property (SGRange Object)

LeftCol Property (SGRange Object)
Returns position of the left-most column in the range.

Read-only at run time. Not available at design time.

Syntax

object.LeftCol As Long

The object placeholder represents an object expression that evaluates to the SGRange object.

Remarks

The LeftCol property is ignored if the Type property of the SGRange object is set to sgRangeRow.


Name Property (SGRange Object)

Name Property (SGRange Object)
Returns or sets range's name.

Read-only at run time. Not available at design time.

Syntax

object.Name As String

The object placeholder represents an object expression that evaluates to the SGRange object.

Remarks

See Also

SGRange


RightCol Property (SGRange Object)

RightCol Property (SGRange Object)
Returns position of the right-most column in the range.

Read-only at run time. Not available at design time.

Syntax

object.RightCol As Long

The object placeholder represents an object expression that evaluates to the SGRange object.

Remarks

The RightCol property is ignored if the Type property of the SGRange object is set to sgRangeRow.


TopRow Property (SGRange Object)

TopRow Property (SGRange Object)
Returns position of the top-most row in the range.

Read-only at run time. Not available at design time.

Syntax

object.TopRow As Long

The object placeholder represents an object expression that evaluates to the SGRange object.

Remarks

The TopRow property is ignored if the Type property of the SGRange object is set to sgRangeColumn.

Show Example
Copy Code [image] Show Me

The following example creates four ranges and applies style for each object entire ranges. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim rng As SGRange
   Dim i As Integer, j As Integer
   Dim row As SGRow

   SGGrid1.Styles.RemoveCustom

   For Each rng In SGGrid1.Selection.Ranges
      Select Case rng.Type
         Case sgRangeRow
            For i = rng.TopRow To rng.BottomRow
               SGGrid1.Rows.At(i).Style = "SelRow"
            Next
         Case sgRangeColumn
            For i = rng.LeftCol To rng.RightCol
               SGGrid1.Columns.At(i).Style = "SelCol"
            Next
         Case sgRangeFree
            For i = rng.TopRow To rng.BottomRow
               Set row = SGGrid1.Rows.At(i)
               For j = rng.LeftCol To rng.RightCol
                  row.Cells(j).Style = "SelFree"
               Next
            Next
      End Select
   Next

   SGGrid1.Selection.Clear
End Sub

Private Sub SGGrid1_OnInit()

   With SGGrid1
      .FitLastColumn = True
      .GroupByBoxVisible = False
      .Columns.RemoveAll False
      .DataRowCount = 12

      With .Styles.Add("SelRow")
         .BackColor = vbYellow
      End With

      With .Styles.Add("SelCol")
         .BackColor = vbGreen
      End With

      With .Styles.Add("SelFree")
         .BackColor = vbMagenta
      End With

      With .Columns.Add("Row")
         .HeadingStyle = "SelRow"
      End With
      With .Columns.Add("Column")
         .HeadingStyle = "SelCol"
      End With
      With .Columns.Add("Free")
         .HeadingStyle = "SelFree"
      End With

      .Columns.Add
      .Columns.Add
      .Columns.Add

      .MultiSelect = sgMultiSelectExtended
      .SelectionMode = sgSelectionModeAll

      SGGrid1.Selection.Ranges.Add sgRangeFree, 1, 7, 2, 10
      SGGrid1.Selection.Ranges.Add sgRangeFree, 2, 4, 2, 4
      SGGrid1.Selection.Ranges.Add sgRangeRow, 0, 2, 0, 2
      SGGrid1.Selection.Ranges.Add sgRangeColumn, 4, 0, 4, 0

   End With

   Command1_Click
End Sub

Back to topic


Type Property (SGRange Object)

Type Property (SGRange Object)
Returns range type.

Read-only at run time. Not available at design time.

Syntax

object.Type As sgRangeType

The object placeholder represents an object expression that evaluates to the SGRange object.

Settings

The Type settings are:

Name | Value | Description
sgRangeFree | 0 | Range contains one rectangular cell area.
sgRangeRow | 1 | Range contains one or more successive rows.
sgRangeColumn | 2 | Range contains one or more successive columns.

Remarks

The Type property is determined either by the way how the user makes selection or by the Type parameter of the CreateRange method.

If you apply the SelectAll method of the SGSelection object, the SGRanges collection will contain one item. This item will be type of sgRangeFree.

Show Example
Copy Code [image] Show Me

The following example creates four ranges and applies different style for each ranges type. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim rng As SGRange

   With SGGrid1
      .FitLastColumn = True
      .GroupByBoxVisible = False
      .Columns.RemoveAll False
      .DataRowCount = 12

      With .Columns.Add("Row")
         .HeadingStyle.BackColor = vbYellow
      End With
      With .Columns.Add("Column")
         .HeadingStyle.BackColor = vbGreen
      End With
      With .Columns.Add("Free")
         .HeadingStyle.BackColor = vbMagenta
      End With

      .Columns.Add
      .Columns.Add
      .Columns.Add

      .MultiSelect = sgMultiSelectExtended
      .SelectionMode = sgSelectionModeAll

      SGGrid1.Selection.Ranges.Add sgRangeFree, 1, 7, 2, 10
      SGGrid1.Selection.Ranges.Add sgRangeFree, 2, 4, 2, 4
      SGGrid1.Selection.Ranges.Add sgRangeRow, 0, 2, 0, 2
      SGGrid1.Selection.Ranges.Add sgRangeColumn, 4, 0, 4, 0

   End With

   For Each rng In SGGrid1.Selection.Ranges
      Select Case rng.Type
         Case sgRangeRow
            rng.ApplyStyle SGGrid1.Columns(1).HeadingStyle
         Case sgRangeColumn
            rng.ApplyStyle SGGrid1.Columns(2).HeadingStyle
         Case sgRangeFree
            rng.ApplyStyle SGGrid1.Columns(3).HeadingStyle
      End Select
   Next

   SGGrid1.Selection.Clear
End Sub

Back to topic


SGRange Methods

ApplyStyle | Applies style to rows, columns and/or cells in this range.
GetData | Returns data as a string.
Redraw | Redraws cells in the range.
SetData | Replaces cell data with data specified in parameter. Cell values are separated with separator.


ApplyStyle Method (SGRange Object)

ApplyStyle Method (SGRange Object)
Applies style to rows, columns and/or cells in this range.
Syntax

object.ApplyStyle(Style As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGRange object.
Style | A Variant expression that represents the style to apply. Could be either the SGStyle object or Name.

Remarks

To create ranges use either the CreateRange method or the Add method of the SGRanges collection.

The code below shows how to apply style to the range:

   With SGGrid1.CreateRange(sgRangeFree, 1, 1, 1, 1)
      .ApplyStyle SGGrid1.Styles("Heading")
   End With

-or-

   With SGGrid1.Selection.Ranges(0)
      .ApplyStyle "Heading"
   End With

Show Example
Copy Code [image] Show Me

The following example applies the heading style to the all selected cells. To try the example, place a SGGrid and CommandButton on a form. Paste the code into the Declarations section, press F5, select and click button.

Private Sub Command1_Click()
   Dim rng As SGRange

   For Each rng In SGGrid1.Selection.Ranges
      rng.ApplyStyle "Heading"
   Next
   'remove selection
   SGGrid1.Selection.Clear
End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.SelectionMode = sgSelectionByRow
   SGGrid1.Selection.Ranges.Add _
      sgRangeRow, 0, 2, 0, 2
End Sub

Back to topic


GetData Method (SGRange Object)

GetData Method (SGRange Object)
Returns data as a string.
Syntax

object.GetData(Format As sgDataFormat, [Flags = sgExportDefault] As sgExportFlag, [CellSeparator = ","] As String, [RowSeparator = ""] As String)

Return Value A String value containing the range's data.
Arguments
object | An object expression that evaluates to the SGRange object.
Format | An sgDataFormat expression that specifies the data format. The possible values are listed in Settings.
Flags | Optional. An sgExportFlag expression that sets options for a data export. Default value is sgExportDefault. The possible values are listed in Settings.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Default value is ",". Used only if the DataFormat is sgFormatCharSeparatedValue.
RowSeparator | Optional. A String expression that sets delimiter used between rows. Default value is an empty string which is interpreted as a line separator (vbCrLf). Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for Flags are:

Name | Value | Description
sgExportDefault | 0 | Use default export flags.
sgExportCurrentRowOnly | 1 | Export current row only.
sgExportFieldNames | 2 | Export field names.
sgExportRowsOnly | 4 | Export only data rows.
sgExportHidden | 8 | Hidden columns will appear in exported data.
sgExportOverwrite | 16 | Replace file if it already exists.
sgExportAppend | 32 | Append to file if it already exists.
The settings for Format are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

The GetData method returns cell data separated with separator. This method could be useful for the Drag-and-Drop and/or copy operations.

Show Example
Copy Code [image] Show Me

Private Sub SGGrid1_OLEDragDrop _
   (ByVal Data As IsgDataObject, _
   Effect As Long, ByVal Button As Integer, _
   ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
   Dim rng As SGRange, sData As String
   Dim iRangeWidth As Integer, iRangeHeight As Integer
   Dim lLeft&, lTop&, lRight&, lBottom&
   Dim oCell As Variant

   If SGGrid1.HitTestObject(x, y, oCell) <> sgHitCell Then Exit Sub

   With SGGrid1.Selection.Ranges(0)
      iRangeWidth = .RightCol - .LeftCol
      iRangeHeight = .BottomRow - .TopRow
      sData = .GetData(sgFormatCharSeparatedValue, sgExportDefault, , "#")
   End With

   lLeft = oCell.Column.Position
   lTop = oCell.Row.Position

   lRight = iRangeWidth + lLeft
   If lRight > SGGrid1.DataColCount Then SGGrid1.DataColCount = lRight
   lBottom = iRangeHeight + lTop
   If lBottom > SGGrid1.DataRowCount Then SGGrid1.DataRowCount = lBottom

   Set rng = SGGrid1.CreateRange(sgRangeFree, _
      lLeft, lTop, lRight, lBottom)

   rng.SetData sData, sgFormatCharSeparatedValue, ",", "#"

   Set rng = Nothing
   SGGrid1.Redraw

End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .OLEDragMode = sgOLEDragModeAutomatic
      .OLEDropMode = sgOLEDropModeManual
      .SelectionMode = sgSelectionFree
      .Columns.RemoveAll False
      .DataColCount = 10
      .DataRowCount = 20
      .Array(0, 0) = "Select": .Array(0, 1) = "this"
      .Array(0, 2) = "cells": .Array(1, 0) = "end"
      .Array(1, 1) = "drag them": .Array(1, 2) = "somewhere"
   End With
End Sub

Back to topic


Redraw Method (SGRange Object)

Redraw Method (SGRange Object)
Redraws cells in the range.
Syntax | object.Redraw
Return Value | None
Arguments | None

Remarks

The method is ignored if the RedrawEnabled property is set to False.

See Also

SGRange


SetData Method (SGRange Object)

SetData Method (SGRange Object)
Replaces cell data with data specified in parameter. Cell values are separated with separator.
Syntax

object.SetData(Data As String, Format As sgDataFormat, [CellSeparator = ","] As String, [RowSeparator = ""] As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGRange object.
Data | A String expression that contains cells data separated with separator.
Format | A sgDataFormat expression that ...
CellSeparator | Optional. A String expression that ... Default value is ",".
RowSeparator | Optional. A String expression that ... Default value is "".

Settings

The settings for Format are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

The SetData method replaces cell data with data specified in the Data parameter. Cell values are separated with separator. This method could be useful for the Drag-and-Drop or paste operations.

Show Example
Copy Code [image] Show Me

Private Sub SGGrid1_OLEDragDrop _
   (ByVal Data As IsgDataObject, _
   Effect As Long, ByVal Button As Integer, _
   ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
   Dim rng As SGRange, sData As String
   Dim iRangeWidth As Integer, iRangeHeight As Integer
   Dim lLeft&, lTop&, lRight&, lBottom&
   Dim oCell As Variant

   If SGGrid1.HitTestObject(x, y, oCell) <> sgHitCell Then Exit Sub

   With SGGrid1.Selection.Ranges(0)
      iRangeWidth = .RightCol - .LeftCol
      iRangeHeight = .BottomRow - .TopRow
      sData = .GetData(sgFormatCharSeparatedValue, sgExportDefault, , "#")
   End With

   lLeft = oCell.Column.Position
   lTop = oCell.Row.Position

   lRight = iRangeWidth + lLeft
   If lRight > SGGrid1.DataColCount Then SGGrid1.DataColCount = lRight
   lBottom = iRangeHeight + lTop
   If lBottom > SGGrid1.DataRowCount Then SGGrid1.DataRowCount = lBottom

   Set rng = SGGrid1.CreateRange(sgRangeFree, _
      lLeft, lTop, lRight, lBottom)

   rng.SetData sData, sgFormatCharSeparatedValue, ",", "#"

   Set rng = Nothing
   SGGrid1.Redraw

End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .OLEDragMode = sgOLEDragModeAutomatic
      .OLEDropMode = sgOLEDropModeManual
      .SelectionMode = sgSelectionFree
      .Columns.RemoveAll False
      .DataColCount = 10
      .DataRowCount = 20
      .Array(0, 0) = "Select": .Array(0, 1) = "this"
      .Array(0, 2) = "cells": .Array(1, 0) = "end"
      .Array(1, 1) = "drag them": .Array(1, 2) = "somewhere"
   End With
End Sub

Back to topic


SGRanges Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGRanges Object

Name: | SGRanges
Description: | Collection of SGRange objects.
GUID: | {D96465D3-DB03-11D2-8F2C-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example makes cross selection over the grid. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim i As Integer
   Dim j As Integer

   SGGrid1.DataColCount = 10
   SGGrid1.DataRowCount = 20

   SGGrid1.Selection.Clear

   For i = SGGrid1.HeadingRowCount To SGGrid1.Rows.Count
      For j = SGGrid1.HeadingColCount To _
         SGGrid1.Columns.Count - 1 Step 2
         SGGrid1.Selection.Ranges.Add _
            sgRangeFree, j + i Mod 2, i, j + i Mod 2, i
      Next
   Next
End Sub

Back to topic

Referenced By

SGSelection.Ranges


SGRanges Properties

Count | Returns the number of SGRange objects in the collection
Grid | Returns parent SGGrid object.
Item | Returns specified range object


SGRanges Methods

Add | Adds new SGRange object to the collection and returns a reference to the newly created object.
Remove | Removes specified range from the collection.
RemoveAll | Removes all ranges from the collection.


Add Method (SGRanges Collection)

Add Method (SGRanges Collection)
Adds new SGRange object to the collection and returns a reference to the newly created object.
Syntax

object.Add(Type As sgRangeType, Left As Long, Top As Long, Right As Long, Bottom As Long)

Return Value A SGRange object.
Arguments
object | An object expression that evaluates to the SGRanges object.
Type | An sgRangeType expression that specifies type of the range. The possible values are listed in Settings.
Left | A Long expression that sets the zero-based position of the leftmost column in the range. This argument is ignored if argument Type is set to sgRangeRow.
Top | A Long expression that sets the zero-based position of the top row in the range. This argument is ignored if argument Type is set to sgRangeColumn.
Right | A Long expression that sets the zero-based position of the right column in the range. This argument is ignored if argument Type is set to sgRangeRow.
Bottom | A Long expression that sets the zero-based position of the bottom row in the range. This argument is ignored if argument Type is set to sgRangeColumn.

Settings

The settings for Type are:

Name | Value | Description
sgRangeFree | 0 | Range contains one rectangular cell area.
sgRangeRow | 1 | Range contains one or more successive rows.
sgRangeColumn | 2 | Range contains one or more successive columns.

Remarks

Use this method to create new selection range.

Note: the SelectionMode property doesn't effect this method. Even if it's set to sgSelectionNone you can make selection from the code.

You can use the CreateRange method to create a range that doesn't effect the SGSelection object.

Show Example
Copy Code [image] Show Me

The following example makes cross selection over the grid. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim i As Integer
   Dim j As Integer

   SGGrid1.DataColCount = 10
   SGGrid1.DataRowCount = 20

   SGGrid1.Selection.Clear

   For i = SGGrid1.HeadingRowCount To SGGrid1.Rows.Count
      For j = SGGrid1.HeadingColCount To _
         SGGrid1.Columns.Count - 1 Step 2
         SGGrid1.Selection.Ranges.Add _
            sgRangeFree, j + i Mod 2, i, j + i Mod 2, i
      Next
   Next
End Sub

Back to topic


Remove Method (SGRanges Collection)

Remove Method (SGRanges Collection)
Removes specified range from the collection.
Syntax

object.Remove(Index As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGRanges object.
Index | An integer that uniquely identifies the object within the collection.

Remarks

To remove all SGRange objects from the SGRanges collection use the RemoveAll method.

Show Example
Copy Code [image] Show Me

The following example removes first range from the grid.

Private Sub Command1_Click()

   If SGGrid1.Selection.Ranges.Count = 0 Then Exit Sub
   SGGrid1.Selection.Ranges.Remove 0
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


RemoveAll Method (SGRanges Collection)

RemoveAll Method (SGRanges Collection)
Removes all ranges from the collection.
Syntax | object.RemoveAll
Return Value | None
Arguments | None

Remarks

To remove a particular SGRange object from the SGRanges collection use the Remove method.


SGRow Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGRow Object

Name: | SGRow
Description: | SGRow is object that represents one grid row.
GUID: | {ACAE77F2-E214-11D2-8F41-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example shows how to use BeeGrid like Vertical Menu.

Private Sub ScrollRows(CurrRow As SGRow)
   Dim row As SGRow

   For Each row In SGGrid1.Rows
      row.Style = "Heading"
      row.Height = 300
      row.Style.TextAlignment = sgAlignCenterCenter
      row.Style.DisplayType = sgDisplayText
      row.Cells(0).Value = row.Position + 1
   Next

   With CurrRow
      .Height = SGGrid1.ClientHeight - 4 * 300
      .Style = "Normal"
      .Style.DisplayType = sgDisplayPicture
      .Style.PictureAlignment = sgPicAlignTile
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim row As SGRow

   SGGrid1.RedrawEnabled = False
   'misc stuff
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.Width = 1200
   SGGrid1.ScrollBars = sgSBNone
   SGGrid1.FocusRect = sgFocusRectNone
   SGGrid1.FitLastColumn = True
   'cols and row creation
   SGGrid1.Columns.RemoveAll True
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DataRowCount = 5
   SGGrid1.DataColCount = 1

   With SGGrid1.Columns.At(0)
      For i = 1 To 5
         .ValueItems.Add i, "Row " & Trim(i), sgbipFirst + i + 3
      Next
   End With

   ScrollRows SGGrid1.Rows.At(2)
   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_MouseDown _
   (Button As Integer, Shift As Integer, _
   x As Single, y As Single)
   Dim cell As Variant

   If SGGrid1.HitTestObject(x, y, cell) = sgHitCell Then
      If cell.row.Style = "Normal" Then Exit Sub
      ScrollRows cell.row
   End If
End Sub

Back to topic

Referenced By


SGRow Properties

AllowFocus | Returns or sets a value indicating whether a row can receive focus.
AllowSizing | Returns or sets a value indicating whether a user can resize a row.
Bookmark | Returns or sets row's bookmark.
Bottom | Returns the position of the row's bottom edge.
Cells | Returns the collection of row cells.
DataIndex | Returns an absolute database index of the bound record.
Expanded | Returns True if this row is expanded.
Frozen | Returns or sets a value indicating whether the row is frozen.
Grid | Returns parent SGGrid object.
GroupHeading | Returns row as an SGGroupHeading object.
Heading | Returns true if row is heading row.
Height | Returns or sets row's height.
Hidden | Determines whether the row is hidden or not.
Key | Returns row's key.
OutlineLevel | Returns row's outline level.
Parent | Returns parent SGGroupHeading object.
Position | Returns or sets row position. Zero-based.
Status | Returns the row's status bits.
Style | Returns the SGStyle object associated with the row.
Tag | Returns or sets user defined value associated with the grid row.
Top | Returns the position of the row's top edge.
Type | Returns row's type.
Visible | Returns whether a row is currently within view.


AllowFocus Property (SGRow Object)

AllowFocus Property (SGRow Object)
Returns or sets a value indicating whether a row can receive focus.

Read/Write at run time. Not available at design time.

Syntax

object.AllowFocus As Boolean

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

If this property is False, the user will not be able to set the focus to this row, either with the mouse or with the keyboard.

Show Example
Copy Code [image] Show Me

The following example sums all rows and display result in the last row. The last column is unbound and it displays sum of other columns. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim cell As SGCell
   Dim col As SGColumn

   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   'create cols and rows
   SGGrid1.DataColCount = 4
   SGGrid1.DataRowCount = 5

   SGGrid1.GroupByBoxVisible = False
   'set col data type
   For Each col In SGGrid1.Columns
      col.DataType = sgtDouble
   Next
   'the last row display calculation of other rows
   'calculation is implemented in the AfterEdit event
   With SGGrid1.Rows.At(SGGrid1.DataRowCount)
      .AllowSizing = False
      .AllowFocus = False
      .Style = "Heading"
   End With
   'calculate columns at last column
   With SGGrid1.Columns.At(SGGrid1.DataColCount)
      .AllowSizing = False
      .AllowFocus = False
      .Style = "Heading"
      .DBField = ""        'unbound column
   End With
   'add some data
   SGGrid1.Array.Value(0, 0) = 100
   SGGrid1.Array.Value(0, 1) = 200
   SGGrid1.Array.Value(1, 0) = 200
   'calculate sub for new data
   SGGrid1_AfterEdit SGGrid1.Rows.At(SGGrid1.DataRowCount).Key, 1
End Sub

Private Sub SGGrid1_AfterEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long)
   Dim i As Integer, j As Integer
   Dim iColDBIndex As Long
   Dim dblColSum As Double
   Dim ar As SGArray

   Set ar = SGGrid1.Array
   'sum rows in a each column
   For i = 0 To ar.ColCount - 1
      dblColSum = 0
      For j = 0 To ar.RowCount - 2
         dblColSum = dblColSum + ar.Value(j, i)
      Next
      'display sum in the last row
      ar.Value(ar.RowCount - 1, i) = dblColSum
   Next
   'redraw last row
   SGGrid1.Rows.At(SGGrid1.DataRowCount).Redraw
End Sub

Private Sub SGGrid1_FetchColumnData _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal RowBookmark As Variant, Value As Variant)
   Dim lRowDBIndex As Long
   Dim i As Integer
   'sum bounded columns and display result
   'in the last column
   lRowDBIndex = SGGrid1.Rows(RowKey).DataIndex

   For i = 0 To SGGrid1.Array.ColCount - 1
      Value = Value + Val(SGGrid1.Array.Value(lRowDBIndex, i))
   Next
End Sub

Back to topic


AllowSizing Property (SGRow Object)

AllowSizing Property (SGRow Object)
Returns or sets a value indicating whether a user can resize a row.

Read/Write at run time. Not available at design time.

Syntax

object.AllowSizing As Boolean

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

If this property is True, the mouse pointer turns into a "Size N-S" arrow when positioned over the divider of the specified row. The user can resize the row by dragging or auto-resize by double-clicking.

Show Example
Copy Code [image] Show Me

The following example sums all rows and display result in the last row. The last column is unbound and it displays sum of other columns. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim cell As SGCell
   Dim col As SGColumn

   SGGrid1.EnterKeyBehavior = sgEnterKeyColumns
   'create cols and rows
   SGGrid1.DataColCount = 4
   SGGrid1.DataRowCount = 5

   SGGrid1.GroupByBoxVisible = False
   'set col data type
   For Each col In SGGrid1.Columns
      col.DataType = sgtDouble
   Next
   'the last row display calculation of other rows
   'calculation is implemented in the AfterEdit event
   With SGGrid1.Rows.At(SGGrid1.DataRowCount)
      .AllowSizing = False
      .AllowFocus = False
      .Style = "Heading"
   End With
   'calculate columns at last column
   With SGGrid1.Columns.At(SGGrid1.DataColCount)
      .AllowSizing = False
      .AllowFocus = False
      .Style = "Heading"
      .DBField = ""        'unbound column
   End With
   'add some data
   SGGrid1.Array.Value(0, 0) = 100
   SGGrid1.Array.Value(0, 1) = 200
   SGGrid1.Array.Value(1, 0) = 200
   'calculate sub for new data
   SGGrid1_AfterEdit SGGrid1.Rows.At(SGGrid1.DataRowCount).Key, 1
End Sub

Private Sub SGGrid1_AfterEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long)
   Dim i As Integer, j As Integer
   Dim iColDBIndex As Long
   Dim dblColSum As Double
   Dim ar As SGArray

   Set ar = SGGrid1.Array
   'sum rows in a each column
   For i = 0 To ar.ColCount - 1
      dblColSum = 0
      For j = 0 To ar.RowCount - 2
         dblColSum = dblColSum + ar.Value(j, i)
      Next
      'display sum in the last row
      ar.Value(ar.RowCount - 1, i) = dblColSum
   Next
   'redraw last row
   SGGrid1.Rows.At(SGGrid1.DataRowCount).Redraw
End Sub

Private Sub SGGrid1_FetchColumnData _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal RowBookmark As Variant, Value As Variant)
   Dim lRowDBIndex As Long
   Dim i As Integer
   'sum bounded columns and display result
   'in the last column
   lRowDBIndex = SGGrid1.Rows(RowKey).DataIndex

   For i = 0 To SGGrid1.Array.ColCount - 1
      Value = Value + Val(SGGrid1.Array.Value(lRowDBIndex, i))
   Next
End Sub

Back to topic


Bookmark Property (SGRow Object)

Bookmark Property (SGRow Object)
Returns or sets row's bookmark.

Read-only at run time. Not available at design time.

Syntax

object.Bookmark As Variant

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

Use the Bookmark property to save the position of the current row and return to that row at any time.

Bookmarks are empty if the grid is bound to the recordset that doesn't support bookmark functionality.

In the unbound mode, bookmarks are same as row's DataIndex.

The sgVirtualInterface data mode doesn't support bookmarks.


Bottom Property (SGRow Object)

Bottom Property (SGRow Object)
Returns the position of the row's bottom edge.

Read-only at run time. Not available at design time.

Syntax

object.Bottom As OLE_YPOS_CONTAINER

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

The Bottom property is specified in terms of the container's coordinate system.

Row's Top and Bottom properties are valid only for completely visible rows. This property returns -1, if the row is not visible.


Cells Property (SGRow Object)

Cells Property (SGRow Object)
Returns the collection of row cells.

Read-only at run time. Not available at design time.

Syntax

object.Cells As IsgCells

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

Show Example
Copy Code [image] Show Me

The following example uses the RowHeadClick event to sort columns by cells value in the clicked row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Click on the any row head.

Private Sub SGGrid1_RowHeadClick(ByVal RowKey As Long)
   Dim row As SGRow, i As Integer
   Dim j As Integer, iMinValue As Integer
   Dim lVal1 As Long, lVal2 As Long
   'stop drawing
   SGGrid1.RedrawEnabled = False
   'reference the current row
   Set row = SGGrid1.Rows(RowKey)
   'sort columns by values from the current row
   For i = 1 To SGGrid1.DataColCount
      iMinValue = i
      For j = i To SGGrid1.DataColCount
         lVal1 = CLng(row.Cells(j).Value)
         lVal2 = CLng(row.Cells(iMinValue).Value)
         If lVal1 < lVal2 Then iMinValue = j
      Next

      If iMinValue > i Then
         row.Cells(iMinValue).Column.Position = i
      End If
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim ar As SGArray, lRndNum As Long
   'create cols and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DefaultColWidth = 505
   SGGrid1.DataColCount = 7
   SGGrid1.DataRowCount = 12

   SGGrid1.GroupByBoxVisible = False
   'add random numbers
   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         lRndNum = CLng(Rnd * 255)
         ar.Value(i, j) = lRndNum
         'paint cells
         SGGrid1.CellAt(i + 1, j + 1).Style.BackColor = _
            RGB(255 - lRndNum, 255, 255)
      Next
   Next

   Set ar = Nothing
End Sub

Back to topic


DataIndex Property (SGRow Object)

DataIndex Property (SGRow Object)
Returns an absolute database index of the bound record.

Read-only at run time. Not available at design time.

Syntax

object.DataIndex As Long

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

See Also

SGRow


Expanded Property (SGRow Object)

Expanded Property (SGRow Object)
Returns True if this row is expanded.
Syntax

object.Expanded As Boolean

The object placeholder represents an object expression that evaluates to the SGRow object.

See Also

SGRow


Frozen Property (SGRow Object)

Frozen Property (SGRow Object)
Returns or sets a value indicating whether the row is frozen.

Read/Write at run time. Not available at design time.

Syntax

object.Frozen As Boolean

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

The Frozen property controls row's "freeze" state. When a row is "frozen", it remains visible when the user scrolls vertically. Frozen row is positioned at the top side of the grid and value of its Position property is always smaller than the value of the control's FrozenRowCount property.
The code below freezes two rows:

Private Sub Form_Load()
   SGGrid1.DataRowCount = 10

   With SGGrid1.Rows.At(5)
      .Cells(1).Value = "Frozen 1"
      .Frozen = True
   End With

   With SGGrid1.Rows.At(2)
      .Cells(1).Value = "Frozen 2"
      .Frozen = True
   End With
End Sub

Use the "Frozen" style to change appearance of the frozen rows.

Show Example
Copy Code [image] Show Me

The following example fills the grid with test data, freezes the first row and col and applies the heading style to them. Press the command button to freeze additional rows and cols. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   If SGGrid1.FrozenColCount > 3 Then
      SGGrid1.Columns.At(SGGrid1.FrozenColCount).Frozen = False
      SGGrid1.Rows.At(SGGrid1.FrozenRowCount).Frozen = False
   Else
      SGGrid1.Columns.At(SGGrid1.FrozenColCount + 1).Frozen = True
      SGGrid1.Rows.At(SGGrid1.FrozenRowCount + 1).Frozen = True
   End If
End Sub

Private Sub Form_Load()
   Dim ar As SGArray
   Dim i&, j&

   'assign grid array to variable
   Set ar = SGGrid1.Array

   SGGrid1.RowNumbering = True

   SGGrid1.DataColCount = 20
   SGGrid1.DataRowCount = 100
   'load test data
   For i = 0 To SGGrid1.DataColCount - 1
      SGGrid1.Columns.At(i).Caption = "Col " & Trim(i)
      For j = 0 To SGGrid1.DataRowCount - 1
         ar.Value(j, i) = "Row=" & j & " Col=" & i
      Next
   Next

   'make two first cols and rows frozen and
   'apply the Heading to them
   SGGrid1.GridLines = SGGrid1.HeadingGridLines
   SGGrid1.Styles("Frozen").CopyFrom SGGrid1.Styles("Heading")

   SGGrid1.Columns.At(1).Frozen = True
   SGGrid1.Rows.At(1).Frozen = True

   Set ar = Nothing
End Sub

Back to topic


GroupHeading Property (SGRow Object)

GroupHeading Property (SGRow Object)
Returns row as an SGGroupHeading object.

Read-only at run time. Not available at design time.

Syntax

object.GroupHeading As IsgGroupHeading

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

If row is not a group heading row, this property returns Nothing.

See Also

SGRow


Heading Property (SGRow Object)

Heading Property (SGRow Object)
Returns true if row is heading row.

Read-only at run time. Not available at design time.

Syntax

object.Heading As Boolean

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

Use the HeadingRowCount property to add/remove heading rows.

Show Example
Copy Code [image] Show Me

The following example fills the grid with sample data grouped in two groups. Click on the button to show rows with value less then 10000. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim row As SGRow

   SGGrid1.CollapseAll

   For Each row In SGGrid1.Rows
      'check only simple rows
      If row.Type = sgSimpleRow And Not row.Heading Then
         If row.Cells(2).Value < 10000 Then
            row.Hidden = False
         End If
      End If
   Next
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   'misc stuff
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.FitLastColumn = True
   'create columns
   SGGrid1.Columns.RemoveAll

   SGGrid1.Columns.Add("EvenOdd").Hidden = True
   SGGrid1.Columns.Add("ModSeven").Hidden = True

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 120
   'add random numbers
   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue Mod 7
      ar.Value(i, 2) = lRndValue
   Next
   'group by the first column
   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrCaptionAndValue
   'group by the second column
   SGGrid1.Groups.Add "ModSeven", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic


Height Property (SGRow Object)

Height Property (SGRow Object)
Returns or sets row's height.

Read-only at run time. Not available at design time.

Syntax

object.Height As OLE_YSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

The Height property is specified in terms of the container's coordinate system.

Show Example
Copy Code [image] Show Me

The following example shows how to use BeeGrid like Vertical Menu.

Private Sub ScrollRows(CurrRow As SGRow)
   Dim row As SGRow

   For Each row In SGGrid1.Rows
      row.Style = "Heading"
      row.Height = 300
      row.Style.TextAlignment = sgAlignCenterCenter
      row.Style.DisplayType = sgDisplayText
      row.Cells(0).Value = row.Position + 1
   Next

   With CurrRow
      .Height = SGGrid1.ClientHeight - 4 * 300
      .Style = "Normal"
      .Style.DisplayType = sgDisplayPicture
      .Style.PictureAlignment = sgPicAlignTile
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim row As SGRow

   SGGrid1.RedrawEnabled = False
   'misc stuff
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.Width = 1200
   SGGrid1.ScrollBars = sgSBNone
   SGGrid1.FocusRect = sgFocusRectNone
   SGGrid1.FitLastColumn = True
   'cols and row creation
   SGGrid1.Columns.RemoveAll True
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DataRowCount = 5
   SGGrid1.DataColCount = 1

   With SGGrid1.Columns.At(0)
      For i = 1 To 5
         .ValueItems.Add i, "Row " & Trim(i), sgbipFirst + i + 3
      Next
   End With

   ScrollRows SGGrid1.Rows.At(2)
   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_MouseDown _
   (Button As Integer, Shift As Integer, _
   x As Single, y As Single)
   Dim cell As Variant

   If SGGrid1.HitTestObject(x, y, cell) = sgHitCell Then
      If cell.row.Style = "Normal" Then Exit Sub
      ScrollRows cell.row
   End If
End Sub

Back to topic

See Also

SGRow


Hidden Property (SGRow Object)

Hidden Property (SGRow Object)
Determines whether the row is hidden or not.

Read/Write at run time. Not available at design time.

Syntax

object.Hidden As Boolean

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

Hidden row is a row that is not displayed. To hide a row, you can set the Hidden property to True. In addition, the user can hide a row by dragging its heading away. You can prevent users from hiding rows by setting the control's UserHiding property to sgNoRowColHide or sgAllowColHide.

Don't confuse the Hidden and the Visible properties. If a particular row has been scrolled out of the view, its Hidden property remains True. But, a row is not visible any more and thus, its Visible property changes to False.


Key Property (SGRow Object)

Key Property (SGRow Object)
Returns row's key.

Read-only at run time. Not available at design time.

Syntax

object.Key As Long

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

Each row in the BeeGrid control has the unique key assigned to it. Use that key to uniquely identify any row. The key is assigned to the row when row is created and it never changes during row's lifetime.

See Also

SGRow


OutlineLevel Property (SGRow Object)

OutlineLevel Property (SGRow Object)
Returns row's outline level.

Read-only at run time. Not available at design time.

Syntax

object.OutlineLevel As Long

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

The OutlineLevel property is zero-based number that represents row's indentation level. If grid is not grouped, outline level for all rows is zero.

See Also

SGRow


Parent Property (SGRow Object)

Parent Property (SGRow Object)
Returns parent SGGroupHeading object.

Read-only at run time. Not available at design time.

Syntax

object.Parent As IsgGroupHeading

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

If row is not a child row, this property returns Nothing.


Position Property (SGRow Object)

Position Property (SGRow Object)
Returns or sets row position. Zero-based.

Read/Write at run time. Not available at design time.

Syntax

object.Position As Long

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

You can use the SGRows collection's At method to refer to a row if you know its position.

See Also

SGRow


Status Property (SGRow Object)

Status Property (SGRow Object)
Returns the row's status bits.

Read-only at run time. Not available at design time.

Syntax

object.Status As sgRowStatus

The object placeholder represents an object expression that evaluates to the SGRow object.

Settings

The Status settings are:

Name | Value | Description
sgRowStatusNormal | 0 | No special status.
sgRowStatusCurrent | 1 | Row is current (focused) row.
sgRowStatusDataChanged | 2 | Row content has changed but has not yet been written to the database.
sgRowStatusFiltered | 4 | Row does not meet the filter condition.
sgRowStatusHidden | 8 | Row is hidden.
sgRowStatusSelected | 16 | Row is currently selected.
sgRowStatusReadOnly | 32 | Row is read-only.
sgRowStatusExpanded | 64 | Row is group header and child rows are expanded.
sgRowStatusCollapsed | 128 | Row is collapsed child row.

Remarks

Always mask value from the Status property. For example, a row can be member of the current row and can be expanded. In that case its status is 65 (sgRowStatusCurrent + sgRowStatusExpanded).
The code below demonstrates how to check if a row is current:

   If SGGrid1.Rows.At(1).Status And sgRowStatusCurrent Then
    ...
   End If


Style Property (SGRow Object)

Style Property (SGRow Object)
Returns the SGStyle object associated with the row.

Read-only at run time. Not available at design time.

Syntax

object.Style As IsgStyle

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

Row's style has lower priority then column's and cell's styles.

Show Example
Copy Code [image] Show Me

The following example demonstrates relation between row's and column's styles. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .DataColCount = 5
      .DataRowCount = 5
      .Rows.At(3).Style.BackColor = vbGreen
      .Columns.At(3).Style.BackColor = vbRed
   End With
End Sub

Back to topic


Tag Property (SGRow Object)

Tag Property (SGRow Object)
Returns or sets user defined value associated with the grid row.

Read/Write at run time. Not available at design time.

Syntax

object.Tag As Variant

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

Returns or sets an expression that stores any extra data needed for a row.

Show Example
Copy Code [image] Show Me

The following example sets a row tag to New when a new row is added. Click a button to paint new rows to green. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button. Add few rows and press a button.

Private Sub Command1_Click()
   Dim row As SGRow

   For Each row In SGGrid1.Rows
      If row.Tag = "New" Then
         row.Style.BackColor = vbGreen
         row.Redraw
      End If
   Next
End Sub

Private Sub SGGrid1_AfterInsert()
   SGGrid1.Rows.Current.Tag = "New"
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Long, j As Integer

   SGGrid1.AllowAddNew = True

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         SGGrid1.Array.Value(i, j) = "Row ->" & i
      Next j, i
End Sub

Back to topic

See Also

SGRow


Top Property (SGRow Object)

Top Property (SGRow Object)
Returns the position of the row's top edge.

Read-only at run time. Not available at design time.

Syntax

object.Top As OLE_YPOS_CONTAINER

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

The Top property is specified in terms of the container's coordinate system.

Row's Top and Bottom properties are valid only for completely visible rows. This property returns -1, if the row is not visible.

See Also

SGRow


Type Property (SGRow Object)

Type Property (SGRow Object)
Returns row's type.

Read-only at run time. Not available at design time.

Syntax

object.Type As sgRowType

The object placeholder represents an object expression that evaluates to the SGRow object.

Settings

The Type settings are:

Name | Value | Description
sgSimpleRow | 0 | Standard row.
sgGroupHeader | 1 | Group header.
sgGroupFooter | 2 | Group footer.

Remarks

Show Example
Copy Code [image] Show Me

The following example fills the grid with sample data grouped in two groups. Click on the button to show rows with value less then 10000. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim row As SGRow

   SGGrid1.CollapseAll

   For Each row In SGGrid1.Rows
      'check only simple rows
      If row.Type = sgSimpleRow And Not row.Heading Then
         If row.Cells(2).Value < 10000 Then
            row.Hidden = False
         End If
      End If
   Next
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, i As Integer
   Dim lRndValue As Long

   'misc stuff
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.FitLastColumn = True
   'create columns
   SGGrid1.Columns.RemoveAll

   SGGrid1.Columns.Add("EvenOdd").Hidden = True
   SGGrid1.Columns.Add("ModSeven").Hidden = True

   With SGGrid1.Columns.Add("Number")
      .Caption = "Number"
      .HeadingStyle.TextAlignment = sgAlignCenterCenter
      .Style.TextAlignment = sgAlignCenterCenter
      .Style.Format = Chr(34) & "--->  " & Chr(34) & "#,##0" & _
         Chr(34) & "  <---" & Chr(34)
   End With

   SGGrid1.DataRowCount = 120
   'add random numbers
   Set ar = SGGrid1.Array

   Randomize

   For i = 0 To SGGrid1.DataRowCount - 1
      lRndValue = CLng(Rnd * 120000)

      ar.Value(i, 0) = lRndValue Mod 2
      ar.Value(i, 1) = lRndValue Mod 7
      ar.Value(i, 2) = lRndValue
   Next
   'group by the first column
   SGGrid1.Groups.Add "EvenOdd", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.Groups(1).HeaderTextSource = sgGrpHdrCaptionAndValue
   'group by the second column
   SGGrid1.Groups.Add "ModSeven", sgSortAscending, _
      sgSortTypeNumber, False, False

   SGGrid1.RefreshGroups
   SGGrid1.CollapseAll

   Set ar = Nothing
End Sub

Back to topic


Visible Property (SGRow Object)

Visible Property (SGRow Object)
Returns whether a row is currently within view.

Read-only at run time. Not available at design time.

Syntax

object.Visible As Boolean

The object placeholder represents an object expression that evaluates to the SGRow object.

Remarks

The Visible property indicates whether a row is currently visible. This property returns False if a particular row has been scrolled out of view. In addition, it will return False if row's Hidden property is set to True.

Don't confuse the Hidden and the Visible properties. If a particular row has been scrolled out of the view, its Hidden property remains True. However, a row is not visible any more and thus, its Visible property changes to False.


SGRow Methods

AutoSize | Resize row to fit cell content.
Collapse | Collapses this row.
Expand | Expands this row.
GetData | Returns row data as a string.
Redraw | Redraws row.
SetData | Replaces row data with data specified in parameter. Cell values are separated with separator.


AutoSize Method (SGRow Object)

AutoSize Method (SGRow Object)
Resize row to fit cell content.
Syntax | object.AutoSize
Return Value | None
Arguments | None

Remarks

The AutoSize method resizes a specified row height to fit cell content. You can use the AutoSizeRows method to resize all rows.


Collapse Method (SGRow Object)

Collapse Method (SGRow Object)
Collapses this row.
Syntax | object.Collapse
Return Value | None
Arguments | None


Expand Method (SGRow Object)

Expand Method (SGRow Object)
Expands this row.
Syntax

object.Expand([Levels = -1] As Integer)

Return Value None
Arguments
object | An object expression that evaluates to the SGRow object.
Levels | Optional. An Integer expression that specifies the number of levels to expand. Default value is -1, which expands all levels.

Remarks


GetData Method (SGRow Object)

GetData Method (SGRow Object)
Returns row data as a string.
Syntax

object.GetData(Format As sgDataFormat, [CellSeparator = ","] As String)

Return Value A String value containing the row's data.
Arguments
object | An object expression that evaluates to the SGRow object.
Format | An sgDataFormat expression that specifies the data format. The possible values are listed in Settings.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Default value is ",". Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for Format are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

The GetData method returns a string that contains row data.

Show Example
Copy Code [image] Show Me

The following example shows how to use the OLESetData event to control data for drag-drop.

Private Sub SGGrid1_OLESetData( _
   ByVal Data As IsgDataObject, _
   dataFormat As Integer)
   Dim rng As SGRange, i As Integer
   Dim sData As String, sgCol As SGColumn

   Data.Clear

   For Each rng In SGGrid1.Selection.Ranges
      For i = rng.TopRow To rng.BottomRow
         sData = sData & SGGrid1.Rows.At(i).GetData _
            (sgFormatCharSeparatedValue, vbTab) & vbCrLf
      Next
   Next

   Set rng = Nothing

   If Len(sData) = 0 Then Exit Sub

   sData = Left$(sData, Len(sData) - 2)
   Data.SetData sData, vbCFText

End Sub

Back to topic


Redraw Method (SGRow Object)

Redraw Method (SGRow Object)
Redraws row.
Syntax | object.Redraw
Return Value | None
Arguments | None

Remarks

The Redraw method has no effect if the control's RedrawEnabled property is set to False.

Show Example
Copy Code [image] Show Me

The following example sets a row tag to New when a new row is added. Click a button to paint new rows to green. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5 and click button. Add few rows and press a button.

Private Sub Command1_Click()
   Dim row As SGRow

   For Each row In SGGrid1.Rows
      If row.Tag = "New" Then
         row.Style.BackColor = vbGreen
         row.Redraw
      End If
   Next
End Sub

Private Sub SGGrid1_AfterInsert()
   SGGrid1.Rows.Current.Tag = "New"
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Long, j As Integer

   SGGrid1.AllowAddNew = True

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         SGGrid1.Array.Value(i, j) = "Row ->" & i
      Next j, i
End Sub

Back to topic

See Also

SGRow


SetData Method (SGRow Object)

SetData Method (SGRow Object)
Replaces row data with data specified in parameter. Cell values are separated with separator.
Syntax

object.SetData(Format As sgDataFormat, RowData As String, [CellSeparator = ","] As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGRow object.
Format | An sgDataFormat expression that specifies the data format. The possible values are listed in Settings.
RowData | A String expression that contains the row data.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Default value is ",". Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for Format are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks


SGRows Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGRows Object

Name: | SGRows
Description: | Collection of all SGRow objects.
GUID: | {ACAE77F3-E214-11D2-8F41-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example shows how to use BeeGrid like Vertical Menu.

Private Sub ScrollRows(CurrRow As SGRow)
   Dim row As SGRow

   For Each row In SGGrid1.Rows
      row.Style = "Heading"
      row.Height = 300
      row.Style.TextAlignment = sgAlignCenterCenter
      row.Style.DisplayType = sgDisplayText
      row.Cells(0).Value = row.Position + 1
   Next

   With CurrRow
      .Height = SGGrid1.ClientHeight - 4 * 300
      .Style = "Normal"
      .Style.DisplayType = sgDisplayPicture
      .Style.PictureAlignment = sgPicAlignTile
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim row As SGRow

   SGGrid1.RedrawEnabled = False
   'misc stuff
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.Width = 1200
   SGGrid1.ScrollBars = sgSBNone
   SGGrid1.FocusRect = sgFocusRectNone
   SGGrid1.FitLastColumn = True
   'cols and row creation
   SGGrid1.Columns.RemoveAll True
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DataRowCount = 5
   SGGrid1.DataColCount = 1

   With SGGrid1.Columns.At(0)
      For i = 1 To 5
         .ValueItems.Add i, "Row " & Trim(i), sgbipFirst + i + 3
      Next
   End With

   ScrollRows SGGrid1.Rows.At(2)
   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_MouseDown _
   (Button As Integer, Shift As Integer, _
   x As Single, y As Single)
   Dim cell As Variant

   If SGGrid1.HitTestObject(x, y, cell) = sgHitCell Then
      If cell.row.Style = "Normal" Then Exit Sub
      ScrollRows cell.row
   End If
End Sub

Back to topic

Referenced By

Rows


SGRows Properties

Count | Returns the number of SGRow objects in the collection
Current | Returns current row object.
First | Returns first non-heading row object.
Grid | Returns parent SGGrid object.
Item | Returns specified grid row object
Last | Returns last row object.


Current Property (SGRows Collection)

Current Property (SGRows Collection)
Returns current row object.

Read-only at run time. Not available at design time.

Syntax

object.Current As IsgRow

The object placeholder represents an object expression that evaluates to the SGRows object.

Remarks

Show Example
Copy Code [image] Show Me

Private Sub EnumGroupHeadings(ghs As SGGroupHeadings)
   Dim gh As SGGroupHeading

   For Each gh In ghs
      Debug.Print gh.Row.Cells(0).Value & _
         " (" & gh.ChildRows.Count & ")"
      EnumGroupHeadings gh.Headings
   Next
End Sub

Private Sub Command1_Click()
   EnumGroupHeadings SGGrid1.GroupHeadings
End Sub

Private Sub SGGrid1_FetchGroupFooterText _
   (ByVal GroupIndex As Integer, _
   ByVal RowKey As Long, Text As String)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).Parent.Row.GroupHeading

   Text = "Average: " & _
      Round(gh.CalculationResult(3), 2) & " Total: " & _
      Round(gh.CalculationResult(4), 2)
End Sub

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading

   Set gh = SGGrid1.Rows(RowKey).GroupHeading

   Text = MonthName(gh.GroupingValue) & " from " & _
      gh.CalculationResult(1) & " to " & gh.CalculationResult(2)
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 1000
   SGGrid1.FitLastColumn = True

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, True, False)
   'use formulas for header and footer text
   grp.HeaderTextSource = sgGrpHdrFireFetchText
   grp.FooterTextSource = sgGrpFooterFireFetchText
   'create calculations
   grp.Calculations.Add sgCalcMinimum, "Day"
   grp.Calculations.Add sgCalcMaximum, "Day"
   grp.Calculations.Add sgCalcAverage, "Amount"
   grp.Calculations.Add sgCalcSum, "Amount"

   Set grp = SGGrid1.Groups.Add("Day", _
      sgSortAscending, sgSortTypeNumber, False, False)
   grp.Calculations.Add sgCalcMaximum, "Amount"
   grp.HeaderTextSource = sgGrpHdrFormula
   grp.HeaderFormula = "GroupingValue & '    Total: ' & GroupCalc(1)"
   Set grp = Nothing

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic


First Property (SGRows Collection)

First Property (SGRows Collection)
Returns first non-heading row object.

Read-only at run time. Not available at design time.

Syntax

object.First As IsgRow

The object placeholder represents an object expression that evaluates to the SGRows object.

Remarks

The First property returns both hidden and visible rows.

See Also

SGRows


Last Property (SGRows Collection)

Last Property (SGRows Collection)
Returns last row object.

Read-only at run time. Not available at design time.

Syntax

object.Last As IsgRow

The object placeholder represents an object expression that evaluates to the SGRows object.

Remarks

If the AllowAddNew property is set to True and the property NewRowPos is set to sgNewRowBottom the Last property reference the add new row.

Show Example
Copy Code [image] Show Me

The following example uses the Last property to make the add new row invisible. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      'create cols and rows
      .DataColCount = 5
      .DataRowCount = 3
      .AllowAddNew = True
      'customize appearance
      .CellsBorderVisible = False
      .FitLastColumn = True
      'apply alpha blanding only on the last row
      .AlphaBlendEnabled = True
      .Styles("Normal").AlphaLevel(sgAlphaBackground) = 255
      .Styles("Normal").AlphaLevel(sgAlphaBorder) = 255
   End With

   SGGrid1_AfterInsert
End Sub

Private Sub SGGrid1_AfterInsert()
   'make last row invisible
   SGGrid1.Rows.Last.Style. _
      AlphaLevel(sgAlphaBackground) = 0
    SGGrid1.Rows.Last.Style. _
      AlphaLevel(sgAlphaBorder) = 0

   SGGrid1.Rows.Last.Redraw
End Sub

Back to topic


SGRows Methods

Add | Adds new row at the and of the grid.
At | Returns reference to the row at specified position.
FindTag | Finds first row whose tag value matches specified condition.
Find | Finds first row that matches specified condition.
InsertAt | Inserts new row at specified position.
RemoveAll | Removes all rows from the collection.
RemoveAt | Removes row at specified position.
Remove | Removes specified row from a grid.


Add Method (SGRows Collection)

Add Method (SGRows Collection)
Adds new row at the and of the grid.
Syntax

object.Add(Format As sgDataFormat, RowData As String, [CellSeparator = ","] As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGRows object.
Format | An sgDataFormat expression that specifies the data format. The possible values are listed in Settings.
RowData | A String expression that contains the row data.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Default value is ",". Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for Format are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

The Add method adds a new row to the grid. The new row is initialized with data specified in the RowData parameter. If RowData contains more values than grid columns, excess values are ignored. If Format property is set to sgFormatXML, only columns with field names specified in the RowData parameter are initialized.

The code below copies the current row from one grid to another:

   SGGrid2.Rows.Add sgFormatXML, SGGrid1.Rows.Current.GetData(sgFormatXML)

Show Example
Copy Code [image] Show Me

The following example shows how to use the row's add method. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim sData As String

   SGGrid1.DataColCount = 2
   SGGrid1.DataRowCount = 0

   For i = 0 To 20
      sData = "Row " & Trim(i)
      sData = "Col 1 " & sData & ";" & "Col 2 " & sData
      SGGrid1.Rows.Add sgFormatCharSeparatedValue, sData, ";"
   Next
End Sub

Back to topic


At Method (SGRows Collection)

At Method (SGRows Collection)
Returns reference to the row at specified position.
Syntax

object.At(Position As Long)

Return Value A SGRow object.
Arguments
object | An object expression that evaluates to the SGRows object.
Position | A Long that identifies the row Position.

Remarks

The At method returns the SGRow object representing row at the specified position. If the control's HeadingRowCount property is not zero, you can use At(0) call to reference the heading row.

Show Example
Copy Code [image] Show Me

The following example resizes the heading row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.HeadingRowCount = 1

   With SGGrid1.Rows.At(0)
      .AllowSizing = False
      .Height = .Height * 2
   End With
End Sub

Back to topic

See Also

SGRows


Find Method (SGRows Collection)

Find Method (SGRows Collection)
Finds first row that matches specified condition.
Syntax

object.Find(ColKey As String, Op As sgOperator, Val1 As Variant, [Val2] As Variant, [StartRowPos = 0] As Long, [Direction = 1] As Long, [SearchFlags = sgSearchDefault] As sgSearchFlag)

Return Value A SGRow object.
Arguments
object | An object expression that evaluates to the SGRows object.
ColKey | A String expression that represents the Key of the column. If you want to search all columns set this parameter to an empty string ("").
Op An sgOperator expression that sets the operator to be used when evaluating condition.
Check out pattern syntax if you use regular expression (sgOpRegEx). The possible values are listed in Settings.
Val1 | A Variant expression that contains the first right-side value to be used when evaluating condition criteria.
Val2 | Optional. A Variant expression that contains the second right-side value to be used for a condition criteria. This argument is used only if the operator is set to sgOpBetween.
StartRowPos Optional. A Long expression that represents the Position where row search is to begin.
If omitted, 0 is assumed.
Direction Optional. Optional. A Long expression that indicates the search direction. Possible values are:
  • 1 = search forward
  • -1 = search backward
Default value is 1.
SearchFlags Optional. An sgSearchFlag expression indicating the kind of comparison to use when evaluating cell's values.
Default value is sgSearchDefault.

Settings

The settings for Op are:

Name | Value | Description
sgOpFalse | 0 | Always fail.
sgOpTrue | 1 | Always succeed.
sgOpLessThan | 2 | Succeeds if the left-side value is smaller then the right-side value.
sgOpLessThanOrEqual | 3 | Succeeds if the left-side value is smaller than or equal to the right-side value.
sgOpGreaterThan | 4 | Succeeds if the left-side value is greater then the right-side value.
sgOpGreaterThanOrEqual | 5 | Succeeds if the left-side value is greater then or equal to the right-side value.
sgOpEqual | 6 | Succeeds if the left-side value is equal to the right-side value.
sgOpBetween | 7 | Succeeds if the left-side value is both greater then the first right-side value and smaller or equal to the second right-side value.
sgOpContains | 8 | Succeeds if left-side value is contained in the right-side value. Applies only to string and integral (byte, short, long, int64) types.
sgOpRegEx | 9 | Succeeds if regular expression is matched. Applies only to string values.
sgOpCallback | 10 | Uses IsgConditionTest interface to test a value.
sgOpNot | 16384 | Negates operator. Can be used only in combination with some other operator.
The settings for SearchFlags are:

Name | Value | Description
sgSearchDefault | 0 | Do not use any special processing when comparing values.
sgSearchText | 1 | Use formatted text when comparing values.
sgSearchCaseSensitive | 2 | Text comparasion is case sensitive.

Remarks

The Find method returns the first row that meets search criteria. If no row meets criteria, Nothing is returned.

Note: Set the parameter ColKey to the empty string ("") to force the grid to search through all columns.

Show Example
Copy Code [image] Show Me

The following example uses the first row as Filter Bar. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Enter the criteria in the first row, then press the Enter key or click a column's header.

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   Dim sColKey As String, lRowKey As Long
   Dim vValue As Variant, row As SGRow
   Dim lStartRowPos As Long
   'get coland row keys
   sColKey = SGGrid1.Columns(ColIndex).Key
   lRowKey = SGGrid1.Rows.At(1).Key
   'get the first row value
   vValue = SGGrid1.Cell(lRowKey, sColKey).Value
   'check out if the top row is the last one
   If SGGrid1.TopRow + 1 = SGGrid1.RowCount Then
      lStartRowPos = 1
   Else
      lStartRowPos = SGGrid1.TopRow + 1
   End If
   'try to find row using value from the first row
   If ColIndex = 1 Then
      Set row = SGGrid1.Rows.Find(sColKey, sgOpContains, vValue, , lStartRowPos)
   Else
      Set row = SGGrid1.Rows.Find(sColKey, sgOpEqual, vValue, , lStartRowPos)
   End If

   If row Is Nothing Then
      'there is not row meets the criteria
      SGGrid1.TopRow = 1
   Else
      'there is row meets the criteria so move it on the top
      SGGrid1.TopRow = row.Position
      Set row = Nothing
   End If
End Sub

Private Sub SGGrid1_KeyPressEdit _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   KeyASCII As Integer)
   'exit cell-editing mode on the return key
   If KeyASCII = vbKeyReturn And SGGrid1.row = 1 Then _
      SGGrid1.Editing = False
End Sub

Private Sub SGGrid1_KeyUp(KeyCode As Integer, Shift As Integer)
   'use the return key to find row
   If KeyCode = vbKeyReturn And SGGrid1.row = 1 Then _
      SGGrid1_ColHeadClick SGGrid1.Columns.Current.ColIndex
End Sub

Private Sub SGGrid1_OnInit()
   Dim sFile As String
   Dim sgCol As SGColumn
   Dim sWinDir As String
   Dim i As Integer
   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   'remove all columns
   SGGrid1.Columns.RemoveAll False
   SGGrid1.RowNumbering = True
   'use tab key to navigate columns
   SGGrid1.TabKeyBehavior = sgTabColumns
   SGGrid1.NavigationWrapMode = sgNavigationWrapSame
   'Column creations
   SGGrid1.Columns.Add "File"
   Set sgCol = SGGrid1.Columns.Add("FileDate")
   sgCol.DataType = sgtDateTime
   sgCol.SortType = sgSortTypeDateTime
   Set sgCol = SGGrid1.Columns.Add("Size")
   sgCol.DataType = sgtLong

   sWinDir = Environ("WINDIR") & "\"
   i = 1
   sFile = Dir(sWinDir & "*.*", vbNormal)
   'add files to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(1).Value = sFile
      SGGrid1.Rows.At(i).Cells(2).Value = _
         FormatDateTime(FileDateTime(sWinDir & sFile), vbShortDate)
      SGGrid1.Rows.At(i).Cells(3).Value = FileLen(sWinDir & sFile)
      sFile = Dir
   Loop

   SGGrid1.Rows.At(1).Frozen = True
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


FindTag Method (SGRows Collection)

FindTag Method (SGRows Collection)
Finds first row whose tag value matches specified condition.
Syntax

object.FindTag(Op As sgOperator, Val1 As Variant, [Val2] As Variant, [StartRowPos = 0] As Long, [Direction = 1] As Long)

Return Value A SGRow object.
Arguments
object | An object expression that evaluates to the SGRows object.
Op An sgOperator expression that sets the operator to be used when evaluating condition.
Check out pattern syntax if you use regular expression (sgOpRegEx). The possible values are listed in Settings.
Val1 | A Variant expression that contains the first right-side value to be used when evaluating condition criteria.
Val2 | Optional. A Variant expression that contains the second right-side value to be used for a condition criteria. This argument is used only if the operator is set to sgOpBetween.
StartRowPos Optional. A Long expression that represents the Position where row search is to begin.
If omitted, 0 is assumed.
Direction Optional. Optional. A Long expression that indicates the search direction. Possible values are:
  • 1 = search forward
  • -1 = search backward
Default value is 1.

Settings

The settings for Op are:

Name | Value | Description
sgOpFalse | 0 | Always fail.
sgOpTrue | 1 | Always succeed.
sgOpLessThan | 2 | Succeeds if the left-side value is smaller then the right-side value.
sgOpLessThanOrEqual | 3 | Succeeds if the left-side value is smaller than or equal to the right-side value.
sgOpGreaterThan | 4 | Succeeds if the left-side value is greater then the right-side value.
sgOpGreaterThanOrEqual | 5 | Succeeds if the left-side value is greater then or equal to the right-side value.
sgOpEqual | 6 | Succeeds if the left-side value is equal to the right-side value.
sgOpBetween | 7 | Succeeds if the left-side value is both greater then the first right-side value and smaller or equal to the second right-side value.
sgOpContains | 8 | Succeeds if left-side value is contained in the right-side value. Applies only to string and integral (byte, short, long, int64) types.
sgOpRegEx | 9 | Succeeds if regular expression is matched. Applies only to string values.
sgOpCallback | 10 | Uses IsgConditionTest interface to test a value.
sgOpNot | 16384 | Negates operator. Can be used only in combination with some other operator.

Remarks

The FindTag method searches for a row by its Tag property. If no tag meets criteria, Nothing is returned.

Show Example
Copy Code [image] Show Me

The following example changes a row's tag when it's updated. Edit some cells and click button to find updated rows. To try the example, place BeeGrid and CommandButton control on a form. Paste the code into the Declarations section, press F5, edit some cells and click button.

Private Sub Command1_Click()
   Dim row As SGRow
   Dim cell As SGCell
   Static lLastRowPos As Long

   Set row = SGGrid1.Rows.FindTag(sgOpEqual, "Update", , lLastRowPos)

   If row Is Nothing Then
      MsgBox "No more updated rows!"
      lLastRowPos = 0
   Else
      SGGrid1.TopRow = row.Position
      For Each cell In row.Cells
         If cell.Status = sgCellStatusDataChanged Then
            cell.Style.ForeColor = vbRed
            cell.Redraw
         End If
      Next
      lLastRowPos = row.Position + 1
      If lLastRowPos = SGGrid1.RowCount Then lLastRowPos = 0
   End If
End Sub

Private Sub SGGrid1_AfterUpdate()
   SGGrid1.Rows.Current.Tag = "Update"
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, iCol As Integer
   Dim i As Integer, j As Integer, iCell As Integer

   'create columns and rows
   SGGrid1.DataColCount = 10
   SGGrid1.DataRowCount = 100

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         iCell = iCell + 1
         ar.Value(i, j) = iCell
      Next j, i

   Set ar = Nothing
End Sub

Back to topic


InsertAt Method (SGRows Collection)

InsertAt Method (SGRows Collection)
Inserts new row at specified position.
Syntax

object.InsertAt(RowPos As Long, Format As sgDataFormat, RowData As String, [CellSeparator = ","] As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGRows object.
RowPos | A Long expression representing the position where the new row is placed.
Format | An sgDataFormat expression that specifies the data format. The possible values are listed in Settings.
RowData | A String expression that contains the row data.
CellSeparator | Optional. A String expression that sets delimiter used between columns. Default value is ",". Used only if the DataFormat is sgFormatCharSeparatedValue.

Settings

The settings for Format are:

Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

Remarks

The InsertAt method inserts a new row into the grid. The row is inserted at the RowPos position and initialized with data specified in the RowData parameter. If RowData contains more values than grid columns, excess values are ignored. If Format property is set to sgFormatXML, only columns with field names specified in the RowData parameter are initialized.

Show Example
Copy Code [image] Show Me

The following example uses the Timer control to insert one row on the first position every second. To try the example, place the SGGrid and Timer control on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Timer1.Interval = 1000
   SGGrid1.DataColCount = 1
   SGGrid1.FitLastColumn = True
   SGGrid1.DataRowCount = 0
End Sub

Private Sub Timer1_Timer()
   Dim lLastRow As Long

   SGGrid1.Rows.InsertAt 0, sgFormatCharSeparatedValue, Now

   If SGGrid1.RowCount > 20 Then
      lLastRow = SGGrid1.Rows.At(SGGrid1.RowCount - 1).Key
      SGGrid1.Rows.Remove lLastRow
   End If
End Sub

Back to topic


Remove Method (SGRows Collection)

Remove Method (SGRows Collection)
Removes specified row from a grid.
Syntax

object.Remove(RowKey As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGRows object.
RowKey | A Long that represents the key of the row being removed.

Remarks

Use this method to remove a data or heading row. To remove a heading row, set the control's HeadingRowCount property to zero (0).

Show Example
Copy Code [image] Show Me

The following example deletes all selected rows.

Private Sub DeleteSelectedRows()
   Dim rng As SGRange, i As Integer
   Dim lKey As Long

   For Each rng In SGGrid2.Selection.Ranges
      For i = rng.BottomRow To rng.TopRow Step -1
         lKey = SGGrid2.Rows.At(i).Key
         SGGrid2.Rows.Remove lKey
      Next
   Next

   Set rng = Nothing

End Sub

Back to topic

See Also

SGRows


RemoveAll Method (SGRows Collection)

RemoveAll Method (SGRows Collection)
Removes all rows from the collection.
Syntax

object.RemoveAll([RemoveHeading = -1] As Boolean)

Return Value None
Arguments
object | An object expression that evaluates to the SGRows object.
RemoveHeading | Optional. A Boolean expression specifying whether the heading row will be also removed. Default value is -1.

Remarks

See Also

SGRows


RemoveAt Method (SGRows Collection)

RemoveAt Method (SGRows Collection)
Removes row at specified position.
Syntax

object.RemoveAt(Position As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGRows object.
Position | A Long that identifies the row Position.

Remarks

See Also

SGRows


SGRowBuffer Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGRowBuffer Object

Name: | SGRowBuffer
Description: | SGRowBuffer object is row data buffer used to get/set data in virtual mode.
GUID: | {F1EBD1D2-1676-4569-8B9E-EC7D4A2295B5}

Show Example
Copy Code [image] Show Me

The following example uses VirtualEvents mode to fill grid. Grid get data throught VirtualReadData event. To try the example, place a SGGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_VirtualReadData(ByVal rowBuffer As IsgRowBuffer)
   Dim i As Integer
   'limit to 20 rows
   If rowBuffer.RowIndex = 20 Then
      rowBuffer.RowIndex = -1
      Exit Sub
   End If

   For i = 0 To rowBuffer.ColumnCount - 1
      rowBuffer.Value(i) = "Row: " & rowBuffer.RowIndex & " Col: " & (i + 1)
   Next

End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 4
   SGGrid1.DataMode = sgVirtualEvents
End Sub

Back to topic

Referenced By


SGRowBuffer Properties

Bookmark | Returns or sets row bookmark.
ColumnCount | Returns the number of columns. Zero based.
RowIndex | Returns or sets the data index of the row being retrieved. Zero based.
Value | Returns or sets the value of the row field.


Bookmark Property (SGRowBuffer Object)

Bookmark Property (SGRowBuffer Object)
Returns or sets row bookmark.

Read-only at run time. Not available at design time.

Syntax

object.Bookmark As Variant

The object placeholder represents an object expression that evaluates to the SGRowBuffer object.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates the Bookmark property of the SGRowBuffer object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      .MaxRows = 20
      .DataMode = sgVirtualEvents
      .DataColCount = 2
      .Columns(1).Caption = "Bookmark"
      .Columns(2).Caption = "Row Index"
   End With

End Sub

Private Sub SGGrid1_VirtualReadData _
   (ByVal RowBuffer As IsgRowBuffer)
   Dim lRndNum As Long

   If IsEmpty(RowBuffer.Bookmark) Then
      RowBuffer.Bookmark = CLng(Rnd * 10000)
   Else
      Me.Caption = RowBuffer.Bookmark
   End If

   RowBuffer.Value(0) = RowBuffer.Bookmark
   RowBuffer.Value(1) = RowBuffer.RowIndex
End Sub

Back to topic

See Also

SGRowBuffer


ColumnCount Property (SGRowBuffer Object)

ColumnCount Property (SGRowBuffer Object)
Returns the number of columns. Zero based.

Read-only at run time. Not available at design time.

Syntax

object.ColumnCount As Long

The object placeholder represents an object expression that evaluates to the SGRowBuffer object.

Remarks

The ColumnCount property returns the number of bound columns. It returns the same value as the DataColCount if all columns are bound. Value of the ColumnCount property is equal to the number of elements in the SGRowBuffer's Value array.

Show Example
Copy Code [image] Show Me

The following example populates the RowBuffer with sample data. It uses the ColumnCount property to get data columns count. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      .MaxRows = 20
      .DataColCount = CLng(Rnd * 5) + 1
      .DataMode = sgVirtualEvents
   End With

End Sub

Private Sub SGGrid1_VirtualReadData _
   (ByVal RowBuffer As IsgRowBuffer)
   Dim i As Integer

   For i = 0 To RowBuffer.ColumnCount - 1
      RowBuffer.Value(i) = _
         "Row: " & Trim(RowBuffer.RowIndex + 1) & _
         " Col: " & Trim(i + 1)
   Next
End Sub

Back to topic

See Also

SGRowBuffer


RowIndex Property (SGRowBuffer Object)

RowIndex Property (SGRowBuffer Object)
Returns or sets the data index of the row being retrieved. Zero based.

Read/Write at run time. Not available at design time.

Syntax

object.RowIndex As Long

The object placeholder represents an object expression that evaluates to the SGRowBuffer object.

Remarks

This property has same value as the DataIndex property of the SGRow object. If you can set this property to - 1, inside the VirtualReadData event, the grid will stop draw rows. For example, the code below uses the RowIndex property to limit the grid to 20 rows.

Private Sub SGGrid1_VirtualReadData _
   (ByVal RowBuffer As IsgRowBuffer)
   Dim lRndNum As Long

   If RowBuffer.RowIndex >= 20 Then
      RowBuffer.RowIndex = -1
      Exit Sub
   End If
End Sub

Show Example
Copy Code [image] Show Me

The following example demonstrates relations between the Bookmark and the RowIndex properties of the SGRowBuffer object and the Row, the Position and the DataIndex properties of the SGRow object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      .DataMode = sgVirtualEvents
      .DataColCount = 5
      .Columns(1).Caption = "Bookmark"
      .Columns(2).Caption = "Row Index"
      .Columns(3).Caption = "Position"
      .Columns(4).Caption = "Key"
      .Columns(5).Caption = "DataIndex"
      .CacheAllRecords = True
      .ColumnClickSort = True
   End With

End Sub

Private Sub SGGrid1_VirtualReadData _
   (ByVal RowBuffer As IsgRowBuffer)
   Dim lRndNum As Long

   If RowBuffer.RowIndex >= 20 Then
      RowBuffer.RowIndex = -1
      Exit Sub
   End If

   If IsEmpty(RowBuffer.Bookmark) Then
      RowBuffer.Bookmark = CLng(Rnd * 10000)
   Else
      Me.Caption = RowBuffer.Bookmark
   End If

   RowBuffer.Value(0) = RowBuffer.Bookmark
   RowBuffer.Value(1) = RowBuffer.RowIndex
   With SGGrid1.Rows.At(RowBuffer.RowIndex)
      RowBuffer.Value(2) = .Position
      RowBuffer.Value(3) = .Key
      RowBuffer.Value(4) = .DataIndex
   End With
End Sub

Back to topic

See Also

SGRowBuffer


Value Property (SGRowBuffer Object)

Value Property (SGRowBuffer Object)
Returns or sets the value of the row field.

Read/Write at run time. Not available at design time.

Syntax

object.Value As Variant

The object placeholder represents an object expression that evaluates to the SGRowBuffer object.

Remarks

The Value property is array of variants. The dimension of this property is the ColumnCount property minus one.

Show Example
Copy Code [image] Show Me

The following example populates the RowBuffer with sample data. It uses the ColumnCount property to get data columns count. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      .MaxRows = 20
      .DataColCount = CLng(Rnd * 5) + 1
      .DataMode = sgVirtualEvents
   End With

End Sub

Private Sub SGGrid1_VirtualReadData _
   (ByVal RowBuffer As IsgRowBuffer)
   Dim i As Integer

   For i = 0 To RowBuffer.ColumnCount - 1
      RowBuffer.Value(i) = _
         "Row: " & Trim(RowBuffer.RowIndex + 1) & _
         " Col: " & Trim(i + 1)
   Next
End Sub

Back to topic

See Also

SGRowBuffer


SGRowCollection Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGRowCollection Object

Name: | SGRowCollection
Description: | Collection of child SGRow objects.
GUID: | {49D306E3-3625-11D3-B736-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example uses the SGRowCollection to get a value of the each child row in a group. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchGroupHeaderData _
   (ByVal GroupIndex As Integer, ByVal RowKey As Long, _
   Text As String, PictureExpanded As Variant, _
   PictureCollapsed As Variant)
   Dim gh As SGGroupHeading
   Dim row As SGRow, iLastDay As Integer
   Dim iCurrDay As Integer, iPos As Integer
   Dim rows As SGRowCollection

   Set gh = SGGrid1.rows(RowKey).GroupHeading
   Set rows = gh.ChildRows
   Text = MonthName(gh.GroupingValue) & " Days("

   iPos = SGGrid1.Columns("Day").Position

   For Each row In rows
      iCurrDay = Day(row.Cells(iPos).Value)
      If iLastDay <> iCurrDay Then
         Text = Text & iCurrDay & ","
         iLastDay = iCurrDay
      End If
   Next

   Text = Left(Text, Len(Text) - 1) & ")"

   Set rows = Nothing
   Set gh = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long
   Dim grp As SGGroup
   'create columns and rows
   SGGrid1.Columns.RemoveAll True
   SGGrid1.DataRowCount = 100
   SGGrid1.FitLastColumn = True

   With SGGrid1.Columns.Add("Month")
      .DataType = sgtShort
      .Hidden = True
   End With

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
      .Width = .Width * 2
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With
   'add sample data
   Set ar = SGGrid1.Array
   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = Month(dtDay)
      ar.Value(i, 1) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 2) = Round((Rnd * 1000), 2)
   Next
   Set ar = Nothing
   'create group and calculation
   Set grp = SGGrid1.Groups.Add("Month", _
      sgSortAscending, sgSortTypeNumber, False, False)
   'use formulas for header text
   grp.HeaderTextSource = sgGrpHdrFireFetchText
   'create calculations
   Set grp = Nothing
   SGGrid1.Sort -1, -1, "Day", sgSortAscending, sgSortTypeDateTime

   SGGrid1.RefreshGroups sgCollapseGroups
End Sub

Back to topic

Referenced By

SGGroupHeading.ChildRows


SGRowCollection Properties

Count | Returns the number of SGRow objects in the collection
First | Returns first row object.
Grid | Returns parent SGGrid object.
Item | Returns specified row object.
Last | Returns last row object.


First Property (SGRowCollection Object)

First Property (SGRowCollection Object)
Returns first row object.

Read-only at run time. Not available at design time.

Syntax

object.First As IsgRow

The object placeholder represents an object expression that evaluates to the SGRowCollection object.

Remarks

The First property returns either simple (sgSimpleRow) or footer (sgGroupFooter) rows. It doesn't return group headers (sgGroupHeader).


Last Property (SGRowCollection Object)

Last Property (SGRowCollection Object)
Returns last row object.

Read-only at run time. Not available at design time.

Syntax

object.Last As IsgRow

The object placeholder represents an object expression that evaluates to the SGRowCollection object.

Remarks

If the FooterVisible property is set to True the Last property reference the group footer row.

Show Example
Copy Code [image] Show Me

The following example uses the Last property to retrieve a text displayed in group footer. It displays this text in the cell tool tip window. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_FetchCellTip _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal CellKind As sgCellKind, _
   Width As stdole.OLE_XSIZE_CONTAINER, _
   Height As stdole.OLE_YSIZE_CONTAINER, _
   CellTipText As String, Picture As Variant, _
   ByVal TipStyle As IsgStyle)

   If CellKind = sgCellGroupHeader Then
      Dim gh As SGGroupHeading

      Set gh = SGGrid1.Rows(RowKey).GroupHeading
      'display footer text in the tool tip
      CellTipText = gh.ChildRows.Last.Cells(0).Value
   End If
End Sub

Private Sub Form_Load()
   Dim sFile As String
   Dim SGGroup As SGGroup
   Dim sWinDir As String
   Dim dtFileDate As Date
   Dim i As Integer

   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   'remove all columns
   SGGrid1.Columns.RemoveAll True
   'ColumnClickSort needs CacheAllRecords
   SGGrid1.CacheAllRecords = True
   SGGrid1.ColumnClickSort = True

   SGGrid1.GroupByBoxVisible = False
   SGGrid1.FitLastColumn = True
   'enable tool tips
   SGGrid1.CellTips = sgCellTipsFloat
   SGGrid1.CellTipsDelay = 200
   'Column creations
   With SGGrid1.Columns.Add("File")
      .Caption = "File name"
      .Width = 2200
   End With

   With SGGrid1.Columns.Add("FileDate")
      .Caption = "File date"
      .Width = 2200
      .DataType = sgtDateTime
      .SortType = sgSortTypeDateTime
   End With

   With SGGrid1.Columns.Add("Size")
      .Caption = "Size"
      .DataType = sgtLong
   End With

   With SGGrid1.Columns.Add("FileYear")
      .Hidden = True
      .Caption = "File year"
   End With

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.*", vbNormal)
   'add files to the grid
   Do Until Len(sFile) = 0
      i = i + 1
      SGGrid1.DataRowCount = i
      SGGrid1.Rows.At(i).Cells(0).Value = sFile
      dtFileDate = FormatDateTime _
         (FileDateTime(sWinDir & sFile), vbShortDate)
      SGGrid1.Rows.At(i).Cells(1).Value = dtFileDate
      SGGrid1.Rows.At(i).Cells(2).Value = FileLen(sWinDir & sFile)
      SGGrid1.Rows.At(i).Cells(3).Value = Year(dtFileDate)
      sFile = Dir
   Loop
   'group grid by year and month
   Set SGGroup = SGGrid1.Groups.Add("FileYear", sgSortAscending, _
      sgSortTypeNumber, True, False)
   'show formula result in header and footer
   SGGroup.HeaderTextSource = sgGrpHdrFormula
   SGGroup.FooterTextSource = sgGrpFooterFormula
   'create calculations for header and footer
   SGGroup.Calculations.Add sgCalcSum, "Size"
   SGGroup.Calculations.Add sgCalcAverage, "Size"
   'create formula
   SGGroup.HeaderFormula = "'Total size for ' & GroupingValue &" & _
      "' is ' & Format((GroupCalc(1) / 1024),'Standard') & ' KB" & _
      "(' & TotalChildCount & ' files)'"
   SGGroup.FooterFormula = "'The average file size for ' & " & _
      "GroupingValue & ' is ' & Format((GroupCalc(2) / 1024)," & _
      "'Standard') & ' KB'"

   SGGrid1.RefreshGroups sgCollapseGroups
   'redrow grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


SGSelection Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGSelection Object

Name: | SGSelection
Description: | SGSelection object can be used to manipulate current selection.
GUID: | {D96465D5-DB03-11D2-8F2C-008048E27A77}

Show Example
Copy Code [image] Show Me

Private Sub Form_Load()
   SGGrid1.SelectionMode = sgSelectionByRow
   SGGrid1.MultiSelect = sgMultiSelectExtended
   SGGrid1.SpecialMode = sgModeListBox
End Sub

Back to topic

Referenced By

Selection


SGSelection Properties

Grid | Returns parent SGGrid object.
MultiSelect | Controls multiple selection mode.
Ranges | Collection of SGRanges object in the selection.
SelectionMode | Returns or sets selection mode.
Style | Returns selection's SGStyle object.


Ranges Property (SGSelection Object)

Ranges Property (SGSelection Object)
Collection of SGRanges object in the selection.

Read-only at run time. Not available at design time.

Syntax

object.Ranges As IsgRanges

The object placeholder represents an object expression that evaluates to the SGSelection object.

Remarks

This property returns reference to the SGRanges collection.

If you set the property MultiSelect to sgMultiSelectNone the collection will contain maximum one object.

When you call the Clear method of the SGSelection object all object will be removed from the collection.


Style Property (SGSelection Object)

Style Property (SGSelection Object)
Returns selection's SGStyle object.

Read-only at run time. Not available at design time.

Syntax

object.Style As IsgStyle

The object placeholder represents an object expression that evaluates to the SGSelection object.

Remarks

This property is shortcut to the "Selection" style object in the SGStyles collection.

Following lines have same effect:

SGGrid1.Selection.Style.BackColor = vbRed

- or -

SGGrid1.Styles("Selection").BackColor = vbRed


SGSelection Methods

Clear | Clears selection.
IsCellSelected | Returns True specified cell is selected.
IsColSelected | Returns True specified column is selected.
IsEmpty | Returns True if there is no selected cells.
IsRowSelected | Returns True specified row is selected.
SelectAll | Select all non-heading cells in the grid.


Clear Method (SGSelection Object)

Clear Method (SGSelection Object)
Clears selection.
Syntax | object.Clear
Return Value | None
Arguments | None

Remarks

There are no difference between the Clear method and following code:

   SGGrid1.Selection.Ranges.RemoveAll
   SGGrid1.Redraw


IsCellSelected Method (SGSelection Object)

IsCellSelected Method (SGSelection Object)
Returns True specified cell is selected.
Syntax

object.IsCellSelected(RowPosition As Long, ColPosition As Long)

Return Value An Boolean value indicating whether a cell is selected.
Arguments
object | An object expression that evaluates to the SGSelection object.
RowPosition | A Long that identifies the row Position.
ColPosition | A Long that identifies the column Position.

Remarks

If you set the grid's property SelectionMode to sgSelectionNone, the user will not be able to select a cell.

Show Example
Copy Code [image] Show Me

The following example invert currently selected cells. To try the example, place a SGGrid and CommandButton on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim row As SGRow, col As SGColumn
   Dim lRangesCount As Long, i As Long
    Dim cell As SGCell, lColPos As Long, lRowPos As Long

   'save count of current selection
   lRangesCount = SGGrid1.Selection.Ranges.Count

   For Each row In SGGrid1.Rows
      For Each cell In row.Cells
         lColPos = cell.Column.Position
         lRowPos = row.Position
         If Not SGGrid1.Selection.IsCellSelected(lRowPos, lColPos) Then
            SGGrid1.Selection.Ranges.Add sgRangeFree, lColPos, lRowPos, lColPos, lRowPos
         End If
      Next
   Next
   'remove old selection
   For i = 0 To lRangesCount - 1
      SGGrid1.Selection.Ranges.Remove 0
   Next

   SGGrid1.Redraw
   SGGrid1.SetFocus
End Sub

Back to topic


IsColSelected Method (SGSelection Object)

IsColSelected Method (SGSelection Object)
Returns True specified column is selected.
Syntax

object.IsColSelected(ColPosition As Long)

Return Value An Boolean value indicating whether a column is selected.
Arguments
object | An object expression that evaluates to the SGSelection object.
ColPosition | A Long that identifies the column Position.

Remarks

The method IsColSelected return true when a column is select by:

  • the user click on the column's heading.
  • columns are selected with SelectAll.
  • columns are selected from the code with Add using the sgRangeColumn type.

To allow the user selecting a column, set the grid's property SelectionMode to sgSelectionByColumn, sgSelectionByRowAndColumn or sgSelectionModeAll

Show Example
Copy Code [image] Show Me

The following example invert currently selected columns. To try the example, place a SGGrid and CommandButton on a form. Paste the code into the Declarations section, press F5 and click button.

Private Sub Command1_Click()
   Dim col As Long, iHeadCol As Integer
   Dim lRangesCount As Long, i As Long
   'save count of current selection
   lRangesCount = SGGrid1.Selection.Ranges.Count
   'skip heading col
   iHeadCol = IIf(SGGrid1.HeadingColCount, 1, 0)
   'check out each column and select unselected
   For col = SGGrid1.Columns.Count - iHeadCol To iHeadCol Step -1
      If Not SGGrid1.Selection.IsColSelected(col) Then
         SGGrid1.Selection.Ranges.Add sgRangeColumn, col, 0, col, 1
      End If
   Next
   'remove old selection
   For i = 0 To lRangesCount - 1
      SGGrid1.Selection.Ranges.Remove 0
   Next

   SGGrid1.Redraw
   SGGrid1.SetFocus
End Sub

Back to topic


IsEmpty Method (SGSelection Object)

IsEmpty Method (SGSelection Object)
Returns True if there is no selected cells.
Syntax | object.IsEmpty
Return Value | An Boolean value indicating whether there is not selected cells.
Arguments | None

Remarks

This property returns True if there is no selected cells.

If the property SelectionMode is set to sgSelectionNone the IsEmpty property will always returns True

Show Example
Copy Code [image] Show Me

The following example shows how to use the IsEmpty to enable/disable the command button.

Private Sub SGGrid1_SelChange(cancelSelect As Boolean)
   Command1.Enabled = Not SGGrid1.Selection.IsEmpty
End Sub

Back to topic


IsRowSelected Method (SGSelection Object)

IsRowSelected Method (SGSelection Object)
Returns True specified row is selected.
Syntax

object.IsRowSelected(RowPosition As Long)

Return Value An Boolean value indicating whether a row is selected.
Arguments
object | An object expression that evaluates to the SGSelection object.
RowPosition | A Long that identifies the row Position.

Remarks

The method IsRowSelected return true when a row is select by:

  • the user click on the row selector.
  • the user click on the row when SpecialMode is set to sgModeListBox.
  • rows are selected with SelectAll.
  • rows are selected from the code with Add using the sgRangeRow type.

To allow the user selecting a row, set the grid's property SelectionMode to sgSelectionByRow, sgSelectionByRowAndColumn or sgSelectionModeAll.

Show Example
Copy Code [image] Show Me

The following example marks all selected rows with red or clears mark if row has been marked.

Private Sub MarkRow()
   Dim Row As SGRow

   For Each Row In SGGrid1.Rows
      If SGGrid1.Selection.IsRowSelected(Row.Position) Then
         If Row.Tag = "Marked" Then
            Row.Tag = ""
            Row.Style.ForeColor = vbBlack
         Else
            Row.Tag = "Marked"
            Row.Style.ForeColor = vbRed
         End If
         Row.Redraw
      End If
   Next
End Sub

Back to topic


SelectAll Method (SGSelection Object)

SelectAll Method (SGSelection Object)
Select all non-heading cells in the grid.
Syntax | object.SelectAll
Return Value | None
Arguments | None

Remarks

After the SelectAll method has applied, the Ranges collection contains one SGRange object.

Show Example
Copy Code [image] Show Me

The following example selects all cells and fires SelChange event.

Private Sub Command1_Click()
   SGGrid1.Selection.SelectAll
   'the SelChange event does not occure if you change
   'selection from the code
   SGGrid1_SelChange False
End Sub

Back to topic


SGStyle Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGStyle Object

Name: | SGStyle
Description: | SGStyle is a definition of visual attributes.
GUID: | {EA2CE603-9388-11D2-8EC1-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example uses the Styles collection to access each style. It fills the grid with style properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sty As SGStyle, i As Integer
   Dim lRow As Long

   With SGGrid1
      .RedrawEnabled = False

      .Columns.RemoveAll True

      .DataColCount = 22
      .DataRowCount = .Styles.Count
      'create columns with style properties
      .Columns(1).Caption = "Style Name"
      .Columns(2).Caption = "Backcolor"
      .Columns(3).Caption = "Forecolor"
      .Columns(4).Caption = "Base Style"
      .Columns(5).Caption = "Font name"
      .Columns(6).Caption = "Font size"
      .Columns(6).Style.TextAlignment = sgAlignRightCenter
      For i = 7 To 10
         .Columns(i).Caption = _
            Choose(i - 6, "Bold", "Italic", "Underline", "Strikethrough")
         .Columns(i).Control.Type = sgCellCheckBox
         .Columns(i).Style.TextAlignment = sgAlignCenterCenter
         .HeadingTextAlignment = sgAlignCenterCenter
      Next
      .Columns(11).Caption = "Format"
      .Columns(12).Caption = "Appearance"
      With .Columns(12).ValueItems
         .Add 1, "3D"       'sg3D
         .Add 2, "3D Light"  'sg3DLight
      End With
      .Columns(13).Caption = "DisplayType"
      .Columns(13).ValueItems.Add 0, "Text"     'sgDisplayText
      .Columns(14).Caption = "TextAlignment"
      With .Columns(14).ValueItems
         .Add 0, "General"             'sgAlignGeneral
         .Add 4, "Left-Center"       'sgAlignLeftCenter
         .Add 5, "Center-Center"       'sgAlignCenterCenter
      End With
      .Columns(15).Caption = "PictureAlignment"
      .Columns(15).ValueItems.Add 3, "Left-Center"     'sgPicAlignLeftCenter
      .Columns(16).Caption = "Padding"
      .Columns(17).Caption = "WordWrap"
      .Columns(17).Control.Type = sgCellCheckBox
      .Columns(17).Style.TextAlignment = sgAlignCenterCenter
      .Columns(18).Caption = "Ellipsis"
      .Columns(18).ValueItems.Add 1, "Ellipsis End"     'sgEllipsisEnd
      .Columns(19).Caption = "Borders"
      With .Columns(19).ValueItems
         .Add 15, "All"       'sgCellBorderAll
         .Add 0, "No Border"  'sgCellNoBorder
      End With
      .Columns(20).Caption = "Border Color"
      .Columns(21).Caption = "Border Size"
      .Columns(22).Caption = "Border Style"
      With .Columns(22).ValueItems
         .Add 1, "Solid"      'sgCellBorderSolid
      End With
   End With
   'enum styles end show values for each property
   For Each sty In SGGrid1.Styles
      lRow = lRow + 1
      With SGGrid1.Rows.At(lRow)
         .Cells(0).Value = sty.Name
         .Cells(1).Style.BackColor = sty.BackColor
         .Cells(2).Style.BackColor = sty.ForeColor
         .Cells(3).Value = sty.BaseStyle
         .Cells(4).Value = sty.Font.Name
         .Cells(5).Value = sty.Font.Size
         .Cells(6).Value = sty.Font.Bold
         .Cells(7).Value = sty.Font.Italic
         .Cells(8).Value = sty.Font.Underline
         .Cells(9).Value = sty.Font.Strikethrough
         .Cells(10).Value = sty.Format
         .Cells(11).Value = sty.Appearance
         .Cells(12).Value = sty.DisplayType
         .Cells(13).Value = sty.TextAlignment
         .Cells(14).Value = sty.PictureAlignment
         .Cells(15).Value = sty.Padding
         .Cells(16).Value = sty.WordWrap
         .Cells(17).Value = sty.Ellipsis
         .Cells(18).Value = sty.Borders
         .Cells(19).Style.BackColor = sty.BorderColor
         .Cells(20).Value = sty.BorderSize
         .Cells(21).Value = sty.BorderStyle
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

Referenced By

SGColumn.Style | SGControl.Style | SGStyles.Item | SGSelection.Style | SGRow.Style | SGCell.Style | FetchScrollTip | FetchCellTip | FetchGroupHeaderStyle | FetchGroupFooterStyle | FetchCellStyle


SGStyle Properties

AlphaLevel | Returns or sets an alpha transparency value to be used for the specified element.
Appearance | Returns or sets the paint style.
BaseStyle | Returns or sets name of the style on which a style is based.
BackColor2 | Returns or sets cell's second background color.
BackColor | Returns or sets cell's background color.
BkgPictureAlignment | Returns or sets background picture alignment style.
BkgPicture | Returns or sets a background picture.
BkgStyle | Returns or sets cells background style.
BorderColor | Returns or sets cells border color.
BorderSize | Returns or sets size of the cell border.
BorderStyle | Returns or sets cells border style.
Borders | Indicates which borders are shown.
CustomDraw | Value indicating whether custom draw is enabled.
DisplayType | Determines how a cell is displayed.
Ellipsis | Truncates text that does not fit in the cell and adds ellipses (...).
Font |
ForeColor | Returns or sets cell's foreground color.
Format | Specifies the format for displaying numbers, dates, time and text.
Grid | Returns parent SGGrid object.
HighlightColor | Returns or sets a highlight color used when drawing 3D effects.
MouseIcon | Returns or sets a custom mouse icon.
MousePointer | Returns or sets the type of mouse pointer displayed.
Name | Returns style name.
Padding | Returns or sets the space between the contents and inside edges of cells.
PictureAlignment | Returns or sets picture alignment style.
ShadowColor | Returns or sets a shadow color used when drawing 3D effects.
TextAlignment | Returns or sets text alignment style.
Value | Returns or sets style name. Read only for named styles.
WordWrap | Enables or disables word wrapping for cell text.


AlphaLevel Property (SGStyle Object)

AlphaLevel Property (SGStyle Object)
Returns or sets an alpha transparency value to be used for the specified element.

Read/Write at run time and design time.

Syntax

object.AlphaLevel As Integer

The object placeholder represents an object expression that evaluates to the SGStyle object.

Arguments
Element An sgAlphaBlendElement constant that determines the cell element that is a subject of an alpha blending operation.

Settings

The settings for Element are:

Name | Value | Description
sgAlphaBorder | 1 | Indicates alpha blending attributes for the cell's border.
sgAlphaBackground | 2 | Indicates alpha blending attributes for the cell's background color.
sgAlphaBackgroundPicture | 3 | Indicates alpha blending attributes for the cell's background picture.
sgAlphaContent | 4 | Indicates alpha blending attributes for the cell's content.

Remarks

Show Example
Copy Code [image] Show Me

The following example loads the background picture and sets a different AlphaLevel for each column. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim col As SGColumn
   Dim i As Integer
   Dim iStep As Integer
   'find bitmap to show
   If StrComp(Environ("OS"), "Windows_NT", vbTextCompare) = 0 Then
      Set SGGrid1.BkgPicture = _
         LoadPicture(Environ("WINDIR") & "\system32\Setup.bmp")
   Else
      Set SGGrid1.BkgPicture = _
         LoadPicture(Environ("WINDIR") & "\Setup.bmp")
   End If

   With SGGrid1
      .BkgPictureAlignment = sgPicAlignTile
      .GroupByBoxVisible = False
      .GridLines = sgGridLineNone
      .CellsBorderVisible = False
      .FitLastColumn = True
      .AlphaBlendEnabled = True
      'create cols and rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 0
      .DefaultColWidth = _
         .ClientWidth / 12
      .DataColCount = 12
      .DataRowCount = 100

      iStep = 255 / (.DataColCount - 1)
   End With
   'set AlphaLevel for each col
   For Each col In SGGrid1.Columns
      With col.Style
         .BackColor = vbWhite
         .BackColor2 = RGB(128, 128, 128)
         .BkgStyle = sgCellBkgGradientHorizontal
         .AlphaLevel(sgAlphaBackground) = 255 - i
      End With
      i = i + iStep
   Next

End Sub

Back to topic


Appearance Property (SGStyle Object)

Appearance Property (SGStyle Object)
Returns or sets the paint style.

Read/Write at run time and design time.

Syntax

object.Appearance As sgAppearance

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The Appearance settings are:

Name | Value | Description
sgFlat | 0 | Flat appearance.
sg3D | 1 | Standard 3D appearance.
sg3DLight | 2 | Light 3D appearance.

Remarks

Show Example
Copy Code [image] Show Me

The following example draws the flat grid without borders. The current cell is red because the focus rect covers the contents of the cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.GridBorderStyle = sgNone
   SGGrid1.Appearance = sgFlat
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.BackColor = SGGrid1.Parent.BackColor
   SGGrid1.CellsBorderVisible = False
   SGGrid1.HeadingColCount = 0
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DataRowCount = 4
   SGGrid1.DataColCount = 4
   SGGrid1.FocusRect = sgFocusRectSolid
   SGGrid1.FocusRectColor = vbRed
   SGGrid1.FocusRectLineWidth = 100
End Sub

Back to topic


BaseStyle Property (SGStyle Object)

BaseStyle Property (SGStyle Object)
Returns or sets name of the style on which a style is based.

Read/Write at run time and design time.

Syntax

object.BaseStyle As String

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates the BaseName property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   With SGGrid1
      .DataColCount = 10
      .DataRowCount = 10
      .SpecialMode = sgModeListBox
      .Styles("Selection").BaseStyle = "Heading"
   End With
End Sub

Back to topic

See Also

SGStyle


BackColor Property (SGStyle Object)

BackColor Property (SGStyle Object)
Returns or sets cell's background color.

Read/Write at run time and design time.

Syntax

object.BackColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example paints each cell to shade of green. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim cell As SGCell
   Dim iCell As Integer, lRow As Long

   With SGGrid1
      .RedrawEnabled = False
      .GroupByBoxVisible = False
      .Columns.RemoveAll True
      'create and customize cols
      .DefaultColWidth = 500
      .DataRowCount = 26
      .DataColCount = 10
      .HeadingColCount = 0
      .BackColor = SGGrid1.Styles("Heading").BackColor
      .GridBorderStyle = sgNone
   End With

   lRow = 1

   For iCell = 0 To 255
      Set cell = SGGrid1.Rows.At(lRow). _
         Cells(iCell Mod SGGrid1.DataColCount)
      cell.Value = iCell
      cell.Style.BackColor = RGB(0, 255 - iCell, 0)
      cell.Style.ForeColor = vbWhite
      If (iCell + 1) Mod SGGrid1.DataColCount = 0 Then
         lRow = lRow + 1
      End If
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


BackColor2 Property (SGStyle Object)

BackColor2 Property (SGStyle Object)
Returns or sets cell's second background color.

Read/Write at run time and design time.

Syntax

object.BackColor2 As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example uses the BackColor2 property to create gradient. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim row As SGRow

   With SGGrid1
      .GroupByBoxVisible = False
      .GridLines = sgGridLineNone
      .FitLastColumn = True
      'create cols and rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 1
      .DataRowCount = 16
      .Styles("Normal").BkgStyle = sgCellBkgGradientHorizontal
   End With
   'create gradient for each row
   For Each row In SGGrid1.Rows
      With row.Style
         .BackColor2 = QBColor(i)
      End With
      i = i + 1
   Next

End Sub

Back to topic


BkgPicture Property (SGStyle Object)

BkgPicture Property (SGStyle Object)
Returns or sets a background picture.

Read/Write at run time and design time.

Syntax

object.BkgPicture As IPictureDisp

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example uses bitmaps from the Windows directory as cells background pictures. To try the example, place an SGGrid on a form. Paste the code into the Declarations section and press F5. Change the current row and double click on the grid.

Private Sub SGGrid1_OnInit()
   Dim sFile As String
   Dim sWinDir As String

   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.DataRowCount = 0
   'remove all columns and headers
   SGGrid1.Columns.RemoveAll True
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DefaultRowHeight = SGGrid1.DefaultColWidth
   SGGrid1.FitLastColumn = True
   'Column creations
   SGGrid1.Columns.Add "Picture"
   SGGrid1.Columns.Add "File Name"

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.bmp", vbNormal)

   Do Until Len(sFile) = 0
      SGGrid1.Rows.Add sgFormatCharSeparatedValue, "," & sFile
      With SGGrid1.Rows.At(SGGrid1.RowCount - 1).Cells(0)
         'use the LoadPicture to set cell picture
         .Style.BkgPictureAlignment = sgPicAlignCenterCenter
         Set .Style.BkgPicture = LoadPicture(sWinDir & sFile)
      End With

      sFile = Dir
   Loop

   'redraw grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


BkgPictureAlignment Property (SGStyle Object)

BkgPictureAlignment Property (SGStyle Object)
Returns or sets background picture alignment style.

Read/Write at run time and design time.

Syntax

object.BkgPictureAlignment As sgPicAlignment

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The BkgPictureAlignment property settings are:

Name | Value | Description
sgPicAlignLeftTop | 0 | Align picture to the left-top position.
sgPicAlignCenterTop | 1 | Align picture to the center-top position.
sgPicAlignRightTop | 2 | Align picture to the right-top position.
sgPicAlignLeftCenter | 3 | Align picture to the left-center position.
sgPicAlignCenterCenter | 4 | Align picture to the center-center position.
sgPicAlignRightCenter | 5 | Align picture to the right-center position.
sgPicAlignLeftBottom | 6 | Align picture to the left-bottom position.
sgPicAlignCenterBottom | 7 | Align picture to the center-bottom position.
sgPicAlignRightBottom | 8 | Align picture to the right-bottom position.
sgPicAlignStretch | 9 | Picture is streched to fit cell content.
sgPicAlignTile | 10 | Picture is tiled to fit cell content.

Remarks

Show Example
Copy Code [image] Show Me

The following example uses bitmaps from the Windows directory as cells background pictures. To try the example, place an SGGrid on a form. Paste the code into the Declarations section and press F5. Change the current row and double click on the grid.

Private Sub SGGrid1_OnInit()
   Dim sFile As String
   Dim sWinDir As String

   'disable redraw to speed up proces
   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   SGGrid1.DataRowCount = 0
   'remove all columns and headers
   SGGrid1.Columns.RemoveAll True
   SGGrid1.HeadingRowCount = 0
   SGGrid1.DefaultRowHeight = SGGrid1.DefaultColWidth
   SGGrid1.FitLastColumn = True
   'Column creations
   SGGrid1.Columns.Add "Picture"
   SGGrid1.Columns.Add "File Name"

   sWinDir = Environ("WINDIR") & "\"

   sFile = Dir(sWinDir & "*.bmp", vbNormal)

   Do Until Len(sFile) = 0
      SGGrid1.Rows.Add sgFormatCharSeparatedValue, "," & sFile
      With SGGrid1.Rows.At(SGGrid1.RowCount - 1).Cells(0)
         'use the LoadPicture to set cell picture
         .Style.BkgPictureAlignment = sgPicAlignCenterCenter
         Set .Style.BkgPicture = LoadPicture(sWinDir & sFile)
      End With

      sFile = Dir
   Loop

   'redraw grid
   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


BkgStyle Property (SGStyle Object)

BkgStyle Property (SGStyle Object)
Returns or sets cells background style.

Read/Write at run time and design time.

Syntax

object.BkgStyle As sgCellBkgStyle

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The BkgStyle settings are:

Name | Value | Description
sgCellBkgNone | 0 | Do not draw cell border. Cell is transparent.
sgCellBkgSolid | 1 | Draw solid cell background.
sgCellBkgBDiagonal | 2 | Draw backward diagonal pattern in the cell's background.
sgCellBkgFDiagonal | 3 | Draw forward diagonal pattern in the cell's background.
sgCellBkgCross | 4 | Draw cross-hatched pattern in the cell's background.
sgCellBkgDiagCross | 5 | Draw diagonally cross-hatched pattern in the cell's background.
sgCellBkgHorizontal | 6 | Draw horizontal pattern in the cell's background.
sgCellBkgVertical | 7 | Draw vertical pattern in the cell's background.
sgCellBkgGradientVertical | 8 | The background is shaded from top-to-bottom.
sgCellBkgGradientHorizontal | 9 | The background is shaded from left-to-right.

Remarks

Show Example
Copy Code [image] Show Me

The following example loads the background picture and makes grid's cells transparent. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   'find bitmap to show
   If StrComp(Environ("OS"), "Windows_NT", vbTextCompare) = 0 Then
      Set SGGrid1.BkgPicture = LoadPicture(Environ("WINDIR") & "\system32\Setup.bmp")
   Else
      Set SGGrid1.BkgPicture = LoadPicture(Environ("WINDIR") & "\Setup.bmp")
   End If

   SGGrid1.GroupByBoxVisible = False
   'make the grids cell transparent
   SGGrid1.CellBkgStyle = sgCellBkgNone
   SGGrid1.GridLines = sgGridLineNone
   SGGrid1.HeadingColCount = 0
   SGGrid1.CellsBorderVisible = False

   SGGrid1.Styles("Heading").BkgStyle = sgCellBkgSolid
   SGGrid1.FitLastColumn = True

End Sub

Back to topic


BorderColor Property (SGStyle Object)

BorderColor Property (SGStyle Object)
Returns or sets cells border color.

Read/Write at run time and design time.

Syntax

object.BorderColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates how to customize cell borders. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   Me.BackColor = vbWhite

   With SGGrid1
      .Appearance = sgFlat
      .GridLines = sgGridLineNone
      .BackColor = vbWhite
      .GridBorderStyle = sgNone
      .CellsBorderColor = vbGreen
      .FocusRect = sgFocusRectNone
      'create cols & rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 3
      .DataRowCount = 3

      'set cell border
      With .Styles("Normal")
         .Borders = sgCellBorderTop + sgCellBorderLeft
         .BorderColor = vbGreen
         .BorderSize = 15
      End With
   End With
End Sub

Back to topic


BorderSize Property (SGStyle Object)

BorderSize Property (SGStyle Object)
Returns or sets size of the cell border.

Read/Write at run time and design time.

Syntax

object.BorderSize As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates how to customize cell borders. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   Me.BackColor = vbWhite

   With SGGrid1
      .Appearance = sgFlat
      .GridLines = sgGridLineNone
      .BackColor = vbWhite
      .GridBorderStyle = sgNone
      .CellsBorderColor = vbGreen
      .FocusRect = sgFocusRectNone
      'create cols & rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 3
      .DataRowCount = 3

      'set cell border
      With .Styles("Normal")
         .Borders = sgCellBorderTop + sgCellBorderLeft
         .BorderColor = vbGreen
         .BorderSize = 15
      End With
   End With
End Sub

Back to topic


BorderStyle Property (SGStyle Object)

BorderStyle Property (SGStyle Object)
Returns or sets cells border style.

Read/Write at run time and design time.

Syntax

object.BorderStyle As sgCellBorderStyle

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The BorderStyle settings are:

Name | Value | Description
sgCellBorderSolid | 1 | Draw solid cell borders.
sgCellBorderDotted | 2 | Draw dotted cell borders.
sgCellBorderDashed | 3 | Draw dashed cell borders.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates how to customize cell borders. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   Me.BackColor = vbWhite

   With SGGrid1
      .Appearance = sgFlat
      .GridLines = sgGridLineNone
      .BackColor = vbWhite
      .GridBorderStyle = sgNone
      .CellsBorderColor = vbGreen
      .FocusRect = sgFocusRectNone
      'create cols & rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 3
      .DataRowCount = 3

      'set cell border
      With .Styles("Normal")
         .Borders = sgCellBorderTop + sgCellBorderLeft
         .BorderColor = vbGreen
         .BorderSize = 15
      End With
   End With
End Sub

Back to topic


Borders Property (SGStyle Object)

Borders Property (SGStyle Object)
Indicates which borders are shown.

Read/Write at run time and design time.

Syntax

object.Borders As sgCellBorder

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The Borders settings are:

Name | Value | Description
sgCellNoBorder | 0 | Do not draw cell's borders.
sgCellBorderLeft | 1 | Draw left border.
sgCellBorderTop | 2 | Draw top border.
sgCellBorderRight | 4 | Draw right border.
sgCellBorderBottom | 8 | Draw bottom border.
sgCellBorderAll | 15 | Draw all borders.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates how to customize cell borders. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()

   Me.BackColor = vbWhite

   With SGGrid1
      .Appearance = sgFlat
      .GridLines = sgGridLineNone
      .BackColor = vbWhite
      .GridBorderStyle = sgNone
      .CellsBorderColor = vbGreen
      .FocusRect = sgFocusRectNone
      'create cols & rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 3
      .DataRowCount = 3

      'set cell border
      With .Styles("Normal")
         .Borders = sgCellBorderTop + sgCellBorderLeft
         .BorderColor = vbGreen
         .BorderSize = 15
      End With
   End With
End Sub

Back to topic


CustomDraw Property (SGStyle Object)

CustomDraw Property (SGStyle Object)
Value indicating whether custom draw is enabled.

Read/Write at run time and design time.

Syntax

object.CustomDraw As sgCustomDrawStage

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The CustomDraw settings are:

Name | Value | Description
sgNoCustomDraw | 0 | The grid will draw all stages itself.
sgDrawBeforeGridBkg | 1 | Before the grid's background is drawn.
sgDrawAfterGridBkg | 2 | After the grid's background has been drawn.
sgDrawBeforeGridCaption | 3 | Before the grid's caption is drawn.
sgDrawAfterGridCaption | 4 | After the grid's caption has been drawn.
sgDrawBeforeGridCorner | 5 | Before the grid's corner is drawn.
sgDrawAfterGridCorner | 6 | After the grid's corner has been drawn.
sgDrawBeforePreviewPaneSplitter | 7 | Before the preview pane's splitter bar is drawn.
sgDrawAfterPreviewPaneSplitter | 8 | After the preview pane's splitter bar has been drawn.
sgDrawBeforeFocusRect | 9 | Before the grid's focus rectangle is drawn.
sgDrawAfterFocusRect | 10 | After the grid's focus rectangle has been drawn.
sgDrawBeforeCellBorder | 11 | Before the cell's border (grid lines, border and padding) is drawn.
sgDrawAfterCellBorder | 12 | After the cell's border (grid lines, border and padding) has been drawn.
sgDrawBeforeCellBkg | 13 | Before the cell's background is drawn.
sgDrawAfterCellBkg | 14 | After the cell's background has been drawn.
sgDrawBeforeCellButton | 15 | Before the cell's button is drawn.
sgDrawAfterCellButton | 16 | After the cell's button has been drawn.
sgDrawBeforeCellBkgPicture | 17 | Before the cell's background picture is drawn.
sgDrawAfterCellBkgPicture | 18 | After the cell's background picture has been drawn.
sgDrawBeforeCellContent | 19 | Before the cell's content is drawn.
sgDrawAfterCellContent | 20 | After the cell's content has been drawn.

Remarks

The CustomBkgDraw property determines how the grid's cells will be drawn.

To implement custom draw create object that implements the IsgGridCustomDraw interface. Reference this object to the PaintObject.

Show Example
Copy Code [image] Show Me

The following example draws two circles on the grid. It draws one on the caption area and another on the background. It fills the first column with random data. Example uses this data to draw small rectangle on the left corner. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Implements IsgGridCustomDraw

Private Declare Function SelectObject Lib "gdi32" _
   (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
   (ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" _
   (ByVal crColor As Long) As Long
Private Declare Function Ellipse Lib "gdi32" _
   (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _
   ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreatePen Lib "gdi32" _
   (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function Rectangle Lib "gdi32" _
   (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, _
   ByVal X2 As Long, ByVal Y2 As Long) As Long

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.Caption = "Custom draw"

   Set SGGrid1.PaintObject = Me
   SGGrid1.CustomBkgDraw = sgDrawBeforeGridBkg

   With SGGrid1.Columns.At(1)
      .Style.CustomDraw = sgDrawAfterCellContent
      .Caption = "Custom draw"
   End With

   SGGrid1.DataRowCount = 100

   For i = 0 To SGGrid1.DataRowCount - 1
      SGGrid1.Array(i, 0) = CLng(Rnd * vbWhite)
   Next
End Sub

Private Sub IsgGridCustomDraw_DrawGridBkg( _
   drawInfo As sgGridCustomDraw, _
   response As sgCustomDrawResponse)
   Dim hBrush As Long
   Dim hOldBrush As Long

   If drawInfo.DrawStage = sgDrawAfterGridCaption Then
      ' Draw caption
      hBrush = CreateSolidBrush(RGB(255, 0, 0))
      hOldBrush = SelectObject(drawInfo.DC, hBrush)

      Ellipse drawInfo.DC, drawInfo.Left + 6, drawInfo.Top + 2, _
                            drawInfo.Left + 20, drawInfo.bottom - 1

      SelectObject drawInfo.DC, hOldBrush
      DeleteObject hBrush
   ElseIf drawInfo.DrawStage = sgDrawAfterGridBkg Then

      hBrush = CreateSolidBrush(RGB(255, 0, 0))
      hOldBrush = SelectObject(drawInfo.DC, hBrush)

      Ellipse drawInfo.DC, drawInfo.right - 70, drawInfo.bottom - 40, _
                            drawInfo.right - 34, drawInfo.bottom - 4

      SelectObject drawInfo.DC, hOldBrush
      DeleteObject hBrush
   End If

   response = sgDoDefault
End Sub

Private Sub IsgGridCustomDraw_DrawCell( _
   drawInfo As sgGridCustomDraw, _
   response As sgCustomDrawResponse)
   Dim hPen As Long
   Dim hOldPen As Long
   Dim sData As String

   response = sgDoDefault

   ' Ignore heading cells
   If drawInfo.Heading <> 0 Then Exit Sub

   If drawInfo.DrawStage = sgDrawAfterCellBkg Then
      If drawInfo.ColIndex = 1 Then
         ' Draw left positioned color box and adjust content rect
         ' so grids default painting will not overwrite our color box
         ' Get color
         Dim clr As Long

         clr = CLng(drawInfo.Data)

         ' Draw rectangle
         DrawRectangle drawInfo.DC, clr, drawInfo.Left + 4, drawInfo.Top + 2, _
                                          drawInfo.Left + (drawInfo.bottom - drawInfo.Top), drawInfo.bottom - 2

         drawInfo.Left = drawInfo.Left + 26
      End If
   End If
End Sub

Private Sub DrawRectangle(hdc&, clr&, Left&, Top&, right&, bottom&)
   Dim hBrush As Long
   Dim hPen As Long
   Dim hOldBrush As Long
   Dim hOldPen As Long

   ' Create pen and brush
   hPen = CreatePen(0, 0, RGB(0, 0, 0))
   hBrush = CreateSolidBrush(clr)
   hOldPen = SelectObject(hdc, hPen)
   hOldBrush = SelectObject(hdc, hBrush)

   ' Draw rectangle
   Rectangle hdc, Left, Top, right, bottom

   ' Release pen and brush
   SelectObject hdc, hOldPen
   SelectObject hdc, hOldBrush
   DeleteObject hPen
   DeleteObject hBrush
End Sub

Back to topic


DisplayType Property (SGStyle Object)

DisplayType Property (SGStyle Object)
Determines how a cell is displayed.

Read/Write at run time and design time.

Syntax

object.DisplayType As sgDisplayType

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The DisplayType settings are:

Name | Value | Description
sgDisplayText | 0 | Cell displays text only.
sgDisplayTextAndPicture | 1 | Cell displays text and picture.
sgDisplayPicture | 2 | Cell displays picture only.
sgProgressBar | 3 | Cell displays progress bar.

Remarks

Show Example
Copy Code [image] Show Me

The following example fills the grid with sample data and sets a each column to the different DisplayType. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer

   SGGrid1.RedrawEnabled = False

   SGGrid1.DataColCount = 4
   SGGrid1.DataRowCount = 10

   For i = 1 To 4
      With SGGrid1.Columns.At(i)
         .Style.DisplayType = i - 1
         .Caption = Choose(i, "sgDisplayText", _
            "sgDisplayTextAndPicture", "sgDisplayPicture", "sgProgressBar")
         For j = 1 To 10
            If i < 4 Then _
               .ValueItems.Add j, "Item " & j, sgbipFirst + j
            SGGrid1.CellAt(j, i).Value = j
         Next
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

See Also

SGStyle


Ellipsis Property (SGStyle Object)

Ellipsis Property (SGStyle Object)
Truncates text that does not fit in the cell and adds ellipses (...).

Read/Write at run time and design time.

Syntax

object.Ellipsis As sgEllipsis

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The Ellipsis settings are:

Name | Value | Description
sgNoEllipsis | 0 | Do not draw ellipses. Text is clipped.
sgEllipsisEnd | 1 | Replace part at the end of the text with ellipses.
sgEllipsisPath | 2 | Replace part in the middle of the text with ellipses.

Remarks

This property has effect only if the WordWrap property set to false.

Show Example
Copy Code [image] Show Me

The following example shows how the Ellipsis style works. To try the example, place BeeGrid on a form. Paste the code into the Declarations section ,press F5 and click the columns header.

Private Sub Form_Load()

   SGGrid1.Array.Value(0, 0) = _
      "F:\Documents and Settings\All Users\" & _
      "Application Data\Microsoft\" & _
      "Machine Debug Manager\mdm.ini"
   SGGrid1.Columns.At(1).Style.WordWrap = False
   SGGrid1.Columns.At(2).Caption = SGGrid1.Array.Value(0, 0)
End Sub

Private Sub SGGrid1_ColHeadClick(ByVal ColIndex As Long)
   If SGGrid1.Ellipsis = sgEllipsisPath Then
      SGGrid1.Ellipsis = sgNoEllipsis
   Else
      SGGrid1.Ellipsis = SGGrid1.Ellipsis + 1
   End If

   SGGrid1.HeadingEllipsis = SGGrid1.Ellipsis
   SGGrid1.Columns(1).Caption = _
      Choose(SGGrid1.Ellipsis + 1, "No Ellipsis", _
      "Ellipsis End", "Ellipsis Path")
End Sub

Back to topic


Font Property (SGStyle Object)

Font Property (SGStyle Object)

Read/Write at run time and design time.

Syntax

object.Font As IFontDisp

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example shows how to use the font object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section ,press F5

Private Sub Form_Load()
   Dim fnt As StdFont

   SGGrid1.Columns(1).Caption = "The caption"
   SGGrid1.Array.Value(0, 0) = "Sample Text"

   Set fnt = SGGrid1.Font

   fnt.Name = "Times New Roman"
   fnt.Bold = True
   fnt.Underline = True

   Set SGGrid1.Styles("CurrentCell").Font = fnt
   Set SGGrid1.Styles("Heading").Font = fnt
   Set fnt = Nothing
End Sub

Back to topic


ForeColor Property (SGStyle Object)

ForeColor Property (SGStyle Object)
Returns or sets cell's foreground color.

Read/Write at run time and design time.

Syntax

object.ForeColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks


Format Property (SGStyle Object)

Format Property (SGStyle Object)
Specifies the format for displaying numbers, dates, time and text.

Read/Write at run time and design time.

Syntax

object.Format As String

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

The Format property contains data formatting string. The Format string is used to format cell's data. See the Visual Basic Format function for information about valid format strings.

Note: BeeGrid formatting uses Visual Basic formatting capabilities. If container does not provide this functionality, cell's data will not be formatted. In such cases you can set the Format property to "FormatText Event" and grid will fire the FormatText event when cell's data needs formatting.

Show Example
Copy Code [image] Show Me

The following example fills the grid with sample data and with some of standard formats. The code in the RowColChange event changes the grid's format. To try the example, place BeeGrid on a form. Paste the code into the Declarations section ,press F5

Private Sub Form_Load()
   Dim ar As SGArray
   Dim i As Long

   SGGrid1.DataRowCount = 10
   SGGrid1.DataColCount = 2
   SGGrid1.FitLastColumn = True

   Set ar = SGGrid1.Array

   For i = 0 To SGGrid1.DataRowCount - 1
      ar.Value(i, 1) = i * Rnd * 1000000
   Next

   ar.Value(0, 0) = "General"
   ar.Value(1, 0) = "Standard"
   ar.Value(2, 0) = "Currency"
   ar.Value(3, 0) = "Percent"
   ar.Value(4, 0) = "#0.00"
   ar.Value(5, 0) = "#,###0.00"
   ar.Value(6, 0) = "Short Date"
   ar.Value(7, 0) = "Long Date"
   ar.Value(8, 0) = "Short Time"
   ar.Value(9, 0) = "Long Time"

   Set ar = Nothing

   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_RowColChange(ByVal lastRowKey As Long, ByVal lastColIndex As Long)
   SGGrid1.Format = SGGrid1.Array(SGGrid1.Rows.Current.DataIndex, 0)
End Sub

Back to topic


HighlightColor Property

HighlightColor Property
Returns or sets a highlight color used when drawing 3D effects.

Read/Write at run time and design time.

Syntax

object.HighlightColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Use the HighlightColor property to change the color of the left and top grid lines, when GridLines property is set to sgGridLineInset, sgGridLineRaised, sgGridLineInsetHorz, sgGridLineRaisedHorz, sgGridLineInsetVert or sgGridLineRaisedVert.


MouseIcon Property (SGStyle Object)

MouseIcon Property (SGStyle Object)
Returns or sets a custom mouse icon.

Read/Write at run time and design time.

Syntax

object.MouseIcon As IPictureDisp

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example sets a different mouse pointer for each row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim row As SGRow
   Dim arPointers As Variant

   With SGGrid1
      .RedrawEnabled = False
      .GroupByBoxVisible = False
      .FitLastColumn = True
      'create cols and rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 1
      .DataRowCount = 17
      .Styles("Normal").BkgStyle = sgCellBkgGradientHorizontal
   End With

   arPointers = Array("Default", "Arrow", "Cross", "Ibeam", _
      "Icon", "Size", "SizeNESW", "SizeNS", "SizeNWSE", "SizeEW", _
      "UpArrow", "Hourglass", "NoDrop", "ArrowHourglass", _
      "ArrowQuestion", "SizeAll", "Hand")

   For Each row In SGGrid1.Rows
      row.Cells(0).Value = arPointers(i)
      row.Style.MousePointer = i
      i = i + 1
   Next
   'create row with custom pointer
   SGGrid1.Rows.Add sgFormatCharSeparatedValue, "Custom"

   With SGGrid1.Rows.At(SGGrid1.RowCount - 1)
      Set .Style.MouseIcon = Me.Icon
      .Style.MousePointer = sgMPCustom
   End With

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


MousePointer Property (SGStyle Object)

MousePointer Property (SGStyle Object)
Returns or sets the type of mouse pointer displayed.

Read/Write at run time and design time.

Syntax

object.MousePointer As sgMousePointer

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The MousePointer settings are:

Name | Value | Description
sgMPDefault | 0 | (Default) Shape determined by the object.
sgMPArrow | 1 | Arrow.
sgMPCross | 2 | Cross (cross-hair pointer).
sgMPIbeam | 3 | I Beam.
sgMPIcon | 4 | Icon (small square within a square).
sgMPSize | 5 | Size (four-pointed arrow pointing north, south, east, and west).
sgMPSizeNESW | 6 | Size NE SW (double arrow pointing northeast and southwest).
sgMPSizeNS | 7 | Size N S (double arrow pointing north and south).
sgMPSizeNWSE | 8 | Size NW, SE.
sgMPSizeEW | 9 | Size E W (double arrow pointing east and west).
sgMPUpArrow | 10 | Up Arrow.
sgMPHourglass | 11 | Hourglass (wait).
sgMPNoDrop | 12 | No Drop.
sgMPArrowHourglass | 13 | Arrow and hourglass.
sgMPArrowQuestion | 14 | Arrow and question mark.
sgMPSizeAll | 15 | Size all.
sgMPHand | 16 | Pointing hand.
sgMPCustom | 99 | Custom icon specified by the MouseIcon property.

Remarks

Show Example
Copy Code [image] Show Me

The following example sets a different mouse pointer for each row. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim row As SGRow
   Dim arPointers As Variant

   With SGGrid1
      .RedrawEnabled = False
      .GroupByBoxVisible = False
      .FitLastColumn = True
      'create cols and rows
      .HeadingColCount = 0
      .HeadingRowCount = 0
      .DataColCount = 1
      .DataRowCount = 17
      .Styles("Normal").BkgStyle = sgCellBkgGradientHorizontal
   End With

   arPointers = Array("Default", "Arrow", "Cross", "Ibeam", _
      "Icon", "Size", "SizeNESW", "SizeNS", "SizeNWSE", "SizeEW", _
      "UpArrow", "Hourglass", "NoDrop", "ArrowHourglass", _
      "ArrowQuestion", "SizeAll", "Hand")

   For Each row In SGGrid1.Rows
      row.Cells(0).Value = arPointers(i)
      row.Style.MousePointer = i
      i = i + 1
   Next
   'create row with custom pointer
   SGGrid1.Rows.Add sgFormatCharSeparatedValue, "Custom"

   With SGGrid1.Rows.At(SGGrid1.RowCount - 1)
      Set .Style.MouseIcon = Me.Icon
      .Style.MousePointer = sgMPCustom
   End With

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


Name Property (SGStyle Object)

Name Property (SGStyle Object)
Returns style name.
Syntax

object.Name As String

The object placeholder represents an object expression that evaluates to the SGStyle object.

Show Example
Copy Code [image] Show Me

The following example uses the Styles collection to access each style. It fills the grid with style properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sty As SGStyle, i As Integer
   Dim lRow As Long

   With SGGrid1
      .RedrawEnabled = False

      .Columns.RemoveAll True

      .DataColCount = 22
      .DataRowCount = .Styles.Count
      'create columns with style properties
      .Columns(1).Caption = "Style Name"
      .Columns(2).Caption = "Backcolor"
      .Columns(3).Caption = "Forecolor"
      .Columns(4).Caption = "Base Style"
      .Columns(5).Caption = "Font name"
      .Columns(6).Caption = "Font size"
      .Columns(6).Style.TextAlignment = sgAlignRightCenter
      For i = 7 To 10
         .Columns(i).Caption = _
            Choose(i - 6, "Bold", "Italic", "Underline", "Strikethrough")
         .Columns(i).Control.Type = sgCellCheckBox
         .Columns(i).Style.TextAlignment = sgAlignCenterCenter
         .HeadingTextAlignment = sgAlignCenterCenter
      Next
      .Columns(11).Caption = "Format"
      .Columns(12).Caption = "Appearance"
      With .Columns(12).ValueItems
         .Add 1, "3D"       'sg3D
         .Add 2, "3D Light"  'sg3DLight
      End With
      .Columns(13).Caption = "DisplayType"
      .Columns(13).ValueItems.Add 0, "Text"     'sgDisplayText
      .Columns(14).Caption = "TextAlignment"
      With .Columns(14).ValueItems
         .Add 0, "General"             'sgAlignGeneral
         .Add 4, "Left-Center"       'sgAlignLeftCenter
         .Add 5, "Center-Center"       'sgAlignCenterCenter
      End With
      .Columns(15).Caption = "PictureAlignment"
      .Columns(15).ValueItems.Add 3, "Left-Center"     'sgPicAlignLeftCenter
      .Columns(16).Caption = "Padding"
      .Columns(17).Caption = "WordWrap"
      .Columns(17).Control.Type = sgCellCheckBox
      .Columns(17).Style.TextAlignment = sgAlignCenterCenter
      .Columns(18).Caption = "Ellipsis"
      .Columns(18).ValueItems.Add 1, "Ellipsis End"     'sgEllipsisEnd
      .Columns(19).Caption = "Borders"
      With .Columns(19).ValueItems
         .Add 15, "All"       'sgCellBorderAll
         .Add 0, "No Border"  'sgCellNoBorder
      End With
      .Columns(20).Caption = "Border Color"
      .Columns(21).Caption = "Border Size"
      .Columns(22).Caption = "Border Style"
      With .Columns(22).ValueItems
         .Add 1, "Solid"      'sgCellBorderSolid
      End With
   End With
   'enum styles end show values for each property
   For Each sty In SGGrid1.Styles
      lRow = lRow + 1
      With SGGrid1.Rows.At(lRow)
         .Cells(0).Value = sty.Name
         .Cells(1).Style.BackColor = sty.BackColor
         .Cells(2).Style.BackColor = sty.ForeColor
         .Cells(3).Value = sty.BaseStyle
         .Cells(4).Value = sty.Font.Name
         .Cells(5).Value = sty.Font.Size
         .Cells(6).Value = sty.Font.Bold
         .Cells(7).Value = sty.Font.Italic
         .Cells(8).Value = sty.Font.Underline
         .Cells(9).Value = sty.Font.Strikethrough
         .Cells(10).Value = sty.Format
         .Cells(11).Value = sty.Appearance
         .Cells(12).Value = sty.DisplayType
         .Cells(13).Value = sty.TextAlignment
         .Cells(14).Value = sty.PictureAlignment
         .Cells(15).Value = sty.Padding
         .Cells(16).Value = sty.WordWrap
         .Cells(17).Value = sty.Ellipsis
         .Cells(18).Value = sty.Borders
         .Cells(19).Style.BackColor = sty.BorderColor
         .Cells(20).Value = sty.BorderSize
         .Cells(21).Value = sty.BorderStyle
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

See Also

SGStyle


Padding Property (SGStyle Object)

Padding Property (SGStyle Object)
Returns or sets the space between the contents and inside edges of cells.

Read/Write at run time and design time.

Syntax

object.Padding As OLE_XSIZE_CONTAINER

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example sets rows height to twice the text height. It also sets the CellPadding to one third of the text height. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   Dim sngTextHeight As Single

   SGGrid1.Array(0, 0) = "Sample text"

   Set Me.Font = SGGrid1.Styles("Normal").Font
   sngTextHeight = Me.TextHeight("W")
   SGGrid1.EqualRowHeight = True
   SGGrid1.Rows.At(1).Height = sngTextHeight * 2

   SGGrid1.CellPadding = sngTextHeight / 3

End Sub

Back to topic


PictureAlignment Property (SGStyle Object)

PictureAlignment Property (SGStyle Object)
Returns or sets picture alignment style.

Read/Write at run time and design time.

Syntax

object.PictureAlignment As sgPicAlignment

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The PictureAlignment settings are:

Name | Value | Description
sgPicAlignLeftTop | 0 | Align picture to the left-top position.
sgPicAlignCenterTop | 1 | Align picture to the center-top position.
sgPicAlignRightTop | 2 | Align picture to the right-top position.
sgPicAlignLeftCenter | 3 | Align picture to the left-center position.
sgPicAlignCenterCenter | 4 | Align picture to the center-center position.
sgPicAlignRightCenter | 5 | Align picture to the right-center position.
sgPicAlignLeftBottom | 6 | Align picture to the left-bottom position.
sgPicAlignCenterBottom | 7 | Align picture to the center-bottom position.
sgPicAlignRightBottom | 8 | Align picture to the right-bottom position.
sgPicAlignStretch | 9 | Picture is streched to fit cell content.
sgPicAlignTile | 10 | Picture is tiled to fit cell content.

Remarks

Show Example
Copy Code [image] Show Me

The following example shows different combination of a display type, picture and text alignment. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   Dim arAlign As Variant

   SGGrid1.RedrawEnabled = False

   SGGrid1.DataColCount = 4
   SGGrid1.DataRowCount = 120

   With SGGrid1.Columns.At(1)
   .Caption = "Sample"
      For j = 1 To SGGrid1.DataRowCount
         .ValueItems.Add j, "Item " & j, sgbipFirst + (j Mod 10)
         With SGGrid1.CellAt(j, 1)
            .Style.DisplayType = j Mod 3
            .Style.TextAlignment = j Mod 9
            .Style.PictureAlignment = j Mod 11
            .Value = j
         End With
      Next
   End With

   With SGGrid1.Columns.At(2)
      .Control.Type = sgCellDropList
      .Caption = "DisplayType"
      .ValueItems.Add 0, "Text"
      .ValueItems.Add 1, "TextAndPicture"
      .ValueItems.Add 2, "Picture"
      For j = 1 To SGGrid1.DataRowCount
         SGGrid1.CellAt(j, 2).Value = j Mod 3
      Next
   End With

   arAlign = Array("General", "LeftTop", "CenterTop", "RightTop", _
      "LeftCenter", "CenterCenter", "RightCenter", "LeftBottom", _
      "CenterBottom", "RightBottom", "Stretch", "Tile")

   With SGGrid1.Columns.At(3)
      .Caption = "TextAlign"
      .Control.Type = sgCellDropList
      For j = 0 To 9
         .ValueItems.Add j, arAlign(j)
      Next
      For j = 1 To SGGrid1.DataRowCount
         SGGrid1.CellAt(j, 3).Value = j Mod 4
      Next
   End With

   With SGGrid1.Columns.At(4)
      .Caption = "PictureAlign"
      .Control.Type = sgCellDropList
      For j = 1 To 11
         .ValueItems.Add j - 1, arAlign(j)
      Next
      For j = 1 To SGGrid1.DataRowCount
         SGGrid1.CellAt(j, 4).Value = j Mod 11
      Next
   End With
   SGGrid1.RedrawEnabled = True
End Sub

Private Sub SGGrid1_Change()
   Dim lRowDataIndex As Long

   If SGGrid1.Col = 1 Then Exit Sub

   lRowDataIndex = SGGrid1.Rows.Current.DataIndex

   SGGrid1.Update

   With SGGrid1.CellAt(SGGrid1.Row, 1)
      .Style.DisplayType = CLng(SGGrid1.Array.Value(lRowDataIndex, 1))
      .Style.TextAlignment = CLng(SGGrid1.Array.Value(lRowDataIndex, 2))
      .Style.PictureAlignment = CLng(SGGrid1.Array.Value(lRowDataIndex, 3))
      .Redraw
   End With

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic


ShadowColor Property

ShadowColor Property
Returns or sets a shadow color used when drawing 3D effects.

Read/Write at run time and design time.

Syntax

object.ShadowColor As OLE_COLOR

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Use the ShadowColor property to change the color of the right and bottom grid lines, when GridLines property is set to sgGridLineInset, sgGridLineRaised, sgGridLineInsetHorz, sgGridLineRaisedHorz, sgGridLineInsetVert or sgGridLineRaisedVert.


TextAlignment Property (SGStyle Object)

TextAlignment Property (SGStyle Object)
Returns or sets text alignment style.

Read/Write at run time and design time.

Syntax

object.TextAlignment As sgAlignment

The object placeholder represents an object expression that evaluates to the SGStyle object.

Settings

The TextAlignment settings are:

Name | Value | Description
sgAlignGeneral | 0 | Alignment is based on the underlying data type.
sgAlignLeftTop | 1 | Align to the left-top position.
sgAlignCenterTop | 2 | Align to the center-top position.
sgAlignRightTop | 3 | Align to the right-top position.
sgAlignLeftCenter | 4 | Align to the left-center position.
sgAlignCenterCenter | 5 | Align to the center-center position.
sgAlignRightCenter | 6 | Align to the right-center position.
sgAlignLeftBottom | 7 | Align to the left-bottom position.
sgAlignCenterBottom | 8 | Align to the center-bottom position.
sgAlignRightBottom | 9 | Align to the right-bottom position.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the TextAlignment property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()

   SGGrid1.HeadingTextAlignment = sgAlignCenterCenter
   SGGrid1.TextAlignment = sgAlignRightTop

   SGGrid1.CurrentCell.Column.Caption = "Caption"
   SGGrid1.CurrentCell.Value = "Text"

End Sub

Back to topic


Value Property (SGStyle Object)

Value Property (SGStyle Object)
Returns or sets style name. Read only for named styles.
Syntax

object.Value As Variant

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

SGGrid1.Columns.At(0).Style = SGGrid1.Styles("Normal")

-or-

SGGrid1.Columns.At(0).Style.Value = SGGrid1.Styles("Normal").Value

-or-

SGGrid1.Columns.At(0).Style.Value = "Normal"

-or-

SGGrid1.Columns.At(0).Style = "Normal"

The following code doesn't work:

Dim MyStyle As SGStyle

Set MyStyle = SGGrid1.Styles.Add("MyStyle")
MyStyle.Value = SGGrid1.Styles("Normal").Value

To make named style same as existing one use CopyFrom:

Dim MyStyle As SGStyle

Set MyStyle = SGGrid1.Styles.Add("MyStyle")
MyStyle.CopyFrom SGGrid1.Styles("Normal")

Show Example
Copy Code [image] Show Me

The following example enums all grid's styles and sets a each style to a each cell's style. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sty As SGStyle, cell As SGCell
   Dim iCol As Integer, lRow As Long

   SGGrid1.DataRowCount = 6
   SGGrid1.HeadingColCount = 0

   lRow = 1

   For Each sty In SGGrid1.Styles
      Set cell = SGGrid1.Rows.At(lRow). _
         Cells(iCol Mod SGGrid1.DataColCount)
      cell.Value = iCol & " " & sty.Name
      cell.Style.Value = sty
      iCol = iCol + 1
      If iCol Mod SGGrid1.DataColCount = 0 Then
         lRow = lRow + 1
      End If
   Next
End Sub

Back to topic


WordWrap Property (SGStyle Object)

WordWrap Property (SGStyle Object)
Enables or disables word wrapping for cell text.

Read/Write at run time and design time.

Syntax

object.WordWrap As Boolean

The object placeholder represents an object expression that evaluates to the SGStyle object.

Remarks

Show Example
Copy Code [image] Show Me

The following example sets the WordWrap property to the grid and heading. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub Form_Load()
   SGGrid1.WordWrap = True
   SGGrid1.HeadingWordWrap = True

   SGGrid1.Columns.At(1).Caption = "The little red caption"

   SGGrid1.Rows.At(0).Height = 505
   SGGrid1.Rows.At(1).Height = 505

   SGGrid1.Array.Value(0, 0) = "This is long dong text."
End Sub

Back to topic


SGStyle Methods

CopyFrom | Replaces all style attributes with specified style.
GetDefinition | Returns XML representation of the Style object.
Reset | Roll back all changes and use parent style values.
SetDefinition | Initializes Style object with XML string.


CopyFrom Method (SGStyle Object)

CopyFrom Method (SGStyle Object)
Replaces all style attributes with specified style.
Syntax

object.CopyFrom(Rhs As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGStyle object.
Rhs | A SGStyle object.

Remarks

Use the CopyFrom method to replace style attributes of the named styles. No-named styles also support this event, but for custom style rather use the Value property.

Show Example
Copy Code [image] Show Me

The following example enumerates all grid's styles and copies a each style to a cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sty As SGStyle, cell As SGCell
   Dim iCol As Integer, lRow As Long

   With SGGrid1
      'create cols and rows
      .DataColCount = 3
      .DataRowCount = 6
      .HeadingColCount = 0
      'hide GroupByBox
      .GroupByBoxVisible = False
   End With

   lRow = 1
   'enumerate all elements of the
   'Styles collection
   For Each sty In SGGrid1.Styles
      'reference next cell
      Set cell = SGGrid1.Rows.At(lRow). _
         Cells(iCol Mod SGGrid1.DataColCount)
      'display the name of the referenced style
      cell.Value = iCol & " " & sty.Name
      'copy the referenced style to cell's style
      cell.Style.CopyFrom sty
      'increment column index
      iCol = iCol + 1
      If iCol Mod SGGrid1.DataColCount = 0 Then
         'move to the next row
         lRow = lRow + 1
      End If
   Next
End Sub

Private Sub Command1_Click()
   SGGrid1.Styles.RemoveAll
   SGGrid1.Redraw
End Sub

Back to topic


Reset Method (SGStyle Object)

Reset Method (SGStyle Object)
Roll back all changes and use parent style values.
Syntax | object.Reset
Return Value | None
Arguments | None

Remarks

The Reset method roll back all changes and use parent style values.

Show Example
Copy Code [image] Show Me

The following example uses the MouseMove event and the HitTestObject method to reference the cell under the mouse pointer. It paints column and row of the referenced cell to green. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_MouseMove(Button As Integer, _
   Shift As Integer, x As Single, y As Single)
   Dim oCell As Variant       'current cell
   Static oExCell As SGCell   'last visited cell
   'check out if the mouse pointer is over a cell
   If SGGrid1.HitTestObject(x, y, oCell) = sgHitCell Then
      SGGrid1.RedrawEnabled = False

      If Not oExCell Is Nothing Then
         'exit if you move over the same cell
         If oExCell.ColKey = oCell.ColKey And _
            oExCell.RowKey = oCell.RowKey Then Exit Sub
         'reset styles of the previous cell's
         'row and column
         oExCell.Row.Style.Reset
         oExCell.Column.Style.Reset
      End If
      'paint column and row of the current cell
      oCell.Row.Style.BackColor = vbGreen
      oCell.Column.Style.BackColor = vbGreen
      'save reference of the current cell
      Set oExCell = oCell

      SGGrid1.RedrawEnabled = True
   End If
End Sub

Private Sub SGGrid1_OnInit()
   With SGGrid1
      'create rows and columns
      .DataColCount = 12
      .DataRowCount = 100
      'hide GroupByBox
      .GroupByBoxVisible = False
   End With
End Sub

Back to topic


SGStyles Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGStyles Object

Name: | SGStyles
Description: | Collection of SGStyle objects.
GUID: | {EA2CE604-9388-11D2-8EC1-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example uses the Styles collection to access each style. It fills the grid with style properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sty As SGStyle, i As Integer
   Dim lRow As Long

   With SGGrid1
      .RedrawEnabled = False

      .Columns.RemoveAll True

      .DataColCount = 22
      .DataRowCount = .Styles.Count
      'create columns with style properties
      .Columns(1).Caption = "Style Name"
      .Columns(2).Caption = "Backcolor"
      .Columns(3).Caption = "Forecolor"
      .Columns(4).Caption = "Base Style"
      .Columns(5).Caption = "Font name"
      .Columns(6).Caption = "Font size"
      .Columns(6).Style.TextAlignment = sgAlignRightCenter
      For i = 7 To 10
         .Columns(i).Caption = _
            Choose(i - 6, "Bold", "Italic", "Underline", "Strikethrough")
         .Columns(i).Control.Type = sgCellCheckBox
         .Columns(i).Style.TextAlignment = sgAlignCenterCenter
         .HeadingTextAlignment = sgAlignCenterCenter
      Next
      .Columns(11).Caption = "Format"
      .Columns(12).Caption = "Appearance"
      With .Columns(12).ValueItems
         .Add 1, "3D"       'sg3D
         .Add 2, "3D Light"  'sg3DLight
      End With
      .Columns(13).Caption = "DisplayType"
      .Columns(13).ValueItems.Add 0, "Text"     'sgDisplayText
      .Columns(14).Caption = "TextAlignment"
      With .Columns(14).ValueItems
         .Add 0, "General"             'sgAlignGeneral
         .Add 4, "Left-Center"       'sgAlignLeftCenter
         .Add 5, "Center-Center"       'sgAlignCenterCenter
      End With
      .Columns(15).Caption = "PictureAlignment"
      .Columns(15).ValueItems.Add 3, "Left-Center"     'sgPicAlignLeftCenter
      .Columns(16).Caption = "Padding"
      .Columns(17).Caption = "WordWrap"
      .Columns(17).Control.Type = sgCellCheckBox
      .Columns(17).Style.TextAlignment = sgAlignCenterCenter
      .Columns(18).Caption = "Ellipsis"
      .Columns(18).ValueItems.Add 1, "Ellipsis End"     'sgEllipsisEnd
      .Columns(19).Caption = "Borders"
      With .Columns(19).ValueItems
         .Add 15, "All"       'sgCellBorderAll
         .Add 0, "No Border"  'sgCellNoBorder
      End With
      .Columns(20).Caption = "Border Color"
      .Columns(21).Caption = "Border Size"
      .Columns(22).Caption = "Border Style"
      With .Columns(22).ValueItems
         .Add 1, "Solid"      'sgCellBorderSolid
      End With
   End With
   'enum styles end show values for each property
   For Each sty In SGGrid1.Styles
      lRow = lRow + 1
      With SGGrid1.Rows.At(lRow)
         .Cells(0).Value = sty.Name
         .Cells(1).Style.BackColor = sty.BackColor
         .Cells(2).Style.BackColor = sty.ForeColor
         .Cells(3).Value = sty.BaseStyle
         .Cells(4).Value = sty.Font.Name
         .Cells(5).Value = sty.Font.Size
         .Cells(6).Value = sty.Font.Bold
         .Cells(7).Value = sty.Font.Italic
         .Cells(8).Value = sty.Font.Underline
         .Cells(9).Value = sty.Font.Strikethrough
         .Cells(10).Value = sty.Format
         .Cells(11).Value = sty.Appearance
         .Cells(12).Value = sty.DisplayType
         .Cells(13).Value = sty.TextAlignment
         .Cells(14).Value = sty.PictureAlignment
         .Cells(15).Value = sty.Padding
         .Cells(16).Value = sty.WordWrap
         .Cells(17).Value = sty.Ellipsis
         .Cells(18).Value = sty.Borders
         .Cells(19).Style.BackColor = sty.BorderColor
         .Cells(20).Value = sty.BorderSize
         .Cells(21).Value = sty.BorderStyle
      End With
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

Referenced By

Styles


SGStyles Properties

Count | Returns the number of SGStyle objects in the collection
Grid | Returns parent SGGrid object.
Item | Returns specified style object


SGStyles Methods

Add | Adds new style object to the collection and returns a reference to the newly created object.
Contains | Returns true if style with specified name exists in the collection
CopyFrom | Replaces contained styles with styles from another collection
GetDefinition | Returns XML representation of the Styles collection.
RemoveAll | Removes all style objects from the collection.
RemoveCustom | Removes all unnamed styles from the grid.
Remove | Removes specified style from the collection.
SetDefinition | Initializes Styles collection with XML string.


Add Method (SGStyles Collection)

Add Method (SGStyles Collection)
Adds new style object to the collection and returns a reference to the newly created object.
Syntax

object.Add(StyleName As String)

Return Value A SGStyle object.
Arguments
object | An object expression that evaluates to the SGStyles object.
StyleName | A String expression that represents the Name of the style.

Remarks

The Add method adds a new style object to the collection and returns a reference to the newly created object. Use style name to reference style. Be carefully because the Name property is case sensitive.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to create new named style. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_Click()

   If Not SGGrid1.Styles.Contains("NewStyle") Then
      SGGrid1.Styles.Add "NewStyle"
      With SGGrid1.Styles("NewStyle")
         .CopyFrom SGGrid1.Styles("Heading")
         .BackColor = vbRed
         .BackColor2 = vbYellow
         .BorderColor = vbYellow
         .BorderSize = 15
         .BkgStyle = sgCellBkgGradientVertical
      End With
   End If

   With SGGrid1.Rows.Current
      .Style = "NewStyle"
      .Redraw
   End With
End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 5
   SGGrid1.DataRowCount = 20
End Sub

Back to topic


Contains Method (SGStyles Collection)

Contains Method (SGStyles Collection)
Returns true if style with specified name exists in the collection
Syntax

object.Contains(StyleName As String)

Return Value An Boolean value indicating whether a style with specified name exists in the collection.
Arguments
object | An object expression that evaluates to the SGStyles object.
StyleName | A String expression that represents the Name of the style.

Remarks

Use this method to check out if specified name exists in the collection. Typically, use the Contains method before you add new style to the SGStyles collection.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to create new named style. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_Click()

   If Not SGGrid1.Styles.Contains("NewStyle") Then
      SGGrid1.Styles.Add "NewStyle"
      With SGGrid1.Styles("NewStyle")
         .CopyFrom SGGrid1.Styles("Heading")
         .BackColor = vbRed
         .BackColor2 = vbYellow
         .BorderColor = vbYellow
         .BorderSize = 15
         .BkgStyle = sgCellBkgGradientVertical
      End With
   End If

   With SGGrid1.Rows.Current
      .Style = "NewStyle"
      .Redraw
   End With
End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 5
   SGGrid1.DataRowCount = 20
End Sub

Back to topic


CopyFrom Method (SGStyles Collection)

CopyFrom Method (SGStyles Collection)
Replaces contained styles with styles from another collection
Syntax

object.CopyFrom(newStyles As IsgStyles)

Return Value None
Arguments
object | An object expression that evaluates to the SGStyles object.
newStyles | A SGStyles object.

Remarks

Typically, use this method to copy styles from one BeeGrid control to another.

Show Example
Copy Code [image] Show Me

The following example changes the Normal style in the first grid and copies the styles from the first grid to the second.

Private Sub SGGrid1_OnInit()
   SGGrid1.Styles("Normal").BackColor = vbGreen

   SGGrid2.Styles.CopyFrom SGGrid1.Styles
End Sub

Back to topic

See Also

SGStyles


Remove Method (SGStyles Collection)

Remove Method (SGStyles Collection)
Removes specified style from the collection.
Syntax

object.Remove(StyleName As String)

Return Value None
Arguments
object | An object expression that evaluates to the SGStyles object.
StyleName | A String expression that represents the Name of the style.

Remarks

This method removes named styles from the SGStyles collection. To remove unnamed styles use the RemoveCustom method. You cannot remove built-in styles.


RemoveAll Method (SGStyles Collection)

RemoveAll Method (SGStyles Collection)
Removes all style objects from the collection.
Syntax | object.RemoveAll
Return Value | None
Arguments | None

Remarks

This method removes all named styles from the SGStyles collection. To remove unnamed styles use the RemoveCustom method. You cannot remove built-in styles.

Show Example
Copy Code [image] Show Me

The following example enumerates all grid's styles and copies a each style to a cell. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sty As SGStyle, cell As SGCell
   Dim iCol As Integer, lRow As Long

   With SGGrid1
      'create cols and rows
      .DataColCount = 3
      .DataRowCount = 6
      .HeadingColCount = 0
      'hide GroupByBox
      .GroupByBoxVisible = False
   End With

   lRow = 1
   'enumerate all elements of the
   'Styles collection
   For Each sty In SGGrid1.Styles
      'reference next cell
      Set cell = SGGrid1.Rows.At(lRow). _
         Cells(iCol Mod SGGrid1.DataColCount)
      'display the name of the referenced style
      cell.Value = iCol & " " & sty.Name
      'copy the referenced style to cell's style
      cell.Style.CopyFrom sty
      'increment column index
      iCol = iCol + 1
      If iCol Mod SGGrid1.DataColCount = 0 Then
         'move to the next row
         lRow = lRow + 1
      End If
   Next
End Sub

Private Sub Command1_Click()
   SGGrid1.Styles.RemoveAll
   SGGrid1.Redraw
End Sub

Back to topic


RemoveCustom Method (SGStyles Collection)

RemoveCustom Method (SGStyles Collection)
Removes all unnamed styles from the grid.
Syntax | object.RemoveCustom
Return Value | None
Arguments | None

Remarks

This method removes all unnamed styles. To remove all named styles use the RemoveAll method.

Show Example
Copy Code [image] Show Me

The following example uses the AfterScroll event to paint a column placed at the middle of grid to blue. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_AfterScroll(ByVal OldTopRow As Long, _
   ByVal OldLeftCol As Long, ByVal NewTopRow As Long, _
   ByVal NewLeftCol As Long)
   Dim col As SGColumn
   Dim lPoint As Long
   'get midlle point
   lPoint = SGGrid1.ClientWidth / 2
   lPoint = lPoint + SGGrid1.Columns(SGGrid1.LeftCol).Left
   'repaint columns to the default color
   SGGrid1.Styles.RemoveCustom
   'get a column placed at the midlle of grid
   'and paint it blue
   For Each col In SGGrid1.Columns
      If col.Left <= lPoint And col.Right >= lPoint Then
         col.Style.BackColor = vbBlue
         Exit For
      End If
   Next
End Sub

Private Sub SGGrid1_OnInit()
   'create columns
   SGGrid1.DataColCount = 12

   SGGrid1_AfterScroll 0, 0, 0, 0
End Sub

Back to topic


SGStyleCondition Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGStyleCondition Object

Name: | SGStyleCondition
Description: | SGStyleCondition encapsulates style object and condition that determines when to apply that style.
GUID: | {28D20E78-4F3A-11D3-B75C-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers and creates a StyleCondition for each possible cell value. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sStyleName As String
   Dim i As Long, j As Long
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   'create cols and rows
   SGGrid1.DataRowCount = 20
   SGGrid1.DataColCount = 3
   'create 256 styles
   For i = 0 To 255
      sStyleName = "Style" & Trim$(i)
      With SGGrid1.Styles.Add(sStyleName)
         .CopyFrom SGGrid1.Styles("Normal")
         .BackColor = RGB(255 - i, 255 - i, 255 - i)
         .ForeColor = RGB(255, i, 0)
         .Font.Bold = True
      End With
      'add new style in the StyleConditions collection
      SGGrid1.CellStyleConditions.Add _
         sStyleName, sgConditionCellValue, sgOpEqual, i
   Next

   Set ar = SGGrid1.Array
   'add test data
   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 255)
      Next
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

Referenced By

SGStyleConditions.Item


SGStyleCondition Properties

ConditionColKey | Returns the key of the column whose value is used as a left-side value when evaluating condition.
Condition | Returns condition object.
Grid | Returns parent SGGrid object.
Index | Returns the index of a condition object in a collection.
StyleName | Returns name of the style.
ValueSource | Returns a value indicating source of the value used when evaluating condition.


Condition Property (SGStyleCondition Object)

Condition Property (SGStyleCondition Object)
Returns condition object.

Read-only at run time. Not available at design time.

Syntax

object.Condition As IsgCondition

The object placeholder represents an object expression that evaluates to the SGStyleCondition object.

Remarks

See Also

SGStyleCondition


ConditionColKey Property (SGStyleCondition Object)

ConditionColKey Property (SGStyleCondition Object)
Returns the key of the column whose value is used as a left-side value when evaluating condition.
Syntax

object.ConditionColKey As String

The object placeholder represents an object expression that evaluates to the SGStyleCondition object.

Remarks

You can use this property only in RowStyleConditions collection. This property is ignored if you use it in the StyleConditions collection of the SGColumn object.
In the code below the ConditionColKey property is ignored:

   SGGrid1.Columns("Day").StyleConditions.Add "Tip", _
      sgConditionCellValue, sgOpGreaterThan, 1000, , "Amount"

Show Example
Copy Code [image] Show Me

The following example uses the RowStyleConditions collection to paint all rows where the value of the Amount column is greater then 1000. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim ar As SGArray, dtDay As Date
   Dim i As Integer, lFirstDay As Long

   SGGrid1.FitLastColumn = True
   'create columns and rows
   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 100

   With SGGrid1.Columns.Add("Day")
      .DataType = sgtDateTime
   End With

   With SGGrid1.Columns.Add("Amount")
      .DataType = sgtCurrency
   End With

   lFirstDay = CLng(DateSerial(Year(Now), 1, 1))
   'populate grid with sample data
   Set ar = SGGrid1.Array
   For i = 0 To ar.RowCount - 1
      'get random date
      dtDay = CDate(lFirstDay + 365 * Rnd)
      ar.Value(i, 0) = FormatDateTime(dtDay, vbShortDate)
      ar.Value(i, 1) = Round((Rnd * 2000), 2)
   Next

   With SGGrid1.Styles.Add("Over1000")
      .BackColor = RGB(255, 255, 240)
      .BkgStyle = sgCellBkgGradientVertical
      .Borders = sgCellBorderBottom
      .BorderColor = RGB(128, 0, 0)
      .BorderSize = 15
   End With

   SGGrid1.RowStyleConditions.Add "Over1000", _
      sgConditionCellValue, sgOpGreaterThan, 1000, , "Amount"

End Sub

Back to topic


Index Property (SGStyleCondition Object)

Index Property (SGStyleCondition Object)
Returns the index of a condition object in a collection.

Read-only at run time. Not available at design time.

Syntax

object.Index As Long

The object placeholder represents an object expression that evaluates to the SGStyleCondition object.

Remarks

This property returns the one-based index that uniquely identifies the SGStyleCondition object in the SGStyleConditions collection.

The Index property is set to the order of the creation of objects in a collection. The index for the first object in a collection will always be one (1).

See Also

SGStyleCondition


StyleName Property (SGStyleCondition Object)

StyleName Property (SGStyleCondition Object)
Returns name of the style.

Read/Write at run time. Not available at design time.

Syntax

object.StyleName As String

The object placeholder represents an object expression that evaluates to the SGStyleCondition object.

Remarks

See Also

SGStyleCondition


ValueSource Property (SGStyleCondition Object)

ValueSource Property (SGStyleCondition Object)
Returns a value indicating source of the value used when evaluating condition.

Read/Write at run time. Not available at design time.

Syntax

object.ValueSource As sgConditionValueSource

The object placeholder represents an object expression that evaluates to the SGStyleCondition object.

Settings

The ValueSource settings are:

Name | Value | Description
sgConditionCellValue | 0 | Use cell value when evaluating condition.
sgConditionCellStatus | 1 | Use cell status when evaluating condition.
sgConditionColPosition | 2 | Use column position when evaluating condition.
sgConditionColIndex | 3 | Use column index when evaluating condition.
sgConditionColKey | 4 | Use column key when evaluating condition.
sgConditionRowPosition | 5 | Use row position when evaluating condition.
sgConditionRowKey | 6 | Use row key when evaluating condition.
sgConditionRowBookmark | 7 | Use row bookmark when evaluating condition.
sgConditionRowStatus | 8 | Use row status when evaluating condition.

Remarks

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the Add method of the StyleConditions collection to set the ValueSource property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   With SGGrid1
      .DataColCount = 4
      .DataRowCount = 10

      With .Styles.Add("Red")
         .BackColor = RGB(128, 0, 0)
      End With
      .Columns(1).StyleConditions.Add "Red", _
         sgConditionRowStatus, sgOpEqual, sgCellStatusCurrent

      With .Styles.Add("Green")
         .BackColor = RGB(0, 128, 0)
      End With
      .Columns(2).StyleConditions.Add "Green", _
         sgConditionRowStatus, sgOpEqual, sgCellStatusCurrent

      With .Styles.Add("Blue")
         .BackColor = RGB(0, 0, 128)
      End With
      .Columns(3).StyleConditions.Add "Blue", _
         sgConditionRowStatus, sgOpEqual, sgCellStatusCurrent

      With .Styles.Add("Yellow")
         .BackColor = vbYellow
      End With
      .Columns(4).StyleConditions.Add "Yellow", _
         sgConditionRowStatus, sgOpEqual, sgCellStatusCurrent
   End With
End Sub

Back to topic

See Also

SGStyleCondition


SGStyleConditions Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGStyleConditions Object

Name: | SGStyleConditions
Description: | Collection of SGStyleCondition objects.
GUID: | {28D20E79-4F3A-11D3-B75C-008048E27A77}

Remarks

Each SGStyleCondition in the collection can be accessed by its index.

Use the Add method to add SGStyleCondition object to the collection:

   SGGrid1.CellStyleConditions.Add "Heading", sgConditionCellValue, sgOpRegEx, "^a"

Show Example
Copy Code [image] Show Me

The following example fills the grid array with random numbers and creates a StyleCondition for each possible cell value. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim sStyleName As String
   Dim i As Long, j As Long
   Dim ar As SGArray

   SGGrid1.RedrawEnabled = False
   SGGrid1.GroupByBoxVisible = False
   'create cols and rows
   SGGrid1.DataRowCount = 20
   SGGrid1.DataColCount = 3
   'create 256 styles
   For i = 0 To 255
      sStyleName = "Style" & Trim$(i)
      With SGGrid1.Styles.Add(sStyleName)
         .CopyFrom SGGrid1.Styles("Normal")
         .BackColor = RGB(255 - i, 255 - i, 255 - i)
         .ForeColor = RGB(255, i, 0)
         .Font.Bold = True
      End With
      'add new style in the StyleConditions collection
      SGGrid1.CellStyleConditions.Add _
         sStyleName, sgConditionCellValue, sgOpEqual, i
   Next

   Set ar = SGGrid1.Array
   'add test data
   For i = 0 To SGGrid1.DataRowCount - 1
      For j = 0 To SGGrid1.DataColCount - 1
         ar.Value(i, j) = CLng(Rnd * 255)
      Next
   Next

   SGGrid1.RedrawEnabled = True
End Sub

Back to topic

Referenced By


SGStyleConditions Properties

Count | Returns the number of SGStyleCondition objects in the collection.
Grid | Returns parent SGGrid object.
Item | Returns specified SGStyleCondition object.


SGStyleConditions Methods

Add | Adds new style condition.
GetDefinition | Returns XML representation of the StyleConditions collection.
RemoveAll | Removes all style conditions from the collection.
Remove | Removes specified style condition from the collection.
SetDefinition | Initializes StyleConditions collection with XML string.


Add Method (SGStyleConditions Collection)

Add Method (SGStyleConditions Collection)
Adds new style condition.
Syntax

object.Add(StyleName As String, ValueSource As sgConditionValueSource, Op As sgOperator, Val1 As Variant, [Val2] As Variant, [ColKey] As Variant)

Return Value A SGStyleCondition object.
Arguments
object | An object expression that evaluates to the SGStyleConditions object.
StyleName | A String expression that represents the Name of the style.
ValueSource | An sgConditionValueSource expression that sets condition value source. The possible values are listed in Settings.
Op | An sgOperator expression that sets the operator to be used when evaluating condition. Check out pattern syntax if you use regular expression (sgOpRegEx). The possible values are listed in Settings.
Val1 | A Variant expression that contains the first right-side value to be used when evaluating condition criteria.
Val2 | Optional. A Variant expression that contains the second right-side value to be used for a condition criteria. This argument is used only if the operator is set to sgOpBetween.
ColKey | Optional. A String expression that represents the Key of the column.

Settings

The settings for Op are:

Name | Value | Description
sgOpFalse | 0 | Always fail.
sgOpTrue | 1 | Always succeed.
sgOpLessThan | 2 | Succeeds if the left-side value is smaller then the right-side value.
sgOpLessThanOrEqual | 3 | Succeeds if the left-side value is smaller than or equal to the right-side value.
sgOpGreaterThan | 4 | Succeeds if the left-side value is greater then the right-side value.
sgOpGreaterThanOrEqual | 5 | Succeeds if the left-side value is greater then or equal to the right-side value.
sgOpEqual | 6 | Succeeds if the left-side value is equal to the right-side value.
sgOpBetween | 7 | Succeeds if the left-side value is both greater then the first right-side value and smaller or equal to the second right-side value.
sgOpContains | 8 | Succeeds if left-side value is contained in the right-side value. Applies only to string and integral (byte, short, long, int64) types.
sgOpRegEx | 9 | Succeeds if regular expression is matched. Applies only to string values.
sgOpCallback | 10 | Uses IsgConditionTest interface to test a value.
sgOpNot | 16384 | Negates operator. Can be used only in combination with some other operator.
The settings for ValueSource are:

Name | Value | Description
sgConditionCellValue | 0 | Use cell value when evaluating condition.
sgConditionCellStatus | 1 | Use cell status when evaluating condition.
sgConditionColPosition | 2 | Use column position when evaluating condition.
sgConditionColIndex | 3 | Use column index when evaluating condition.
sgConditionColKey | 4 | Use column key when evaluating condition.
sgConditionRowPosition | 5 | Use row position when evaluating condition.
sgConditionRowKey | 6 | Use row key when evaluating condition.
sgConditionRowBookmark | 7 | Use row bookmark when evaluating condition.
sgConditionRowStatus | 8 | Use row status when evaluating condition.

Remarks

To achieve the maximum speed, the types of the Val1 and Val2 parameters should match the type of the value retrieved from the ValueSource. If either of the Val1 or the Val2 parameters cannot be converted to the type of the ValueSource value, style is not applied.


Remove Method (SGStyleConditions Collection)

Remove Method (SGStyleConditions Collection)
Removes specified style condition from the collection.
Syntax

object.Remove(Index As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGStyleConditions object.
Index | An integer that uniquely identifies the object within the collection.

Remarks

To remove all SGStyleCondition objects from the SGStyleConditions collection use the RemoveAll method.


RemoveAll Method (SGStyleConditions Collection)

RemoveAll Method (SGStyleConditions Collection)
Removes all style conditions from the collection.
Syntax | object.RemoveAll
Return Value | None
Arguments | None

Remarks

To remove a particular SGStyleCondition object from the SGStyleConditions collection use the Remove method.


SGValueItem Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGValueItem Object

Name: | SGValueItem
Description: | SGValueItem contains translation from database to display value and picture.
GUID: | {240E3C92-C2A4-11D2-8EFF-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example uses the CellAsPicture property to create pictures for a value items. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim rs As New ADODB.Recordset
   Dim i As Integer

   rs.Fields.Append "Id", adInteger
   rs.Fields.Append "Caption", adBSTR, 50

   rs.Open

   For i = 1 To 10
      rs.AddNew
      rs!Id = i
      rs!Caption = "Item " & Trim(i)
      rs.Update
   Next

   SGGrid1.DataMode = sgBound
   Set SGGrid1.DataSource = rs

   With SGGrid1.Columns("Id")
      .Width = 2000
      .Control.Type = sgCellDropList
      .HeadingStyle.TextAlignment = sgAlignLeftCenter
      .Style.TextAlignment = sgAlignLeftCenter
      .Control.PopupStyle.TextAlignment = sgAlignLeftCenter
      While Not rs.EOF
         'if you try to add value items with the code
         'below the grid will accept field object not string
         '.ValueItems.Add rs!Id, rs!Caption
         'just convert it to long/string
         .ValueItems.Add CLng(rs!Id), CStr(rs!Caption)
         rs.MoveNext
      Wend
   End With

   rs.MoveFirst
End Sub

Back to topic

Referenced By

SGValueItems.Item


SGValueItem Properties

DisplayPicture | Returns display picture.
DisplayValue | Returns display value.
Index | Returns the index of a ValueItem object in a collection.
Value | Returns data value.


DisplayPicture Property (SGValueItem Object)

DisplayPicture Property (SGValueItem Object)
Returns display picture.

Read-only at run time. Not available at design time.

Syntax

object.DisplayPicture As Variant

The object placeholder represents an object expression that evaluates to the SGValueItem object.

Remarks

This property is a variant expression that represent picture. You can pass Picture object or long expression that represents the index of the image from the grid image list Images. You can also use the grid's buil-in pictures using values from sgbipFirst to sgbipLast.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the SGValueItem object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim vis As SGValueItems
   Dim vi As SGValueItem
   Dim ar As SGArray

   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 12
   'create columns
   With SGGrid1.Columns.Add("Month")
      .Caption = "Month"
      .Control.Type = sgCellDropList
      .Control.SortOrder = sgNoSorting
      .ValueItems.Translate = True
      'add months to the value items coll.
      For i = 1 To 12
         .ValueItems.Add i, MonthName(i), sgbipFirst + i
      Next
      .ValueItems.Default = Month(Now) - 1
   End With

   With SGGrid1.Columns.Add("Value")
      .DataType = sgtLong
   End With

   SGGrid1.Columns.Add "DisplayValue"
   SGGrid1.Columns.Add "DisplayPicture"

   i = 0
   Set vis = SGGrid1.Columns("Month").ValueItems
   Set ar = SGGrid1.Array

   For Each vi In vis
      ar.Value(i, 1) = vi.Value
      ar.Value(i, 2) = vi.DisplayValue
      ar.Value(i, 3) = vi.DisplayPicture
      i = i + 1
   Next

   Set ar = Nothing
   Set vis = Nothing
End Sub

Back to topic


DisplayValue Property (SGValueItem Object)

DisplayValue Property (SGValueItem Object)
Returns display value.

Read-only at run time. Not available at design time.

Syntax

object.DisplayValue As Variant

The object placeholder represents an object expression that evaluates to the SGValueItem object.

Remarks

This property returns the translated data value for a SGValueItem.

The Grid will display the DisplayValue only if the Translate property is set to True or if a cell is in the editing mode.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the SGValueItem object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim vis As SGValueItems
   Dim vi As SGValueItem
   Dim ar As SGArray

   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 12
   'create columns
   With SGGrid1.Columns.Add("Month")
      .Caption = "Month"
      .Control.Type = sgCellDropList
      .Control.SortOrder = sgNoSorting
      .ValueItems.Translate = True
      'add months to the value items coll.
      For i = 1 To 12
         .ValueItems.Add i, MonthName(i), sgbipFirst + i
      Next
      .ValueItems.Default = Month(Now) - 1
   End With

   With SGGrid1.Columns.Add("Value")
      .DataType = sgtLong
   End With

   SGGrid1.Columns.Add "DisplayValue"
   SGGrid1.Columns.Add "DisplayPicture"

   i = 0
   Set vis = SGGrid1.Columns("Month").ValueItems
   Set ar = SGGrid1.Array

   For Each vi In vis
      ar.Value(i, 1) = vi.Value
      ar.Value(i, 2) = vi.DisplayValue
      ar.Value(i, 3) = vi.DisplayPicture
      i = i + 1
   Next

   Set ar = Nothing
   Set vis = Nothing
End Sub

Back to topic


Index Property (SGValueItem Object)

Index Property (SGValueItem Object)
Returns the index of a ValueItem object in a collection.

Read-only at run time. Not available at design time.

Syntax

object.Index As Long

The object placeholder represents an object expression that evaluates to the SGValueItem object.

Remarks

This property returns the one-based index that uniquely identifies the SGValueItem object in the SGValueItems collection.

The Index property is set to the order of the creation of objects in a collection. The index for the first object in a collection will always be one (1).

See Also

SGValueItem


Value Property (SGValueItem Object)

Value Property (SGValueItem Object)
Returns data value.

Read-only at run time. Not available at design time.

Syntax

object.Value As Variant

The object placeholder represents an object expression that evaluates to the SGValueItem object.

Remarks

If the Value is not unique, an error will occur.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the SGValueItem object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim vis As SGValueItems
   Dim vi As SGValueItem
   Dim ar As SGArray

   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 12
   'create columns
   With SGGrid1.Columns.Add("Month")
      .Caption = "Month"
      .Control.Type = sgCellDropList
      .Control.SortOrder = sgNoSorting
      .ValueItems.Translate = True
      'add months to the value items coll.
      For i = 1 To 12
         .ValueItems.Add i, MonthName(i), sgbipFirst + i
      Next
      .ValueItems.Default = Month(Now) - 1
   End With

   With SGGrid1.Columns.Add("Value")
      .DataType = sgtLong
   End With

   SGGrid1.Columns.Add "DisplayValue"
   SGGrid1.Columns.Add "DisplayPicture"

   i = 0
   Set vis = SGGrid1.Columns("Month").ValueItems
   Set ar = SGGrid1.Array

   For Each vi In vis
      ar.Value(i, 1) = vi.Value
      ar.Value(i, 2) = vi.DisplayValue
      ar.Value(i, 3) = vi.DisplayPicture
      i = i + 1
   Next

   Set ar = Nothing
   Set vis = Nothing
End Sub

Back to topic


SGValueItems Object

Referenced By [image] Properties [image] Methods Send us your Feedback
SGValueItems Object

Name: | SGValueItems
Description: | Collection of SGValueItem objects
GUID: | {240E3C93-C2A4-11D2-8EFF-008048E27A77}

Show Example
Copy Code [image] Show Me

The following example uses the CellAsPicture property to create pictures for a value items. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim Row As SGRow, vis As SGValueItems
   Dim sColorColKey As String
   Dim i As Integer, lRowKey As Long

   With SGGrid1
      'create rows and cols
      .DataRowCount = 16
      .DataColCount = 3
      .RowNumbering = True
   End With
   'customize columns
   With SGGrid1.Columns
      With .At(1)
         .HeadingPicture = sgbipFirst + 2
         .ReadOnly = True
         .AllowSizing = False
         .AllowFocus = False
         .Style.Borders = sgCellBorderAll
         .Style.BorderSize = 3
         .Width = 255
         sColorColKey = .Key
      End With
      .At(2).Caption = "Color"
      With .At(3)
         Set vis = .ValueItems
         .Control.Type = sgCellDropDown
         .Style.PictureAlignment = sgPicAlignLeftCenter
         .Style.DisplayType = sgDisplayPicture
         .HeadingStyle.DisplayType = sgDisplayText
         .Caption = "Color combo"
      End With
   End With

   For i = 0 To 15
      lRowKey = SGGrid1.Rows.At(i + 1).Key
      SGGrid1.cell(lRowKey, sColorColKey).Style.BackColor = QBColor(i)
      SGGrid1.Array.Value(i, 1) = QBColor(i)
      vis.Add QBColor(i), "&H" & _
         QBColor(i) & "&", SGGrid1.CellAsPicture(lRowKey, sColorColKey)
   Next

   Set vis = Nothing
End Sub

Back to topic

Referenced By

SGColumn.ValueItems


SGValueItems Properties

Count | Returns number of value items in the collection.
CycleOnClick | Returns or sets a value indicating whether clicking on a cell cycles through value items.
Default | Returns or sets zero based index of default value item.
DisplayItem | Returns first SGValueItem object that has specified display value.
Item | Returns specified value item object
LimitToList | Indicates whether to accept user input only if it matches one of the value items.
Translate | Indicates whether data values are translated to display values.
ValueItem | Returns SGValueItem object associated with specified data value.


CycleOnClick Property (SGValueItems Collection)

CycleOnClick Property (SGValueItems Collection)
Not yet implemented.

Read/Write at run time and design time.

Syntax

object.CycleOnClick As Boolean

The object placeholder represents an object expression that evaluates to the SGValueItems object.

Remarks

This property determines whether the user can cycle through value items by clicking on the current cell. If the last value item is displayed, next click displays the first item in the collection.

See Also

SGValueItems


Default Property (SGValueItems Collection)

Default Property (SGValueItems Collection)
Returns or sets zero based index of default value item.

Read/Write at run time and design time.

Syntax

object.Default As Long

The object placeholder represents an object expression that evaluates to the SGValueItems object.

Remarks

The grid uses this property to provide an alternate display for data values not present in the SGValueItems collection.

By default, this property is set to - 1, that means there is no default item.

Show Example
Copy Code [image] Show Me

The following example creates new column and ads months to the ValueItems collection. The current month is set as default. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.AllowAddNew = True

   With SGGrid1.Columns.Add("Month")
      .Caption = "Month"
      .Control.Type = sgCellDropList
      .Control.SortOrder = sgNoSorting
      .ValueItems.Translate = True
      For i = 1 To 12
         .ValueItems.Add i, MonthName(i)
      Next
      .ValueItems.Default = Month(Now) - 1
   End With

End Sub

Back to topic


DisplayItem Property (SGValueItems Collection)

DisplayItem Property (SGValueItems Collection)
Returns first SGValueItem object that has specified display value.

Read-only at run time. Not available at design time.

Syntax

object.DisplayItem As IsgValueItem

The object placeholder represents an object expression that evaluates to the SGValueItems object.

Arguments
DisplayValue A Variant expression that represents the DisplayValue property of the returned SGValueItem object.

Remarks

Show Example
Copy Code [image] Show Me

The following example shows how to use the DisplayItem property. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5. Move the mouse-pointer over the "Month" column to open the tool-tip window.

Private Sub SGGrid1_FetchCellTip _
   (ByVal RowKey As Long, ByVal ColIndex As Long, _
   ByVal CellKind As sgCellKind, _
   Width As stdole.OLE_XSIZE_CONTAINER, _
   Height As stdole.OLE_YSIZE_CONTAINER, _
   CellTipText As String, Picture As Variant, _
   ByVal TipStyle As IsgStyle)

   If SGGrid1.Columns(ColIndex).Key = "Month" Then
      Dim cell As SGCell
      Dim iMonth As Integer
      Dim vi As SGValueItem

      Set cell = SGGrid1.cell(RowKey, "Month")
      'exit if cell is empty or if cell is heading
      If Len(cell.Value) = 0 Or cell.Row.Heading Then Exit Sub
      'use DisplayItem to get reference to the value item
      Set vi = cell.Column.ValueItems.DisplayItem(cell.Value)
      'display value item value and picture in tool tip
      iMonth = vi.Value
      CellTipText = Trim(iMonth) & ". month"
      Picture = vi.DisplayPicture

      Set vi = Nothing
      Set cell = Nothing
   End If
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer

   SGGrid1.AllowAddNew = True
   'enable tool tips
   SGGrid1.CellTips = sgCellTipsFloat
   SGGrid1.CellTipsDelay = 100
   'create new column
   With SGGrid1.Columns.Add("Month")
      .Caption = "Month"
      .Control.Type = sgCellDropList
      .Control.SortOrder = sgNoSorting
      .ValueItems.Translate = True
      'add months to the value items coll.
      For i = 1 To 12
         .ValueItems.Add i, MonthName(i), sgbipFirst + i
      Next
      .ValueItems.Default = Month(Now) - 1
   End With

End Sub

Back to topic


LimitToList Property (SGValueItems Collection)

LimitToList Property (SGValueItems Collection)
Indicates whether to accept user input only if it matches one of the value items.

Read/Write at run time and design time.

Syntax

object.LimitToList As Boolean

The object placeholder represents an object expression that evaluates to the SGValueItems object.

Remarks

If it's False the user can enters any data. Otherwise, if the user enter data not in SGValueItems collection the grid fires the ValueItemError event. You can use this event to add new entry into the SGValueItems collection or to prevent the user to enter data not in collection.

If you want to prevent the user to add data not in the SGValueItems collection set the column's control Type property to sgCellDropList.

Show Example
Copy Code [image] Show Me

The following example uses the ValueItemError event to add new element into the SGValueItems collection. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 1
   SGGrid1.AllowAddNew = True
   SGGrid1.Columns(1).Control.Type = sgCellDropDown
   'add two items to the ValueItems collection
   With SGGrid1.Columns(1).ValueItems
      .Add 1, "First"
      .Add 2, "Second"
      'set the LimitToList to True to fire
      'the ValueItemError event
      .LimitToList = True
   End With
End Sub

Private Sub SGGrid1_ValueItemError(ByVal ColIndex As Long)
   Dim vis As SGValueItems

   Set vis = SGGrid1.Columns(ColIndex).ValueItems
   'add the current cell value to the
   'ValueItems collection
   vis.Add vis.Count + 1, SGGrid1.Value
   Set vis = Nothing
End Sub

Back to topic


Translate Property (SGValueItems Collection)

Translate Property (SGValueItems Collection)
Indicates whether data values are translated to display values.

Read/Write at run time and design time.

Syntax

object.Translate As Boolean

The object placeholder represents an object expression that evaluates to the SGValueItems object.

Remarks

If you set this property to True a grid will use the DisplayValue to display data. Otherwise, it will display Value.

If a cell is in the editing mode the property is ignored and always the DisplayValue is displayed.

Check out code below and note which properties return DisplayValue and which return ValueItem if the Translate property is set to True:

Private Sub SGGrid1_OnInit()
   Dim msg As String
   Dim cell As SGCell

   SGGrid1.DataColCount = 1
   'add two items to the ValueItems collection
   With SGGrid1.Columns(1).ValueItems
      .Add 1, "First"
      .Add 2, "Second"
      .Translate = True
   End With
   Set cell = SGGrid1.CurrentCell
   'set value for the current (first) cell
   SGGrid1.Array.Value(cell.Row.DataIndex, cell.Column.DBIndex) = 1
   'check what returns each property
   msg = "SGGrid1.Value=" & SGGrid1.Value & vbCrLf    'returns First
   msg = msg & "Cell.Value=" & cell.Value & vbCrLf    'returns First
   msg = msg & "SGArray.Value="
   msg = msg & SGGrid1.Array.Value(cell.Row.DataIndex, cell.Column.DBIndex) 'returns 1

   MsgBox msg
End Sub
Show Example
Copy Code [image] Show Me

The following example displays values of two first columns in the last one. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5, then change some values in the first or second column to see effect.

Private Sub SGGrid1_Change()
   Dim sValue As String
   Dim iPos As Integer

   If SGGrid1.Col = SGGrid1.Columns("Val").Position Then Exit Sub

   iPos = SGGrid1.Columns("Combo1").Position
   sValue = SGGrid1.Rows.Current.Cells(iPos).Value
   iPos = SGGrid1.Columns("Combo2").Position
   sValue = sValue & " - " & SGGrid1.Rows.Current.Cells(iPos).Value

   iPos = SGGrid1.Columns("Val").Position

   With SGGrid1.Rows.Current.Cells(iPos)
      .Value = sValue
      .Redraw
   End With
End Sub

Private Sub SGGrid1_OnInit()
   Dim i As Integer, j As Integer
   'create columns
   SGGrid1.DataRowCount = 10
   SGGrid1.DataColCount = 3
   'create value items
   For i = 1 To 2
      With SGGrid1.Columns.At(i)
         .Key = "Combo" & Trim(i)
         .Caption = .Key
         .Control.Type = sgCellDropDown
         For j = 1 To 10
            .ValueItems.Add j, "Item " & Trim(j), sgbipFirst + j
         Next
      End With
   Next

   SGGrid1.Columns.At(2).ValueItems.Translate = False
   SGGrid1.Columns.At(3).Key = "Val"
   SGGrid1.Columns("Val").Caption = "Values"
   'add some data
   For i = 1 To 3
      With SGGrid1.Rows.At(i)
         .Cells(1).Value = CLng(Rnd * 10)
         .Cells(2).Value = CLng(Rnd * 10)
      End With
   Next
End Sub

Back to topic


ValueItem Property (SGValueItems Collection)

ValueItem Property (SGValueItems Collection)
Returns SGValueItem object associated with specified data value.

Read-only at run time. Not available at design time.

Syntax

object.ValueItem As IsgValueItem

The object placeholder represents an object expression that evaluates to the SGValueItems object.

Remarks

Use the Add method to add ValueItem to the SGValueItems collection.

Show Example
Copy Code [image] Show Me

The following example demonstrates how to use the SGValueItem object. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   Dim i As Integer
   Dim vis As SGValueItems
   Dim vi As SGValueItem
   Dim ar As SGArray

   SGGrid1.DataColCount = 0
   SGGrid1.DataRowCount = 12
   'create columns
   With SGGrid1.Columns.Add("Month")
      .Caption = "Month"
      .Control.Type = sgCellDropList
      .Control.SortOrder = sgNoSorting
      .ValueItems.Translate = True
      'add months to the value items coll.
      For i = 1 To 12
         .ValueItems.Add i, MonthName(i), sgbipFirst + i
      Next
      .ValueItems.Default = Month(Now) - 1
   End With

   With SGGrid1.Columns.Add("Value")
      .DataType = sgtLong
   End With

   SGGrid1.Columns.Add "DisplayValue"
   SGGrid1.Columns.Add "DisplayPicture"

   i = 0
   Set vis = SGGrid1.Columns("Month").ValueItems
   Set ar = SGGrid1.Array

   For Each vi In vis
      ar.Value(i, 1) = vi.Value
      ar.Value(i, 2) = vi.DisplayValue
      ar.Value(i, 3) = vi.DisplayPicture
      i = i + 1
   Next

   Set ar = Nothing
   Set vis = Nothing
End Sub

Back to topic


SGValueItems Methods

Add | Adds new value item to the collection.
Remove | Removes specified value item from the collection.
RemoveAll | Removes all value items from the collection.


Add Method (SGValueItems Collection)

Add Method (SGValueItems Collection)
Adds new value item to the collection.
Syntax

object.Add(DataValue As Variant, DisplayValue As Variant, [DisplayPicture = -1] As Variant)

Return Value None
Arguments
object | An object expression that evaluates to the SGValueItems object.
DataValue | A Variant expression that sets the data value for a SGValueItem.
DisplayValue | A Variant expression that sets the translated data value for a SGValueItem.
DisplayPicture | Optional. A Variant expression that represent picture. You can pass Picture object or long expression that represents the index of the image from the grid image list Images. You can also use the grid's buil'in pictures using values from sgbipFirst to sgbipLast. Default value is -1.

Remarks

The Add method adds a new ValueItem object to the collection and returns a reference to the newly created object. All parameters of this method are variants so be shore that you use proper types. For example, if you add values from a recordset use type conversion functions to convert parameters.

SGGrid1.Columns(1).ValueItems.Add Clng(rs!Id), CStr(rs!Name)
Show Example
Copy Code [image] Show Me

The following example uses the ValueItemError event to add new element into the SGValueItems collection. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 1
   SGGrid1.AllowAddNew = True
   SGGrid1.Columns(1).Control.Type = sgCellDropDown
   'add two items to the ValueItems collection
   With SGGrid1.Columns(1).ValueItems
      .Add 1, "First"
      .Add 2, "Second"
      'set the LimitToList to True to fire
      'the ValueItemError event
      .LimitToList = True
   End With
End Sub

Private Sub SGGrid1_ValueItemError(ByVal ColIndex As Long)
   Dim vis As SGValueItems

   Set vis = SGGrid1.Columns(ColIndex).ValueItems
   'add the current cell value to the
   'ValueItems collection
   vis.Add vis.Count + 1, SGGrid1.Value
   Set vis = Nothing
End Sub

Back to topic


Remove Method (SGValueItems Collection)

Remove Method (SGValueItems Collection)
Removes specified value item from the collection.
Syntax

object.Remove(Index As Long)

Return Value None
Arguments
object | An object expression that evaluates to the SGValueItems object.
Index | An integer that uniquely identifies the object within the collection.

Remarks

To remove all SGValueItem objects from the SGValueItems collection use the RemoveAll method.

Show Example
Copy Code [image] Show Me

The following example translates numbers from 1 to 12 to months and ads them to the SGValueItems collection. When you delete some row, ValueItems not represent in remaining rows will be removed from the collection. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_AfterDelete()
   Dim i As Integer, j As Integer
   Dim ar As SGArray, vi As SGValueItem
   Dim bDelete As Boolean

   Set ar = SGGrid1.Array

   For i = SGGrid1.Columns(1).ValueItems.Count - 1 To 0 Step -1
      bDelete = True
      Set vi = SGGrid1.Columns(1).ValueItems(i)
      For j = 0 To ar.RowCount - 1
         If Val(ar.Value(j, 0)) = vi.Value Then
            bDelete = False
            Exit For
         End If
      Next
      If bDelete Then
         SGGrid1.Columns(1).ValueItems.Remove vi.Value
      End If
   Next
End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 1

   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True

   SGGrid1.Columns(1).Control.Type = sgCellDropDown
   With SGGrid1.Columns(1).ValueItems
      .Add 1, MonthName(1)
      .Translate = False
      .LimitToList = True
   End With
End Sub

Private Sub SGGrid1_ValueItemError(ByVal ColIndex As Long)
   Dim vis As SGValueItems
   Dim vi As SGValueItem
   Dim iMonth As Integer

   If Not IsNumeric(SGGrid1.Value) Then Exit Sub
   If SGGrid1.Value < 1 Or SGGrid1.Value > 12 Then Exit Sub

   iMonth = CInt(SGGrid1.Value)

   Set vis = SGGrid1.Columns(ColIndex).ValueItems

   For Each vi In vis
      If vi.Value = iMonth Then
         SGGrid1.Value = vi.DisplayValue
         Exit Sub
      End If
   Next
   vis.Add iMonth, MonthName(iMonth)
   Set vis = Nothing
End Sub

Back to topic


RemoveAll Method (SGValueItems Collection)

RemoveAll Method (SGValueItems Collection)
Removes all value items from the collection.
Syntax | object.RemoveAll
Return Value | None
Arguments | None

Remarks

To remove a particular SGValueItem object from the SGValueItems collection use the Remove method.

Show Example
Copy Code [image] Show Me

The following example translates numbers from 1 to 12 to months and ads them to the SGValueItems collection. When you delete some row, all ValueItems are removed from the collection and then collection is refilled only with values from remaining rows. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.

Private Sub SGGrid1_AfterDelete()
   Dim i As Integer, vis As SGValueItems
   Dim ar As SGArray, vi As SGValueItem
   Dim bAdd As Boolean

   SGGrid1.Columns(1).ValueItems.RemoveAll

   Set ar = SGGrid1.Array
   Set vis = SGGrid1.Columns(1).ValueItems

   For i = 0 To ar.RowCount - 1
      bAdd = True
      For Each vi In vis
         If ar.Value(i, 0) = vi.Value Then
            bAdd = False
            Exit For
         End If
      Next
      If bAdd Then
         vis.Add ar.Value(i, 0), MonthName(ar.Value(i, 0))
      End If
   Next

   Set vis = Nothing
   Set ar = Nothing
End Sub

Private Sub SGGrid1_OnInit()
   SGGrid1.DataColCount = 1

   SGGrid1.AllowAddNew = True
   SGGrid1.AllowDelete = True

   SGGrid1.Columns(1).Control.Type = sgCellDropDown
   With SGGrid1.Columns(1).ValueItems
      .Add 1, MonthName(1)
      .Translate = False
      .LimitToList = True
   End With
End Sub

Private Sub SGGrid1_ValueItemError(ByVal ColIndex As Long)
   Dim vis As SGValueItems
   Dim vi As SGValueItem
   Dim iMonth As Integer

   If Not IsNumeric(SGGrid1.Value) Then Exit Sub
   If SGGrid1.Value < 1 Or SGGrid1.Value > 12 Then Exit Sub

   iMonth = CInt(SGGrid1.Value)

   Set vis = SGGrid1.Columns(ColIndex).ValueItems

   For Each vi In vis
      If vi.Value = iMonth Then
         SGGrid1.Value = vi.DisplayValue
         Exit Sub
      End If
   Next
   vis.Add iMonth, MonthName(iMonth)
   Set vis = Nothing
End Sub

Back to topic


IsgGridDataSource Interface

See Also Send us your Feedback
IsgGridCustomDraw Interface

To utilize a custom drawing, you should implement an IsgGridCustomDraw interface. This interface has methods that are called by the grid's drawing engine at certain stages during cell rendering process. You can draw before or after grid performs its normal drawing, or you can completely replace grid's default painting with your own.

To control at what stage of a cell rendering process you want plug-in your painting, use the style's CustomDraw property. For a list of a possible values check SGCustomDrawStage constants.

To implement an interface in Visual Basic, use the Implements keyword. When you have an object that implements an IsgGridCustomDraw, assign it to the PaintObject property.

IsgGridCustomDraw methods

DrawGridBkg(DrawInfo As sgGridCustomDraw, Response As sgCustomDrawResponse)
 Called when the grid's background is drawn.

DrawCell(DrawInfo As sgGridCustomDraw, Response As sgCustomDrawResponse)
Called when a cell is drawn.

SGGridCustomDraw structure

DrawStage As sgCustomDrawStage | Current drawing stage
DC As Long | Windows device context handle
Left As Long | Left margin of the drawing rectangle. In pixels relative to the DC's coordinate system.
Top As Long | Top margin of the drawing rectangle. In pixels relative to the DC's coordinate system.
Right As Long | Right margin of the drawing rectangle. In pixels relative to the DC's coordinate system.
Bottom As Long | Bottom margin of the drawing rectangle. In pixels relative to the DC's coordinate system.
RowKey As Long | Key of the row that is being drawn.
RowPos As Long | Position of the row that is being drawn.
RowLevel As Long | Outline level of the row that is being drawn.
ColKey As String | Key of the column that is being drawn.
ColIndex As Long | Index of the column that is being drawn.
ColPos As Long | Position of the column that is being drawn.
CellKind As Integer | Type of the cell that is being drawn.
Heading As Integer | Non-zero if cell being drawn is a heading cell.
Frozen As Integer | Non-zero if cell being drawn is a member of the frozen row or column.
Merged As Integer | Non-zero if cell being drawn is merged.
Data As Variant | Data that needs to be displayed.
Picture As Variant | Picture that needs to be displayed.

Note that BeeGrid Free Edition does not support custom drawing.


IsgGridDataSource Interface

See Also Send us your Feedback
IsgGridDataSource Interface

To use grid in a Virtual Interface mode, you must implement an IsgGridDataSource interface. In Visual Basic, Implements keyword is used to implement interface in a form or class module.

The interface has these functions:

AddRow | Called when a new row should be added the data source.
DeleteRow | Called when a row should be deleted from the data source.
GetRowCount | Returns number of rows provided by the data source implementation.
GetRowData | Called to retrieve data for the specified row.
SetRowData | Called to modify row's data.


IsgConditionTest Interface

See Also Send us your Feedback
IsgConditionTest Interface

The IsgConditionTest interface is used by the SGCondition object to test a value when operator is equal to sgOpCallback. In Visual Basic, Implements keyword is used to implement interface in a form or class module.

Interface contains only one function:

Test(Value As Variant, Tag As Variant) As Boolean

Value is a value to be tested. Tag is a user defined value passed to the condition object through the Value2 parameter.


OLEDBBeeGrid10 Enums

Constants

sgAlignment | Text alignment settings.
sgAlphaBlendElement | Determines the cell element that is a subject of an alpha blending operation.
sgAppearance | Appearance settings.
sgAutoResize | Auto resizing settings.
sgBuiltInPictures |
sgButtonAlignment | Cell's action button alignment.
sgCalculationType | Calculations.
sgCellBkgStyle | Cell's background styles.
sgCellBorderStyle | Cell's border styles.
sgCellBorder | Cell's border settings.
sgCellEditorType | Cell editor types.
sgCellKind | Cell kind settings.
sgCellMerge | Cell merging rules.
sgCellStatus | Cell status settings.
sgCellTip | Cell tip settings.
sgConditionValueSource | Condition value settings.
sgCustomDrawResponse | Custom-draw response codes.
sgCustomDrawStage | Grid's custom-draw drawing stages.
sgDataFormat | Data format settings.
sgDataMode | Data mode settings.
sgDataType | Supported data types.
sgDisplayType | Cell display types.
sgEllipsis | Text ellipses settings.
sgEnterKeyBehavior | Enter key settings.
sgEvenOddStyle | Even odd style settings.
sgExpand | Group expanding settings.
sgExportFlag | Export flags.
sgFilterAction | Filter action settings.
sgFocusRect | Focus rectangle settings.
sgGridBorderStyle | Grid control's border styles.
sgGridHitTest | Hit test codes.
sgGridLineStyle | Grid line styles.
sgGridRedrawCode | Redrawing settings.
sgGroupFooterText | Group footer text's settings.
sgGroupHeaderPicture |
sgGroupHeaderText | Group header text's settings.
sgGroupOperation | Group commands.
sgInactiveSelection | Inactive selection settings.
sgItemHeight | Popup window's item height settings.
sgLayoutFormat | Grid's layout format settings.
sgMaskDataMode | Specifies how masked cells will be stored by the underlaying data source.
sgMousePointer | Specifies the type of mouse pointer displayed.
sgMultiSelect | Multi-selection settings.
sgNavigationWrapMode | Navigation wrapping.
sgNewRowPos | Position of the row used to add new records.
sgOLEDragMode | OLE drag mode.
sgOLEDropMode | OLE drop mode.
sgOperator | Condition operator.
sgOutlineLines | Type of the grouping outline line.
sgPicAlignment | Picture alignment settings.
sgPopupAlignment | Popup window alignment settings.
sgPreviewPanePosition | Preview pane position.
sgPreviewPaneType | Preview pane type.
sgRangeType | Range types.
sgResizeAnimation | Resize animation settings.
sgRowStatus | Row status settings.
sgRowType | Row types.
sgScrollBarMode | Scrollbar mode settings.
sgScrollBar | Scrollbar settings.
sgScrollTip | Scrollbar tip settings.
sgSearchFlag |
sgSelectionMode | Selection mode settings.
sgShowButton | Cell's action button settings.
sgSortOrder | Sorting order settings.
sgSortType | Sorting type settings.
sgSpecialMode | Special working mode settings.
sgTabKeyBehavior | Tabulator key settings.
sgUserResizing | User resizing settings.
sgUserRowColDrag | User's row and column dragging settings.
sgUserRowColHide | User's row and column hiding settings.


sgAlignment Enum

See Also
sgAlignment Constants
Text alignment settings.
Name | Value | Description
sgAlignGeneral | 0 | Alignment is based on the underlying data type.
sgAlignLeftTop | 1 | Align to the left-top position.
sgAlignCenterTop | 2 | Align to the center-top position.
sgAlignRightTop | 3 | Align to the right-top position.
sgAlignLeftCenter | 4 | Align to the left-center position.
sgAlignCenterCenter | 5 | Align to the center-center position.
sgAlignRightCenter | 6 | Align to the right-center position.
sgAlignLeftBottom | 7 | Align to the left-bottom position.
sgAlignCenterBottom | 8 | Align to the center-bottom position.
sgAlignRightBottom | 9 | Align to the right-bottom position.


sgAlphaBlendElement Enum

See Also
sgAlphaBlendElement Constants
Determines the cell element that is a subject of an alpha blending operation.
Name | Value | Description
sgAlphaBorder | 1 | Inidcates alpha blending attributes for the cell's border.
sgAlphaBackground | 2 | Inidcates alpha blending attributes for the cell's background color.
sgAlphaBackgroundPicture | 3 | Inidcates alpha blending attributes for the cell's background picture.
sgAlphaContent | 4 | Inidcates alpha blending attributes for the cell's content.

See Also

AlphaLevel (SGStyle)


sgAppearance Enum

See Also
sgAppearance Constants
Appearance settings.
Name | Value | Description
sgFlat | 0 | Flat appearance.
sg3D | 1 | Standard 3D appearance.
sg3DLight | 2 | Light 3D appearance.


sgOperator Enum

See Also
sgAutoSearch Constants
Specifies auto-search mode.
Name | Value | Description
sgNoAutoSearch | 0 | Auto-search is disabled.
sgAutoSearchFromTop | 1 | Start searching from the first row.
sgAutoSearchFromCurrentRow | 2 | Start searching from the current row.


sgAutoResize Enum

See Also
sgAutoResize Constants
Auto resizing settings.
Name | Value | Description
sgNoAutoResize | 0 | No auto resizing.
sgAutoResizeColumns | 1 | Resize only columns.
sgAutoResizeRows | 2 | Resize only rows.
sgAutoResizeRowsAndColumns | 3 | Resize both rows and columns.

See Also

AutoResize


sgBuiltInPictures Enum

See Also
sgBuiltInPictures Constants
Name | Value | Description
sgbipFirst | 32768 | Index of the first built-in picture.
sgbipLast | 33023 | Index of the last built-in picture.

See Also

SGGrid


sgButtonAlignment Enum

See Also
sgButtonAlignment Constants
Cell's action button alignment.
Name | Value | Description
sgButtonLeft | 0 | Button is positioned on the left side of the cell.
sgButtonRight | 1 | Button is positioned on the right side of cell.

See Also

ButtonAlignment (SGControl)


sgCalculationType Enum

See Also
sgCalculationType Constants
Calculations.
Name | Value | Description
sgCalcNone | 0 | No calculation.
sgCalcCount | 1 | Row count.
sgCalcMaximum | 2 | Maximum.
sgCalcMinimum | 3 | Minimum.
sgCalcSum | 4 | Sum.
sgCalcAverage | 5 | Average.
sgCalcList | 6 | Creates list.


sgCellBkgStyle Enum

See Also
sgCellBkgStyle Constants
Cell's background styles.
Name | Value | Description
sgCellBkgNone | 0 | Do not draw cell border. Cell is transparent.
sgCellBkgSolid | 1 | Draw solid cell background.
sgCellBkgBDiagonal | 2 | Draw backward diagonal pattern in the cell's background.
sgCellBkgFDiagonal | 3 | Draw forward diagonal pattern in the cell's background.
sgCellBkgCross | 4 | Draw cross-hatched pattern in the cell's background.
sgCellBkgDiagCross | 5 | Draw diagonally cross-hatched pattern in the cell's background.
sgCellBkgHorizontal | 6 | Draw horizontal pattern in the cell's background.
sgCellBkgVertical | 7 | Draw vertical pattern in the cell's background.
sgCellBkgGradientVertical | 8 | The background is shaded from top-to-bottom.
sgCellBkgGradientHorizontal | 9 | The background is shaded from left-to-right.


sgCellBorder Enum

See Also
sgCellBorder Constants
Cell's border settings.
Name | Value | Description
sgCellNoBorder | 0 | Do not draw cell's borders.
sgCellBorderLeft | 1 | Draw left border.
sgCellBorderTop | 2 | Draw top border.
sgCellBorderRight | 4 | Draw right border.
sgCellBorderBottom | 8 | Draw bottom border.
sgCellBorderAll | 15 | Draw all borders.

See Also

Borders (SGStyle)


sgCellBorderStyle Enum

See Also
sgCellBorderStyle Constants
Cell's border styles.
Name | Value | Description
sgCellBorderSolid | 1 | Draw solid cell borders.
sgCellBorderDotted | 2 | Draw dotted cell borders.
sgCellBorderDashed | 3 | Draw dashed cell borders.

See Also

BorderStyle (SGStyle)


sgCellEditorType Enum

See Also
sgCellEditorType Constants
Cell editor types.
Name | Value | Description
sgCellGeneral | 0 | The cell editor type is determined by the underlying data type.
sgCellTextBox | 1 | The cell editor is a text box.
sgCellCheckBox | 2 | The cell editor is a checkbox.
sgCellDropDown | 3 | The cell editor is a dropdown combobox.
sgCellDropList | 4 | The cell editor is a droplist combobox.

See Also

Type (SGControl)


sgCellKind Enum

See Also
sgCellKind Constants
Cell kind settings.
Name | Value | Description
sgCellStandard | 0 | Standard cell.
sgCellGroupHeader | 2 | Cell is a group header cell.
sgCellGroupFooter | 3 | Cell is a group footer cell.
sgCellPreviewPane | 4 | Cell is a preview pane.
sgCellGroupByBox | 5 | Cell is a group-by box.
sgCellGroupByHeadingCell | 6 | Cell is a column heading inside the group-by box.


sgCellMerge Enum

See Also
sgCellMerge Constants
Cell merging rules.
Name | Value | Description
sgMergeNone | 0 | Do not merge cells.
sgMergeFree | 1 | Merge cells with same contents.

See Also

MergeCells (SGColumn)


sgCellStatus Enum

See Also
sgCellStatus Constants
Cell status settings.
Name | Value | Description
sgCellStatusNormal | 0 | No special status.
sgCellStatusCurrent | 1 | Cell is focused.
sgCellStatusCurrentRow | 2 | Cell is a member of the current row.
sgCellStatusDataChanged | 4 | Cell content has changed but has not yet been written to the database.

See Also

Status (SGCell)


sgCellTip Enum

See Also
sgCellTip Constants
Cell tip settings.
Name | Value | Description
sgCellTipsNone | 0 | Cell tips are not displayed.
sgCellTipsStatic | 1 | Show static cell tip.
sgCellTipsFloat | 2 | Show floating cell tip.

See Also

CellTips


sgConditionValueSource Enum

See Also
sgConditionValueSource Constants
Condition value settings.
Name | Value | Description
sgConditionCellValue | 0 | Use cell value when evaluating condition.
sgConditionCellStatus | 1 | Use cell status when evaluating condition.
sgConditionColPosition | 2 | Use column position when evaluating condition.
sgConditionColIndex | 3 | Use column index when evaluating condition.
sgConditionColKey | 4 | Use column key when evaluating condition.
sgConditionRowPosition | 5 | Use row position when evaluating condition.
sgConditionRowKey | 6 | Use row key when evaluating condition.
sgConditionRowBookmark | 7 | Use row bookmark when evaluating condition.
sgConditionRowStatus | 8 | Use row status when evaluating condition.


sgCustomDrawResponse Enum

See Also
sgCustomDrawResponse Constants
Custom-draw response codes.
Name | Value | Description
sgDoDefault | 0 | The grid will draw current stage itself. Valid only for 'Before' draw stages.
sgSkipDefault | 1 | The grid will not draw current stage. Valid only for 'Before' draw stages.
sgDoDefaultAll | 2 | The grid will draw all further stages itself.
sgSkipDefaultAll | 3 | The grid will not draw any further stages.

See Also

SGGrid


sgCustomDrawStage Enum

See Also
sgCustomDrawStage Constants
Grid's custom-draw drawing stages.

Name | Value | Description
sgNoCustomDraw | 0 | The grid will draw all stages itself.
sgDrawBeforeGridBkg | 1 | Before the grid's background is drawn.
sgDrawAfterGridBkg | 2 | After the grid's background has been drawn.
sgDrawBeforeGridCaption | 3 | Before the grid's caption is drawn.
sgDrawAfterGridCaption | 4 | After the grid's caption has been drawn.
sgDrawBeforeGridCorner | 5 | Before the grid's corner is drawn.
sgDrawAfterGridCorner | 6 | After the grid's corner has been drawn.
sgDrawBeforePreviewPaneSplitter | 7 | Before the preview pane's splitter bar is drawn.
sgDrawAfterPreviewPaneSplitter | 8 | After the preview pane's splitter bar has been drawn.
sgDrawBeforeFocusRect | 9 | Before the grid's focus rectangle is drawn.
sgDrawAfterFocusRect | 10 | After the grid's focus rectangle has been drawn.
sgDrawBeforeCellBorder | 11 | Before the cell's border (grid lines, border and padding) is drawn.
sgDrawAfterCellBorder | 12 | After the cell's border (grid lines, border and padding) has been drawn.
sgDrawBeforeCellBkg | 13 | Before the cell's background is drawn.
sgDrawAfterCellBkg | 14 | After the cell's background has been drawn.
sgDrawBeforeCellButton | 15 | Before the cell's button is drawn.
sgDrawAfterCellButton | 16 | After the cell's button has been drawn.
sgDrawBeforeCellBkgPicture | 17 | Before the cell's background picture is drawn.
sgDrawAfterCellBkgPicture | 18 | After the cell's background picture has been drawn.
sgDrawBeforeCellContent | 19 | Before the cell's content is drawn.
sgDrawAfterCellContent | 20 | After the cell's content has been drawn.


sgDataFormat Enum

See Also
sgDataFormat Constants
Data format settings.
Name | Value | Description
sgFormatXML | 1 | Data is saved/loaded in an XML format.
sgFormatCharSeparatedValue | 2 | Data is saved/loaded as character separated values.

See Also

SetData (SGRow) | GetData (SGRow) | Add (SGRows) | InsertAt (SGRows) | SetData (SGRange) | GetData (SGRange) | ExportData | ExportDataString | ImportData | ImportDataString


sgDataMode Enum

See Also
sgDataMode Constants
Data mode settings.
Name | Value | Description
sgBound | 0 | SGGrid is connected to the external OLEDB data source.
sgUnbound | 1 | SGGrid is not connected to the external data source. It uses internal buffer to store cell data.
sgVirtualEvents | 2 | SGGrid uses events to fetch cell data.
sgVirtualInterface | 3 | SGGrid uses externally implemented interface to fetch cell data.

See Also

DataMode


sgDataType Enum

See Also
sgDataType Constants
Supported data types.
Name | Value | Description
sgtEmpty | 0 | Data type is undefined.
sgtShort | 2 | 16 bit integer.
sgtLong | 3 | 32 bit integer.
sgtFloat | 4 | Single precision number.
sgtDouble | 5 | Double precision number.
sgtCurrency | 6 | Currency.
sgtDateTime | 7 | Date-time value.
sgtString | 8 | Character string.
sgtBoolean | 11 | Boolean.
sgtDecimal | 14 | Decimal.
sgtByte | 17 | 8 bit integer.
sgtBinary | 65 | Binary data.

See Also

DataType (SGColumn)


sgDisplayType Enum

See Also
sgDisplayType Constants
Cell display types.
Name | Value | Description
sgDisplayText | 0 | Cell displays text only.
sgDisplayTextAndPicture | 1 | Cell displays text and picture.
sgDisplayPicture | 2 | Cell displays picture only.
sgProgressBar | 3 | Cell displays progress bar.

See Also

DisplayType (SGStyle)


sgEllipsis Enum

See Also
sgEllipsis Constants
Text ellipses settings.
Name | Value | Description
sgNoEllipsis | 0 | Do not draw ellipses. Text is clipped.
sgEllipsisEnd | 1 | Replace part at the end of the text with ellipses.
sgEllipsisPath | 2 | Replace part in the middle of the text with ellipses.


sgEnterKeyBehavior Enum

See Also
sgEnterKeyBehavior Constants
Enter key settings.
Name | Value | Description
sgEnterKeyDefault | 0 | Default ENTER key behavior.
sgEnterKeyColumns | 1 | ENTER key jumps to next focusable column.
sgEnterKeyRows | 2 | ENTER key jumps to next focusable row.

See Also

EnterKeyBehavior


sgEvenOddStyle Enum

See Also
sgEvenOddStyle Constants
Even odd style settings.
Name | Value | Description
sgNoEvenOdd | 0 | Do not alternate colors.
sgEvenOddRows | 1 | Apply alternate colors for rows only.
sgEvenOddCols | 2 | Apply alternate colors for columns only.
sgEvenOddBoth | 3 | Apply alternate colors for both rows and columns.

See Also

EvenOddStyle


sgExpand Enum

See Also
sgExpand Constants
Group expanding settings.
Name | Value | Description
sgExpandGroups | 1 | Groups will be expanded.
sgCollapseGroups | 2 | Groups will be collapsed.

See Also

RefreshGroups


sgExportFlag Enum

See Also
sgExportFlag Constants
Export flags.
Name | Value | Description
sgExportDefault | 0 | Use default export flags.
sgExportCurrentRowOnly | 1 | Export current row only.
sgExportFieldNames | 2 | Export field names.
sgExportRowsOnly | 4 | Export only data rows.
sgExportHidden | 8 | Hidden columns will appear in exported data.
sgExportOverwrite | 16 | Replace file if it already exists.
sgExportAppend | 32 | Append to file if it already exists.


sgFilterAction Enum

See Also
sgFilterAction Constants
Filter action settings.
Name | Value | Description
sgFilterActionDefault | 0 | Use actions already stored in the Filters object.
sgFilterActionMarkHidden | 1 | Mark row as hidden.
sgFilterActionMarkReadOnly | 2 | Mark row as read-only.
sgFilterActionSelect | 4 | Select row.
sgFilterActionCustom | 8 | Custom action. BeeGrid does not use it.


sgFocusRect Enum

See Also
sgFocusRect Constants
Focus rectangle settings.
Name | Value | Description
sgFocusRectNone | 0 | Do not draw focus rectangle.
sgFocusRectDotted | 1 | Draw dotted focus rectangle.
sgFocusRectSolid | 2 | Draw solid focus rectangle.
sgFocusRectOwnerDraw | 3 | Custom drawn focus rectangle.

See Also

FocusRect


sgGridBorderStyle Enum

See Also
sgGridBorderStyle Constants
Grid control's border styles.
Name | Value | Description
sgNone | 0 | No border.
sgFixed | 1 | Fixed border.

See Also

GridBorderStyle


sgGridHitTest Enum

See Also
sgGridHitTest Constants
Hit test codes.
Name | Value | Description
sgHitNowhere | 0 | Inactive part of a grid control.
sgHitHeadingRow | 1 | At heading row.
sgHitHeadingCol | 2 | At heading column.
sgHitCell | 3 | At grid cell.
sgHitCellButton | 4 | At grid cell's button.
sgHitBkg | 5 | At area outside of grid cells .
sgHitGroupExpandBtn | 6 | At group header expand button.
sgHitGroupIndentation | 7 | At group indentation.
sgHitCaption | 8 | At grid's caption bar.
sgHitPreviewPaneSplitter | 9 | At preview pane's splitter.
sgHitPreviewPane | 10 | At preview pane.
sgHitGridCorner | 11 | At rectangle between vertical and horizontal scroll bars.
sgHitGroupByBox | 12 | At group-by box.
sgHitGroupByBoxCell | 13 | At cell inside group-by box.


sgGridLineStyle Enum

See Also
sgGridLineStyle Constants
Grid line styles.
Name | Value | Description
sgGridLineNone | 0 | Do not draw grid lines.
sgGridLineFlat | 1 | Draw flat grid lines.
sgGridLineInset | 2 | Inset.
sgGridLineRaised | 3 | Raised.
sgGridLineFlatHorz | 4 | Draw only horizontal flat grid lines.
sgGridLineInsetHorz | 5 | Draw only horizontal inset grid lines.
sgGridLineRaisedHorz | 6 | Draw only horizontal raised grid lines.
sgGridLineFlatVert | 7 | Draw only vertical flat grid lines.
sgGridLineInsetVert | 8 | Draw only vertical inset grid lines.
sgGridLineRaisedVert | 9 | Draw only vertical raised grid lines.


sgGridRedrawCode Enum

See Also
sgGridRedrawCode Constants
Redrawing settings.
Name | Value | Description
sgRedrawAll | 0 | Redraws grid control.
sgRedrawHeadingRow | 1 | Redraw the heading row.
sgRedrawHeadingCol | 2 | Redraws the heading column.
sgRedrawBkg | 3 | Redraws area outside of grid cells.
sgRedrawCaption | 4 | Redraws the caption bar.
sgRedrawPreviewPaneSplitter | 5 | Redraws the preview pane's splitter.
sgRedrawPreviewPane | 6 | Redraws the preview pane.
sgRedrawGroupByBox | 7 | Redraws the group-by box.
sgRedrawGridCorner | 8 | Redraws the rectangle between vertical and horizontal scroll bars.

See Also

Redraw


sgGroupFooterText Enum

See Also
sgGroupFooterText Constants
Group footer text's settings.
Name | Value | Description
sgGrpFooterEmpty | 0 | Footer without any text or picture.
sgGrpFooterCaption | 1 | Uses group footer caption.
sgGrpFooterFormula | 2 | Uses group footer formula.
sgGrpFooterFireFetchText | 3 | Uses an event to fetch group footer text.

See Also

FooterTextSource (SGGroup)


sgGroupHeaderPicture Enum

See Also
sgGroupHeaderPicture Constants
Name | Value | Description
sgGroupHeaderFetchPicture | 33024 | Value that indicates that grid uses events to fetch group header picture.
sgGroupHeaderColumnPicture | 33025 | Group header will show the picture associated with grouping value.

See Also

SGGrid


sgGroupHeaderText Enum

See Also
sgGroupHeaderText Constants
Group header text's settings.
Name | Value | Description
sgGrpHdrEmpty | 0 | Group header without any text.
sgGrpHdrColCaptionAndValue | 1 | Uses column caption and grouping value.
sgGrpHdrCaptionAndValue | 2 | Uses group header caption and grouping value.
sgGrpHdrCaption | 3 | Uses group header caption.
sgGrpHdrFormula | 4 | Uses group header formula.
sgGrpHdrFireFetchText | 5 | Uses an event to fetch group header text.

See Also

HeaderTextSource (SGGroup)


sgGroupOperation Enum

See Also
sgGroupOperation Constants
Group commands.
Name | Value | Description
sgGroupAdd | 1 | A new group is about to be added.
sgGroupRemove | 2 | A group is about to be deleted.
sgGroupMove | 3 | A group is moved from one position to the other position.


sgInactiveSelection Enum

See Also
sgInactiveSelection Constants
Inactive selection settings.
Name | Value | Description
sgHideSelection | 0 | Selected cells are displayed as not selected when grid does not have focus.
sgShowAsInactive | 1 | Selected cells are displayed with inactive colors.
sgShowAsNormal | 2 | Selected cells are displayed using same colors as when the grid has the focus.

See Also

InactiveSelection


sgItemHeight Enum

See Also
sgItemHeight Constants
Popup window's item height settings.
Name | Value | Description
sgItemHeightFixed | -1 | All items in the dropdown list are of same height.
sgItemHeightVariable | -2 | Each item in the dropdown list can have different height.

See Also

ItemHeight (SGControl)


sgLayoutFormat Enum

See Also
sgLayoutFormat Constants
Grid's layout format settings.
Name | Value | Description
sgLayoutXML | 1 | Layout is saved in XML format.
sgLayoutIgnoreColumns | 256 | When loading layout, columns are not created or destroyed.


sgMaskDataMode Enum

See Also
sgMaskDataMode Constants
Specifies how masked cells will be stored by the underlaying data source.
Name | Value | Description
sgMaskModeInput | 0 | Store only entered characters.
sgMaskModeSaveAll | 1 | Store all characters.
sgMaskModeIncludeLiterals | 2 | Store entered and literal characters.
sgMaskModeIncludePrompt | 3 | Store entered and prompt characters.

See Also

EditMaskDataMode (SGColumn)


sgMousePointer Enum

See Also
sgMousePointer Constants
Specifies the type of mouse pointer displayed.
Name | Value | Description
sgMPDefault | 0 | (Default) Shape determined by the object.
sgMPArrow | 1 | Arrow.
sgMPCross | 2 | Cross (cross-hair pointer).
sgMPIbeam | 3 | I Beam.
sgMPIcon | 4 | Icon (small square within a square).
sgMPSize | 5 | Size (four-pointed arrow pointing north, south, east, and west).
sgMPSizeNESW | 6 | Size NE SW (double arrow pointing northeast and southwest).
sgMPSizeNS | 7 | Size N S (double arrow pointing north and south).
sgMPSizeNWSE | 8 | Size NW, SE.
sgMPSizeEW | 9 | Size E W (double arrow pointing east and west).
sgMPUpArrow | 10 | Up Arrow.
sgMPHourglass | 11 | Hourglass (wait).
sgMPNoDrop | 12 | No Drop.
sgMPArrowHourglass | 13 | Arrow and hourglass.
sgMPArrowQuestion | 14 | Arrow and question mark.
sgMPSizeAll | 15 | Size all.
sgMPHand | 16 | Pointing hand.
sgMPCustom | 99 | Custom icon specified by the MouseIcon property.

See Also

MousePointer (SGStyle)


sgMultiSelect Enum

See Also
sgMultiSelect Constants
Multi-selection settings.
Name | Value | Description
sgMultiSelectNone | 0 | No multiple selections.
sgMultiSelectSimple | 1 | All selected rows, cols or cells are adjacent.
sgMultiSelectExtended | 2 | Can select ranges of non-adjacent rows, cols or cells.


sgNavigationWrapMode Enum

See Also
sgNavigationWrapMode Constants
Navigation wrapping.
Name | Value | Description
sgNavigationWrapNone | 0 | Do not wrap to the next row.
sgNavigationWrapNext | 1 | Wrap to the first focusable column of the next focusable row.
sgNavigationWrapSame | 2 | Wrap to the first focusable column of the same row.

See Also

NavigationWrapMode


sgNewRowPos Enum

See Also
sgNewRowPos Constants
Position of the row used to add new records.
Name | Value | Description
sgNewRowTop | 0 | The row for adding new records is the first row below the heading rows.
sgNewRowBottom | 1 | The row for adding new records is the last grid row.

See Also

NewRowPos


sgOLEDragMode Enum

See Also
sgOLEDragMode Constants
OLE drag mode.
Name | Value | Description
sgOLEDragModeManual | 0 | Manual.
sgOLEDragModeAutomatic | 1 | Automatic.

See Also

OLEDragMode


sgOLEDropMode Enum

See Also
sgOLEDropMode Constants
OLE drop mode.
Name | Value | Description
sgOLEDropModeNone | 0 | None.
sgOLEDropModeManual | 1 | Manual.
sgOLEDropModeAutomatic | 2 | Automatic.

See Also

OLEDropMode


sgOperator Enum

See Also
sgOperator Constants
Condition operator.
Name | Value | Description
sgOpFalse | 0 | Always fail.
sgOpTrue | 1 | Always succeed.
sgOpLessThan | 2 | Succeeds if the left-side value is smaller then the right-side value.
sgOpLessThanOrEqual | 3 | Succeeds if the left-side value is smaller than or equal to the right-side value.
sgOpGreaterThan | 4 | Succeeds if the left-side value is greater then the right-side value.
sgOpGreaterThanOrEqual | 5 | Succeeds if the left-side value is greater then or equal to the right-side value.
sgOpEqual | 6 | Succeeds if the left-side value is equal to the right-side value.
sgOpBetween | 7 | Succeeds if the left-side value is both greater then the first right-side value and smaller or equal to the second right-side value.
sgOpContains | 8 | Succeeds if left-side value is contained in the right-side value. Applies only to string and integral (byte, short, long, int64) types.
sgOpRegEx | 9 | Succeeds if regular expression is matched. Applies only to string values.
sgOpCallback | 10 | Uses the custom IsgConditionTest interface to test an LhsValue value. RhsValue1 should be an object that implements IsgConditionTest interface. RhsValue2 is a Tag value passed as the Test method's Tag parameter.
sgOpNot | 16384 | Negate operator. Can be used only in a combination with some other operator.


sgOutlineLines Enum

See Also
sgOutlineLines Constants
Type of the grouping outline line.
Name | Value | Description
sgNoOutlineLines | 0 | Do not draw any lines.
sgGroupLines | 1 | Draw grouping lines.

See Also

OutlineLines


sgPicAlignment Enum

See Also
sgPicAlignment Constants
Picture alignment settings.
Name | Value | Description
sgPicAlignLeftTop | 0 | Align picture to the left-top position.
sgPicAlignCenterTop | 1 | Align picture to the center-top position.
sgPicAlignRightTop | 2 | Align picture to the right-top position.
sgPicAlignLeftCenter | 3 | Align picture to the left-center position.
sgPicAlignCenterCenter | 4 | Align picture to the center-center position.
sgPicAlignRightCenter | 5 | Align picture to the right-center position.
sgPicAlignLeftBottom | 6 | Align picture to the left-bottom position.
sgPicAlignCenterBottom | 7 | Align picture to the center-bottom position.
sgPicAlignRightBottom | 8 | Align picture to the right-bottom position.
sgPicAlignStretch | 9 | Picture is streched to fit cell content.
sgPicAlignTile | 10 | Picture is tiled to fit cell content.


sgPopupAlignment Enum

See Also
sgPopupAlignment Constants
Popup window alignment settings.
Name | Value | Description
sgPopupLeft | 0 | Popup window is aligned to the left cell border.
sgPopupRight | 1 | Popup window is aligned to the right cell border.

See Also

PopupAlignment (SGControl)


sgPreviewPanePosition Enum

See Also
sgPreviewPanePosition Constants
Preview pane position.
Name | Value | Description
sgPreviewPaneLeft | 0 | Preview pane is aligned with left grid border.
sgPreviewPaneTop | 1 | Preview pane is aligned with top grid border.
sgPreviewPaneRight | 2 | Preview pane is aligned with right grid border.
sgPreviewPaneBottom | 3 | Preview pane is aligned with bottom grid border.

See Also

PreviewPanePosition


sgPreviewPaneType Enum

See Also
sgPreviewPaneType Constants
Preview pane type.
Name | Value | Description
sgNoPreviewPane | 0 | Grid does not show preview pane.
sgPreviewPaneDefault | 1 | Preview pane is drawn with standard cell drawing.

See Also

PreviewPaneType


sgRangeType Enum

See Also
sgRangeType Constants
Range types.
Name | Value | Description
sgRangeFree | 0 | Range contains one rectangular cell area.
sgRangeRow | 1 | Range contains one or more successive rows.
sgRangeColumn | 2 | Range contains one or more successive columns.


sgResizeAnimation Enum

See Also
sgResizeAnimation Constants
Resize animation settings.
Name | Value | Description
sgNoResizeAnimation | 0 | No animation while user resizes rows and columns.
sgAnimateHeadings | 1 | Animate headings.
sgAnimateRowsColumns | 2 | Animate headings and cells.

See Also

UserResizeAnimate


sgRowStatus Enum

See Also
sgRowStatus Constants
Row status settings.
Name | Value | Description
sgRowStatusNormal | 0 | No special status.
sgRowStatusCurrent | 1 | Row is current (focused) row.
sgRowStatusDataChanged | 2 | Row content has changed but has not yet been written to the database.
sgRowStatusFiltered | 4 | Row does not meet the filter condition.
sgRowStatusHidden | 8 | Row is hidden.
sgRowStatusSelected | 16 | Row is currently selected.
sgRowStatusReadOnly | 32 | Row is read-only.
sgRowStatusExpanded | 64 | Row is group header and child rows are expanded.
sgRowStatusCollapsed | 128 | Row is collapsed child row.

See Also

Status (SGRow)


sgRowType Enum

See Also
sgRowType Constants
Row types.
Name | Value | Description
sgSimpleRow | 0 | Standard row.
sgGroupHeader | 1 | Group header.
sgGroupFooter | 2 | Group footer.

See Also

Type (SGRow)


sgScrollBar Enum

See Also
sgScrollBar Constants
Scrollbar settings.
Name | Value | Description
sgSBNone | 0 | Scrollbars are not displayed.
sgSBVertical | 1 | Show only vertical scroll bar.
sgSBHorizontal | 2 | Show only horizontal scroll bar.
sgSBAll | 3 | Show both vertical and horizontal scroll bars.

See Also

ScrollBars


sgScrollBarMode Enum

See Also
sgScrollBarMode Constants
Scrollbar mode settings.
Name | Value | Description
sgSBRegularMode | 0 | Show standard (3D) scrollbars.
sgSBEncartaMode | 1 | Show flat scrollbars.
sgSBFlatMode | 2 | Show flat scrollbars.

See Also

FlatScrollBars


sgScrollTip Enum

See Also
sgScrollTip Constants
Scrollbar tip settings.
Name | Value | Description
sgScrollTipsNone | 0 | Scroll tips are not displayed.
sgScrollTipsHorizontal | 1 | Show scroll tips for the horizontal scroll bar.
sgScrollTipsVertical | 2 | Show scroll tips for the vertical scroll bar.
sgScrollTipsBoth | 3 | Show scroll tips for both the horizontal and vertical scroll bars.


sgSearchFlag Enum

See Also
sgSearchFlag Constants
Name | Value | Description
sgSearchDefault | 0 | Do not use any special processing when comparing values.
sgSearchText | 1 | Use formatted text when comparing values.
sgSearchCaseSensitive | 2 | Text comparasion is case sensitive.


sgSelectionMode Enum

See Also
sgSelectionMode Constants
Selection mode settings.
Name | Value | Description
sgSelectionNone | 0 | No selections.
sgSelectionFree | 1 | Select only rectangular cell area.
sgSelectionByRow | 2 | Select only rows.
sgSelectionByColumn | 3 | Select only columns.
sgSelectionByRowAndColumn | 4 | Select both rows and columns.
sgSelectionModeAll | 5 | Enable all selection modes.


sgShowButton Enum

See Also
sgShowButton Constants
Cell's action button settings.
Name | Value | Description
sgHideButton | 0 | Do not show cell's button.
sgShowButtonFocused | 1 | Show cell's button only when cell is focused.
sgShowButtonAlways | 2 | Allway show cell's button.

See Also

ShowButton (SGControl)


sgSortOrder Enum

See Also
sgSortOrder Constants
Sorting order settings.
Name | Value | Description
sgNoSorting | 0 | Do not sort.
sgSortAscending | 1 | Sort in ascending order.
sgSortDescending | 2 | Sort in descending order.


sgSortType Enum

See Also
sgSortType Constants
Sorting type settings.
Name | Value | Description
sgSortTypeDefault | 0 | Convert values to the column's data type before comparing.
sgSortTypeCustom | 1 | Fire the CompareCell event to compare two values.
sgSortTypeNumber | 2 | Convert to double-precision values before comparing.
sgSortTypeString | 3 | Convert to string values before comparing.
sgSortTypeNoCaseString | 4 | Convert to string values before comparing. Ignore case.
sgSortTypeDateTime | 5 | Convert to date-time values before comparing.


sgSpecialMode Enum

See Also
sgSpecialMode Constants
Special working mode settings.
Name | Value | Description
sgModeNone | 0 | Grid is in the standard mode.
sgModeListBox | 1 | Grid is in the listbox mode.

See Also

SpecialMode


sgTabKeyBehavior Enum

See Also
sgTabKeyBehavior Constants
Tabulator key settings.
Name | Value | Description
sgTabControls | 0 | TAB key jumps over controls on the form.
sgTabColumns | 1 | TAB key jumps to next focusable column.
sgTabRows | 2 | TAB key jumps to next focusable row.

See Also

TabKeyBehavior


sgUserResizing Enum

See Also
sgUserResizing Constants
User resizing settings.
Name | Value | Description
sgNoUserResizing | 0 | User can not resize rows and columns.
sgAllowRowResizing | 1 | User can resize rows.
sgAllowColResizing | 2 | User can resize columns.
sgAllowRowColResizing | 3 | User can resize both rows and columns.

See Also

UserResizing


sgUserRowColDrag Enum

See Also
sgUserRowColDrag Constants
User's row and column dragging settings.
Name | Value | Description
sgNoRowColDrag | 0 | User can not drag rows and columns.
sgAllowRowDrag | 1 | User can drag rows.
sgAllowColDrag | 2 | User can drag columns.
sgAllowRowColDrag | 3 | User can drag both rows and columns.

See Also

UserDragging


sgUserRowColHide Enum

See Also
sgUserRowColHide Constants
User's row and column hiding settings.
Name | Value | Description
sgNoRowColHide | 0 | User can not hide rows and columns.
sgAllowRowHide | 1 | User can hide rows.
sgAllowColHide | 2 | User can hide columns.
sgAllowRowColHide | 3 | User can hide both rows and columns.

See Also

UserHiding


AUGUST
Mo | Tu | We | Th | Fr | Sa | Su
 |  |  |  |  |  | 1
2 | 3 | 4 | 5 | 6 | 7 | 8
9 | 10 | 11 | 12 | 13 | 14 | 15
16 | 17 | 18 | 19 | 20 | 21 | 22
23 | 24 | 25 | 26 | 27 | 28 | 29
30 | 31 |  |  |  |  |


SGGrid Control

Properties [image] Methods [image] Events Send us your Feedback
SGGrid Control

Name: | SGGrid
Description: | Stinga BeeGrid Control
GUID: | {97BD7A14-77E0-11D2-8EAE-008048E27A77}
Version: | 1.0


Calculation Example

Applies To [image] Sample Code Send us your Feedback
Calculation Example

This sample demonstrates how to use the SGCalculation object.

Calculation Example

DataRowCount, DataColCount, Columns, Array, FitLastColumn, Rows
None
FetchGroupHeaderData, FetchGroupFooterText


Cell Object Example

Applies To [image] Sample Code Send us your Feedback
Cell Object Example

This sample enumerates all cells and changes background and font colors.

Cell Object Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, HeadingRowCount, HeadingColCount, TextAlignment, RedrawEnabled, Font, Row, DefaultColWidth, DefaultRowHeight, Styles, GroupByBoxVisible
None
None


Cell Fore Color Example

Applies To [image] Sample Code Send us your Feedback
Cell Fore Color Example

The following example changes the fore color, padding and font weight of a cell bellow the mouse pointer.

Cell Fore Color Example

EnterKeyBehavior, DataRowCount, DataColCount, RedrawEnabled, RowNumbering, Columns, Array, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
MouseMove


Control and ValueItems Example

Applies To [image] Sample Code Send us your Feedback
Control and ValueItems Example

The following example creates two columns. The first column uses a DropDown control and the second uses a check-box.

Control and ValueItems Example

DataRowCount, DataColCount, GroupByBoxVisible
None
None


FetchCellStyle Example

Applies To [image] Sample Code Send us your Feedback
FetchCellStyle Example

The following example paints calls using a cell value to get color.

FetchCellStyle Example

DataRowCount, Columns, GroupByBoxVisible
None
FetchCellStyle


Letter Heading Column Example

Applies To [image] Sample Code Send us your Feedback
Letter Heading Column Example

The following example uses the first data column as heading column. The first column displays letter to mark row.

Letter Heading Column Example

EnterKeyBehavior, DataRowCount, DataColCount, HeadingColCount, Row, Columns, Styles, Array, GroupByBoxVisible
None
ColMove, ColHide, RowColChange


Columns Properties Example

Applies To [image] Sample Code Send us your Feedback
Columns Properties Example

The following examples creates four columns in the three different ways. It fills cells with following columns properties: Key, ColIndex, DBIndex, DBField, Caption and Position.
The code below adds columns:

   SGGrid1.DataColCount = 2
   SGGrid1.Columns.Add
   With SGGrid1.Columns.InsertAt(1)
      .Caption = "Inserted"
   End With

Note: When you remove a column, the ColIndex property has changed.

SGGrid1.Columns.Remove 2

Columns Properties Example

DataRowCount, DataColCount, DefaultColWidth, ClientWidth, Columns, Rows, GroupByBoxVisible
None
None


Condition Example

Applies To [image] Sample Code Send us your Feedback
Condition Example

This sample uses Between operator for row filtering. When you click on the button it increases the Condition members, Value1 and Value2 by 100 and applies new filter.

Condition Example

DataRowCount, DataColCount, Columns, Styles, RowFilters, GroupByBoxVisible
None
None


Filters Example

Applies To [image] Sample Code Send us your Feedback
Filters Example

The following example shows how to use the SGFilters object. Two SGFilter objects are added to the collection. The "All" button apply both filters, the "First Filter" button apply the first one and the "Second Filter" button second one. The button "Clear" remove filters action.

Filters Example

Filter Action:

DataRowCount, Columns, Styles, RowFilters, GroupByBoxVisible
None
None


AfterDelete Example

Applies To [image] Sample Code Send us your Feedback
AfterDelete example

To try this example select any row in the grid and press del key.

AfterDelete Example

EnterKeyBehavior, DataRowCount, DataColCount, HeadingColCount, HeadingFont, Font, Row, Columns, Styles, Array, AllowDelete, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
AfterDelete


AfterEdit example

Applies To [image] Sample Code Send us your Feedback
AfterEdit example

To try this example edit any cell and move to an another cell.

AfterEdit Example

Skip sample code

DataRowCount, DataColCount, Array, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
AfterEdit


Appearance Properties Example

Applies To [image] Sample Code Send us your Feedback
Appearance Properties Example

The Appearance Properties Example.

Appearance Properties Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, HeadingRowCount, HeadingColCount, FocusRect, FocusRectColor, CellsBorderVisible, Appearance, AllowEdit, GroupByBoxVisible
None
None


Array Example

Applies To [image] Sample Code Send us your Feedback
Array Example

This sample demonstrates how to populate the grid array with data.

Array Example

EnterKeyBehavior, DataRowCount, DataColCount, RowNumbering, Columns, Array, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
None


Caption Example

Applies To [image] Sample Code Send us your Feedback
Caption Example

This sample illustrates how to create and customize the grid's caption.

Caption Example

Styles
None
None


Resize Grid Example

Applies To [image] Sample Code Send us your Feedback
Resize Grid Example

Resize the window to see how example works. Example resize the grid cells using the ClientWidth and ClientHeight properties.

Resize Grid Example

BackColor, GridBorderStyle, ScrollBars, DataRowCount, DataColCount, HeadingRowCount, HeadingColCount, EvenOddStyle, ColorEven, ColorOdd, FocusRect, ClientWidth, CellsBorderColor, EqualRowHeight, EqualColWidth, Columns, Styles, Rows, AllowEdit, GroupByBoxVisible
None
None


EditMask Example

Applies To [image] Sample Code Send us your Feedback
EditMask Example

This sample demonstrates the EditMask and the EditMaskDataMode properties. To understand how those properties works, enter some data into the last column.

EditMask Example

EnterKeyBehavior, DataRowCount, DataColCount, UserDragging, Row, Columns, Array, Editing, FitLastColumn
None
RowColChange


Edit Properties Example

Applies To [image] Sample Code Send us your Feedback
Edit Properties Example

This sample demonstrates how to enable data input and deleting. In addition, it changes the Enter and the Tab keys behavior to speed up data input.

Edit Properties Example

TabKeyBehavior, EnterKeyBehavior, NavigationWrapMode, AllowAddNew, AllowDelete, AllowEdit
None
None


EditSel Example

Applies To [image] Sample Code Send us your Feedback
EditSel Example

The following example searches the grid's array for a value with same beginning as data you entred. If it finds such data, fills current cell with it. Enter some text to first cell, press enter and start new word with same letter as previous text.

EditSel Example

EnterKeyBehavior, DataRowCount, Value, Columns, Array, Rows, AllowAddNew, EditSelStart
None
KeyUpEdit


Ellipsis Example

Applies To [image] Sample Code Send us your Feedback
Ellipsis Example

Click the column's header to change value of the Ellipsis property.

Ellipsis Example

Ellipsis, Columns, Array
None
ColHeadClick


FetchColumnData Example

Applies To [image] Sample Code Send us your Feedback
FetchColumnData Example

The following example uses the FetchColumnData event to multiply first two columns and displays result in the unbound column. The property SkipReadOnly is set to True to speed up data entering. The example uses the KeyPressEdit event to restricts data entry to numeric values.

FetchColumnData Example

EnterKeyBehavior, DataColCount, SkipReadOnly, Row, Columns, Array, AllowAddNew, GroupByBoxVisible
None
KeyPressEdit, FetchColumnData


Fetch Group Footer Example

Applies To [image] Sample Code Send us your Feedback
Fetch Group Footer Example

The following example fills the grid with random numbers. Groups them by odd and even. Uses the FetchGroupFooterStyle event to set style and the FetchGroupFooterText event to set a footer text.

Fetch Group Footer Example

DataRowCount, Columns, Array, FitLastColumn, Rows, GroupHeadings, GroupByBoxVisible
None
FetchGroupHeaderData, FetchGroupFooterStyle, FetchGroupFooterText, FormatText


Cell Tool Tip Example

Applies To [image] Sample Code Send us your Feedback
Cell Tool Tip Example

The following example uses the FetchCellTip event to take control over the tool tip display. Click any call in the grid and move the mouse pointer over cells to display the cell tip window.

Cell Tool Tip Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, Columns, Styles, Rows, AllowEdit, CellTips, CellTipsDelay, GroupByBoxVisible
None
FetchCellTip


Frozen Rows and Cols Example

Applies To [image] Sample Code Send us your Feedback
Frozen Rows and Cols Example

Press buttons to freeze/unfreeze rows and columns.

Frozen Rows and Cols Example

DataRowCount, DataColCount, GridLines, HeadingGridLines, RedrawEnabled, RowNumbering, Columns, Styles, Array, Rows, FrozenColCount, GroupByBoxVisible
None
None


ListBox Example

Applies To [image] Sample Code Send us your Feedback
ListBox Example

The following example makes the grid look like the ListBox.

ListBox Example

BackColor, ScrollBarTrack, ScrollBarTips, DataRowCount, DataColCount, HeadingRowCount, HeadingColCount, GridLines, RedrawEnabled, CellBackColor, ClientWidth, CellsBorderVisible, Columns, Styles, VScrollWidth, Array, Appearance, FitLastColumn, AllowEdit, SpecialMode, License, ScrollTipColumn, GroupByBoxVisible
None
None


Move Example.

Applies To [image] Sample Code Send us your Feedback
Move Example.

The following example demonstrates how to move the current record using MoveFirst, MovePrevious, MoveNext, MoveLast, MoveRelative and MoveToRowKey methods. In addition, it sets BOF and EOF properties after each action.

Move Example

BOF = False EOF = False

EnterKeyBehavior, GridBorderStyle, DataRowCount, DataColCount, RedrawEnabled, RowNumbering, Columns, Array, Rows, SpecialMode, CacheAllRecords, ColumnClickSort, BOF, GroupByBoxVisible
MoveFirst, MoveNext, MovePrevious, MoveToRowKey
None


NewTopPosition Example

Applies To [image] Sample Code Send us your Feedback
NewTopPosition Example

Click the button to see how the NewRowPos property works.

NewTopPosition Example

EnterKeyBehavior, BackColor, DataRowCount, HeadingColCount, Columns, FitLastColumn, SelectionMode, MultiSelect, AllowAddNew, SpecialMode, CacheAllRecords, ColumnClickSort, OLEDragMode, Caption, NewRowPos
None
FormatText


Odd-Even Properties Example

Applies To [image] Sample Code Send us your Feedback
Odd-Even Properties Example

The following example creates the black-white grid and fills grid with the sample data.

Odd-Even Properties Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, EvenOddStyle, ColorEven, ColorOdd, RedrawEnabled, Row, EqualRowHeight, EqualColWidth, Styles, GroupByBoxVisible
None
None


OLEDropMode Example

Applies To [image] Sample Code Send us your Feedback
OLEDropMode Example

The drag text from the text box to the grid.

OLEDropMode Example

DataColCount, RedrawEnabled, MouseRow, RowNumbering, Rows, OLEDropMode, GroupByBoxVisible
None
OnInit, OLEDragDrop


Middle Col Example

Applies To [image] Sample Code Send us your Feedback
Middle Col Example

The following example uses the AfterScroll event to paint a column placed at the middle of grid to blue. Scroll columns to change a column at the middle of grid.

Middle Col Example

LeftCol, ClientWidth, Columns, Styles
None
AfterScroll


HitTest Example

Applies To [image] Sample Code Send us your Feedback
HitTest Example

The following example changes the fore color, padding and font weight of a cell bellow the mouse pointer.

HitTest Example

EnterKeyBehavior, DataRowCount, DataColCount, RedrawEnabled, MouseCol, MouseRow, RowNumbering, Columns, Array, Rows, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
HitTest
MouseMove


RedrawEnabled Example

Applies To [image] Sample Code Send us your Feedback
RedrawEnabled Example

The following example shows how to speed up the grid's drawing with the RedrawEnabled property.

RedrawEnabled Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, RedrawEnabled, Styles, Rows, GroupByBoxVisible
None
None


Row/Col Properties Example

Applies To [image] Sample Code Send us your Feedback
Row/Col Properties Example

The following example changes the current col and row.

Row/Col Properties Example

EnterKeyBehavior, BackColor, GridBorderStyle, DataRowCount, DataColCount, HeadingRowCount, RedrawEnabled, RowNumbering, Columns, Styles, Array, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
None


RowNumbering Example

Applies To [image] Sample Code Send us your Feedback
RowNumbering Example

The following example shows how to use the RowNumbering and the HeadingColCount properties.

RowNumbering Example

Row Numbering HeadingColCount (could be 0 or 1)

EnterKeyBehavior, DataRowCount, DataColCount, RowNumbering, Columns, Array, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
None


Sort Example

Applies To [image] Sample Code Send us your Feedback
Sort Example

The following example fills grid with sample data and uses the Sort method to sort them.

Sort Example

DataRowCount, Columns, License, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
ColHeadClick


Sorting and Grouping example

Applies To [image] Sample Code Send us your Feedback
Sorting and Grouping example

Click each chack box to see how those properties works toghether.

Sorting and Grouping example

CacheAllRecords ColumnClickSort Group by category

EnterKeyBehavior, EqualRowHeight, Columns, FitLastColumn, SelectionMode, MultiSelect, SpecialMode, CacheAllRecords, ColumnClickSort
ImportDataString
BeforeGroupChange


Sort Columns Example

Applies To [image] Sample Code Send us your Feedback
Sort Columns Example

This sample uses the RowHeadClick event to sort columns by cells value in the clicked row. Click row selector to sort columns.

Sort Columns Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, RedrawEnabled, DefaultColWidth, Styles, Array, Rows, GroupByBoxVisible
None
RowHeadClick


StyleConditions Example

Applies To [image] Sample Code Send us your Feedback
StyleConditions Example

The following example fills the grid array random numbers and create style for a each cell possible value.

StyleConditions Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, RedrawEnabled, Styles, CellStyleConditions, GroupByBoxVisible
None
None


Sum Cols And Rows Example

Applies To [image] Sample Code Send us your Feedback
Sum Cols And Rows Example

The following example sums all rows and display result in the last row. The last column is unbound and it displays sum of other columns.

Sum Cols And Rows Example

EnterKeyBehavior, DataRowCount, DataColCount, Columns, Rows, GroupByBoxVisible
None
AfterEdit, FetchColumnData


ValueItems Example

Applies To [image] Sample Code Send us your Feedback
ValueItems Example

The following example uses the CellAsPicture property to create pictures for a value items.

ValueItems Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, RowNumbering, Columns, Styles, Array, Rows, Cell, GroupByBoxVisible
None
None


Virtual Events Example

Applies To [image] Sample Code Send us your Feedback
Virtual Events Example

The following example shows how to read, edit, add and delete data in the sgVirtualEvents DataMode. Also it uses the FetchCellStyle event to paint cells.

Virtual Events Example

TabKeyBehavior, EnterKeyBehavior, DataRowCount, HeadingColCount, RedrawEnabled, SkipReadOnly, DataMode, RowNumbering, Columns, Rows, AllowAddNew, AllowDelete, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
ValidateEdit, KeyPressEdit, FetchCellStyle, VirtualAddRow, VirtualDeleteRow, VirtualReadData, VirtualWriteData, FormatText


GroupHeadings Example

Applies To [image] Sample Code Send us your Feedback
GroupHeadings Example

The following example loads grid data and creates two groups. Click button to write all GroupHeadings to the grid.

GroupHeadings Example

DataRowCount, DataColCount, Columns, Array, FitLastColumn, Rows, GroupHeadings, GroupByBoxVisible
ImportDataString
FetchGroupHeaderData, FetchGroupFooterText


Add/Remove Groups Example

Applies To [image] Sample Code Send us your Feedback
Add/Remove Groups Example

Click each check box to add/remove groups.

Add/Remove Groups Example

Group by category Group by company

EnterKeyBehavior, BackColor, LeftCol, EqualRowHeight, Columns, FitLastColumn, SelectionMode, MultiSelect, SpecialMode, ColumnClickSort, AutoScroll
ImportDataString
None


GroupHeadings Example

Applies To [image] Sample Code Send us your Feedback
GroupHeadings Example

The following example fills the grid array with random numbers and group odd and even numbers. It uses the GroupHeadings property to create the group header caption.

GroupHeadings Example

DataRowCount, Columns, Array, FitLastColumn, GroupHeadings, GroupIndentation, GroupByBoxVisible
RefreshGroups
FetchGroupHeaderData, FormatText


Odd/Even Group Example

Applies To [image] Sample Code Send us your Feedback
Odd/Even Group Example

The following example fills the grid array with random numbers and group odd and even numbers. It uses the GroupHeadings property to create the group header caption.

Odd/Even Group Example

DataRowCount, Columns, Array, FitLastColumn, Rows, GroupHeadings, GroupByBoxVisible
RefreshGroups
FetchGroupHeaderStyle, FetchGroupHeaderData


Range Set/Get Example

Applies To [image] Sample Code Send us your Feedback
Range Set/Get Example

Select some cells and drag them somewhere to the grid.

Range Set/Get Example

DataRowCount, DataColCount, Columns, Array, SelectionMode, Selection, OLEDragMode, OLEDropMode, GroupByBoxVisible
HitTestObject, CreateRange
OLEDragDrop


Ranges Example

Applies To [image] Sample Code Send us your Feedback
Ranges Example

This sample makes cross selection over the grid.

Ranges Example

EnterKeyBehavior, BackColor, GridBorderStyle, DataRowCount, DataColCount, HeadingRowCount, HeadingColCount, Columns, Styles, Array, Selection, Rows, CacheAllRecords, ColumnClickSort, GroupByBoxVisible
None
None


FindTag Example

Applies To [image] Sample Code Send us your Feedback
FindTag Example

The following example changes a row's tag when it's updated. Edit some cells and click button to find updated rows.

FindTag Example

TopRow, DataRowCount, DataColCount, RowCount, Rows, GroupByBoxVisible
None
AfterUpdate


GroupHeadings Example

Applies To [image] Sample Code Send us your Feedback
GroupHeadings Example

The following example fills the grid array with random numbers and group odd and even numbers. Click on the button to show rows with value less then 10000.

GroupHeadings

DataRowCount, Columns, Array, FitLastColumn, Rows, GroupByBoxVisible
CollapseAll
None


Paint New Row Example

Applies To [image] Sample Code Send us your Feedback
Paint New Row Example

The following example sets a row tag to New when a new row is added. Click the button to paint new rows to green..

Paint New Row Example

DataRowCount, DataColCount, Rows, AllowAddNew, GroupByBoxVisible
None
AfterInsert


Vertical Menu Example

Applies To [image] Sample Code Send us your Feedback
Vertical Menu Example

Click on a button like cell to enlarge it.

Vertical Menu Example

ScrollBars, DataRowCount, HeadingRowCount, RedrawEnabled, FocusRect, ClientHeight, Columns, FitLastColumn, Rows, AllowEdit, GroupByBoxVisible
None
MouseDown


RowCollection Example

Applies To [image] Sample Code Send us your Feedback
RowCollection Example

The following example uses the SGRowCollection to get a value of the each child row in a group.

RowCollection Example

DataRowCount, Columns, Array, FitLastColumn, Rows
Sort
FetchGroupHeaderData


BackColor Example

Applies To [image] Sample Code Send us your Feedback
BackColor Example

This sample paints each cell to shade of green.

BackColor Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, HeadingColCount, RedrawEnabled, Row, DefaultColWidth, Columns, Styles, GroupByBoxVisible
None
None


CopyFrom (Style) Example

Applies To [image] Sample Code Send us your Feedback
CopyFrom (Style) Example

The following example shows difference between the style's CopyFrom method and the style's Value property.

CopyFrom (Style) Example

BackColor, GridBorderStyle, DataRowCount, DataColCount, RedrawEnabled, Row, Columns, Styles, GroupByBoxVisible
None
None


DisplayType Example

Applies To [image] Sample Code Send us your Feedback
DisplayType Example

The following example fills the grid with sample data and sets a each column to the different DisplayType.

DisplayType Example

DataRowCount, DataColCount, RedrawEnabled, Columns, GroupByBoxVisible
None
None


PictureAlign And TextAlign Example

Applies To [image] Sample Code Send us your Feedback
PictureAlign And TextAlign Example

The following example shows different combination of a display type, picture and text alignment.

PictureAlign And TextAlign Example

DataRowCount, DataColCount, RedrawEnabled, Columns, Rows, CellAt
None
AfterEdit


Styles Example

Applies To [image] Sample Code Send us your Feedback
Styles Example

The following example enum grid styles and fill grid with style properties.

Styles Example

EnterKeyBehavior, BackColor, DataRowCount, DataColCount, HeadingColCount, RedrawEnabled, Columns, Styles, Rows
None
None


ValueItem Example

Applies To [image] Sample Code Send us your Feedback
ValueItem Example

The following example demonstrates how to use the SGValueItem object.

ValueItem Example

DataRowCount, DataColCount, Columns
None
None


Translate (ValueItems) Example

Applies To [image] Sample Code Send us your Feedback
Translate (ValueItems) Example

The following example displays values of two first columns in the last one. Change some values in the first or second column to see effect.

Translate (ValueItems) Example

DataRowCount, DataColCount, Col, Columns, Rows
None
Change


IE Version

This example requires Microsoft® Internet Explorer 5 or higher!


OLEDBBeeGrid10

Description: | Stinga BeeGrid Control 1.0 (OLEDB)
Typelib GUID: | {97BD7A06-77E0-11D2-8EAE-008048E27A77}
Version: | 1.0
LocaleID: | 0

Write detailed description here...


SGStyleCondition Methods

Object SGStyleCondition does not contain any method.


SGRowCollection Methods

Object SGRowCollection does not contain any method.


SGValueItem Methods

Object SGValueItem does not contain any method.


SGCalculation Methods

Object SGCalculation does not contain any method.


SGRowBuffer Methods

Object SGRowBuffer does not contain any method.


Samples

Back To Topic
Free Edition

Not available in Free Edition!


Expression Property (SGFilters Collection)

Expression Property (SGFilters Collection)
Not yet implemented.
Syntax

object.Expression As String

The object placeholder represents an object expression that evaluates to the SGFilters object.

See Also

SGFilters