CGridView:JoinCells
The JoinCells method joins, or "merges", a block of cells into a single cell. Although joining can be done anywhere in the grid, it is commonly used to group columns or rows using a second or other line of headings. For example, a second (upper) heading row may be used to make a different heading for groups of every 3 columns. Note that columns and rows in the table body begin at index 1. Side and top headings have index 0, -1, -2, and so on, with increasing distance from the table body. Joined cells can be returned to their original layout using UnJoinCells.
The column and row location of the joined cells continues to use the indices of unjoined cells. For example, if cells starting at column 1 were joined into groups of 10 columns, then the first joined cell is at column index 1, the second joined cell is column 11, and so on.
CGridView:JoinCells( nColLeft, nColRight, nRowTop, nRowBottom )
where nColLeft, nColRight, nRowTop, and nRowBottom are the boundaries of the group of cells to join.
The grid below shows joining in the 2nd header row at index -1. Also notice that the horizontal alignment of joined cells is set to "center".
The following script creates a grid with 2 heading rows and joins the top-most row to cover groups of 3 columns. The heading row closest to the grid body (row index 0) is filled with default column labels (that may be changed using SetStr for columns in row 0). Cells in the second heading row at index -1 are joined into groups of 3 columns each and the labels "A", "B", "C", and "D" are assigned to the 4 joined column headings:
|
-- define the grid properties |
|
|
|
-- create 12 columns |
|
|
|
|
|
|
|
|
|
-- create 2 top heading rows |
|
-- each top heading row has a height of 16 |
|
|
|
-- create a new CGridView window |
|
-- create some simple labels |
|
-- index for accessing join labels |
|
-- get the column count |
|
-- step every 3rd column |
|
-- join the 3 columns, from nCol through nCol+2 |
|
-- 3 means align center |
|
-- set the title of the joined heading cells |
|
-- point index to the next label |
|
|
CGridView class, UnJoinCells, SetHorzAlign, SetVertAlign
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.