|
CGridCtrl:JoinCells, 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.
Syntax
CGridCtrl: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".
Example
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:
|
params =
|
|
|
{
|
|
|
nCols = 12,
|
|
|
nRows = 20,
|
|
|
nSheets = 1,
|
|
|
nSH_Cols = 1,
|
|
|
nSH_Width = 24,
|
|
|
nTH_Rows = 2,
|
|
|
nTH_Height = 16,
|
|
|
}
|
|
|
V = new_gridview("My Grid", params
)
|
|
|
G = new_gridctrl(V)
|
|
|
label = { "A", "B", "C", "D"
}
|
|
|
nJoinLabel = 1
|
|
|
nCols = G:GetNumCols()
|
|
|
for nCol = 1,nCols,3 do
|
|
|
G:JoinCells(
nCol, nCol+2, -1, -1)
|
|
|
G:SetHorzAlign( nCol,
-1, 3 )
|
|
|
G:SetStr(nCol, -1,
label[nJoinLabel])
|
|
|
nJoinLabel = nJoinLabel
+ 1
|
|
|
end
|
|
Related Topics
CGridCtrl class
UnJoinCells
SetHorzAlign
SetVertAlign
Mira Pro x64 Script User's Guide, v.8.76 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.
|