ZeeGrid Programming Reference

Cell Addressing

Cell Addressing

A ZeeGrid is a collection of cells. These cells are referenced by index, beginning at zero and continuing as necessary to reference every cell in the ZeeGrid. Whether the cell is the title cell, a column header cell, or a data cell, they are all just one of many cells that make up the ZeeGrid control.

In all cases, index 0 references the ZeeGrid title. Indexing then continues to the column headers for as many columns as the grid contains. Then indexing continues by row, incrementing for each column.

Refer to the following ASCII grids to see the ZeeGrid cell indexing scheme for a 2X2 (2 column, 2 row) grid, then a 3X2 (3 column, 2 row) grid.

      |                                         |
      | index = 0                               |
      |    (Grid 1 Title)                       |
      |                    |                    |
      | index = 1          | index = 2          |
      |   Column 1 header  |   Column 2 header  |
      |                    |                    |
      | index = 3          | index = 4          | 
      |  Data (row 1,col 1)|  Data (row 1,col 2)|
      |                    |                    |
      | index = 5          | index = 6          |
      |  Data (row 2,col 1)|  Data (row 2,col 2)|

      |                                                              |
      | index = 0                                                    |
      |    (Grid 2 Title)                                            |
      |                    |                    |                    |
      | index = 1          | index = 2          | index = 3          |
      |   Column 1 header  |   Column 2 header  |   Column 3 header  |
      |                    |                    |                    |
      | index = 4          | index = 5          | index = 6          |
      |  Data (row 1,col 1)|  Data (row 1,col 2)|  Data (row 1,col 3)|
      |                    |                    |                    |
      | index = 7          | index = 8          | index = 9          |
      |  Data (row 2,col 1)|  Data (row 2,col 2)|  Data (row 2,col 3)|

You can see that the title will always be index 0, and that each column header will always have an index that is equal to its column number.

This is the way the cells in the ZeeGrid are referenced. We usually think in a row, column format when thinking about tabular formatted data and fortunately ZeeGrid has a handy message function (ZGM_GETCELLINDEX) that takes as parameters the row and column and returns the proper index for the given ZeeGrid.

There are also ZeeGrid function messages that take a cell index as a parameter and return the row number (ZGM_GETROWOFINDEX), or column number (ZGM_GETCOLOFINDEX).

In the example grid #2, it could be that the ZeeGrid was dimensioned with 3 columns, but only 2 columns were to be visible. In this case, the grid would appear to look like example grid #1, but it would in fact have 3 columns and would have cell indexes as shown in example grid #2.

ZeeGrids can be dimensioned (ZGM_DIMGRID) with as few as 1 column, to as many as 65535* columns. *I honestly don't know the upper limit to the number of columns. If you need a grid with thousands columns, I feel confident in saying you haven't thought something through. Cell indexes are integer types, but are signed integers internally in the grid. That should allow about one billion columns, but you'll either run out of memory, or hang your computer if you try to make one that big. ZeeGrid should be able to handle any reasonable size of rows and columns. A little common sense here goes a long way.

ZeeGrids can optionally have a special row number column displayed at the far left of the ZeeGrid. This column is referenced as column 0 in some functions, but the 'cells' in it are phantom cells and are not addressable. Your only options with the row number column is to display it or not, and to programmatically set the width of it.

In the Programmers Message Reference, all references to iCellIndex is this index that is being demonstrated in the above ASCII grids.

It is important to realize that after loading the ZeeGrid cells with data, a user operation such as sorting, inserting a row, or deleting a row, could affect the cell index of every data cell (cells with an index greater than the number of columns) in the ZeeGrid. All of these actions can be enabled or disabled through the ZeeGrid message functions. Users can also reorder the display order of ZeeGrid columns. This reordering of columns only change the display order, so the data cell indexes will not be affected. Column reordering can also be enabled or disabled by the programmer.

ZeeGridTMCopyright © 2002-2016 by David Hillard