The new vbAccelerator Site - more VB and .NET Code and Controls
Source Code
1 ActiveX Controls &nbsp

vbAccelerator S-Grid Control

A lightweight all VB Grid: Smooth Displays and Outlook Style Features!

NOTE: this code has been superceded by the version at the new site.

S-Grid, Outlook Style Demonstration Showing Grouping

Download Code
VB5 code VB5 Control Binary (104kb) VB6 code VB6 Control Binary (104kb)
VB5 code VB5 Demonstration Project (68kb) VB6 code VB6 Demonstration Project (70kb)
VB5 code VB5 Full Source Code (233kb) VB6 code VB6 Full Source Code (267kb)
Required Files:
  • vbAccelerator SSubTmr.DLL for VB5
  • vbAccelerator VB5 ImageList control
  • Required Files:
  • vbAccelerator SSubTmr6.DLL for VB6
  • vbAccelerator VB6 ImageList control

  • &nbsp UpdatedUpdated! 1 November 1999 &nbsp
    &nbsp A new VB6 binary of the control is available, courtesy of Glenn Halbedl. Thanks! Plus a new VB5 compile including 13 minor bug fixes and changes to the control. &nbsp
    &nbsp UpdatedUpdated! 21 March 1999 &nbsp
    &nbsp A few display and code bugs crept into the released version of the control. These are now fixed in the download code. Please note that you need version 1.2 (or higher) of the vbAccelerator ImageList Control to run the demonstration project. &nbsp
    &nbsp Sorting a grid with two rows caused a GPF. &nbsp
    &nbsp Focus rectangle did not draw with dots unless system highlight colour was black. Focus rectangle also drew when the grid was out of focus (hmmm...) (thanks to Sven Wiese Solty). &nbsp
    &nbsp Grid did not reorder when the column before an invisible column was dragged by one place (thanks to Sven Wiese Solty). &nbsp
    &nbsp Only standard character set fonts were supported. Now all font types and DBCS characters should work correctly. (thanks to Lance Franklin). &nbsp
    &nbsp Row following a group row drew in system highlight colour (thanks to Dion Wiggins) &nbsp
    &nbsp Source Code Note &nbsp
    &nbsp This OCX is a binary compatible component which works with all other samples. If you compile your own copy of this OCX yourself please make sure you change the name. See disclaimer and license for more details. &nbsp


    The SGrid control is an all-VB grid which can emulate the Outlook messages list, including grouping of messages and message preview. The highly optimised display code makes this grid draw faster than FlexGrid and other VB grids even while it allows more sophisticated displays to be set up. It is also a good replacement for a ListView in report mode.
    What S-Grid Can Do
    • Row Features
      1. Add, Insert or Remove rows
      2. Rows can be visible or invisible
      3. Row height can be set independently for each row, or automatically calculated based on the contents of the cells.
      4. Rows can be set to be "Group Rows". When this is set, the row extends across all of the cells and displays only the information in the last column of the grid (which doesn't appear in the grid's header)
      5. Sort rows automatically using the grid's inbuilt Sort object, which allows the grid to be sorted by up to 8 columns simultaneously based on many sorting criteria (icon, selection, indentation, text, date, number).
      6. SGrid can theoretically accommodate up to 2 billion rows. Practically, performance becomes unacceptable for grids containing more than about 10,000 rows.
    • Column Features
      1. Add, Insert or Remove columns
      2. Columns can be visible or invisible.
      3. Column headers can be clickable or flat.
      4. Set column width independently for each column, or have it automatically calculated based on the contents of the cells.
      5. Column headers can have text and/or icons, and the icon position can be set to the left or right of the text in the header.
      6. Text in column headers can be aligned Left, Right or Centred.
      7. Get/set the order of the columns in code. Columns can optionally be set so the user can drag them to change the order.
      8. SGrid can theoretically accommodate up to 2 billion columns. A practically maximum is somewhere around 1,000 columns.
    • Cells
      1. Set Background and Foreground colours on a cell by cell basis.
      2. Each cell can have its own font.
      3. Up to two icons per cell, drawn from an image list. CellExtraIcon specifies the first icon to be drawn and CellIcon the second. Icons can optionally be highlighted when selected.
      4. Cells can be indented so selection and drawing starts at a specified offset.
      5. Cells can have up to 8,192 characters of text.
      6. Cell text can be aligned horizontally or vertically left, right or centred; it can appear on a single line or multiple lines; text can appear with a trailing ellipsis (...) or it can be broken on words.
      7. Cells can be included or excluded from the selection box for a row.
      8. The last cell in the grid can be set as the "RowTextColumn". Data in this cell is either drawn directly underneath the standard cells (like the message preview in Outlook) or if the Group Row property is set then only this column is drawn. You can either specify the column that this row starts drawing at or allow the grid to work this out automatically (when it starts drawing at the first cell which is included in the selection box).
    • Other Features
      1. RowMode
        S-Grid works either as a standard grid, where you can individually highlight each cell, or as a row-based grid, where you can highlight whole rows.
      2. Selections
        You can have Multiple or Single selections, and this property can be set either at run-time or design-time.
      3. Background Bitmap
        S-Grid will tile a standard VB Picture object behind the grid.
      4. Virtual Mode
        In Virtual mode, S-Grid will request new rows whenever they need to be displayed. This allows you to add rows as they are required.
      5. Editable Setting
        By setting this property, S-Grid will raise a RequestEdit event whenever the user clicks twice on a cell, or hits the return or space keys on a cell. You can use this to show a child control such as text box or combo box over the grid cell (positioning it to the position retrieved using the CellBoundary method).
      6. Show/hide gridlines at run-time or design-time.

    ... And What S-Grid Doesn't do
    • S-Grid has no data-binding features whatsoever. To load records from a database you must write the code yourself!
    • Each row must have the same number of columns.
    • You cannot group cells together, although you can have one cell in each row which spans multiple columns.
    • S-Grid does not have an IDE designer so the grid's layout cannot be set at design time; it must be set up in code.
    S-Grid Performance
    The following performance tests will give you an idea of how S-Grid performs. The speeds are given for adding a number of rows to a 10 column grid, adding the text Row[y]Col[x] to each cell. For comparison the same grid has also been set up in a ListView in report mode and a standard VB5 FlexGrid. All measurements are given in seconds and were performed on Win95 using VB5 on a PII 266MHz with 32Mb memory and an 8Mb AGP ATI XPert@Work graphics card.

    Control 512 1024 2048 4096 8192 16384 32767
    ListView 0.18 0.36 0.74 1.49 2.78 6.23 11.0
    FlexGrid 1.46 3.74 11.2 35.6 121 Aborted Aborted
    S-Grid 0.31 0.64 1.24 3.50 7.31 13.6 77

    Note: FlexGrid took more than 5 minutes to complete some tests and was stopped
    Performance Test Results

    VB5 codeDownload the SGrid Performance Test project (10kb)

    Coding With S-Grid
    The demonstration project shows how to use all S-Grid's features. The demonstration contains five different forms demonstrating different aspects of S-Grid's use and showing some ideas of how you can use S-Grid in your project. Get stuck into this code!

    Documentation for S-Grid's properties, methods and classes is available as an RTF. This documentation was created with the Active X Documenter.

    Click here to download/view the S-Grid method and event documentation

    Hints and Tips
    The main thing to remember with S-Grid is to ensure you set the Redraw property to False whenever you are changing a large number of cells. This particularly applies when adding or inserting rows and changing the visibility of multiple rows.

    To get your grid to work, make sure you set up the columns before attempting to add any rows. Remember that all rows in the grid have to have the same number of columns.

    If you want a row to span all columns, make sure the last column in the grid is an invisible column with the bRowTextColumn parameter of the AddColumn method set to True. When you add the row, set the RowIsGroup property for that row to True (or set the bGroupRow parameter of the AddRow method to True).

    TopBack to top
    Source Code - What We're About!Back to ActiveX Control Source Code
    Source Code - What We're About!Back to Source Code

    NOTE: this code has been superceded by the version at the new site.


    AboutContributeSend FeedbackPrivacy

    Copyright 1998-2000, Steve McMahon ( All Rights Reserved.
    Last updated: 21 March 2000