CGrid:SetDim


The SetDim method specifies the number of columns, rows, and sheets in the grid. Each sheet is configured with the same number of columns and rows.

Syntax

G:SetDim( nCols )

G:SetDim( nCols, nRows )

G:SetDim( nCols, nRows, nSheets )

where

    nCols is the number of columns to set in each sheet.

    nRows is the number of rows to set in each sheet. If omitted, it defaults to 1

    nSheets is the number of sheets to set. If omitted, it defaults to 1.

Example

The following script creates a grid and increases its dimensions at a later time. Before increasing the dimension, sheet 3 is undefined and the number of rows is 0. After changing the dimensions, sheet 3 exists and hwnce the number of rows is valid.

G = NewGrid(3,10)

-- new grid with 3 cols, 10 rows, 1 sheet

Printf("rows = %d\n", G:GetNumRows() )

-- result: rows = 10

G:SelectSheet( 3 )

-- Select sheet 3 (out of range)

Printf("rows = %d\n", G:GetNumRows() )

-- result: rows = 0 (sheet out of range)

G:SetDim( 10, 12, 4 )

-- change to 10 columns, 12 rows, 4 sheets

G:SelectSheet( 3 )

-- Select sheet 3 (sheet in range)

Printf("rows = %d\n", G:GetNumRows() )

-- result: rows = 12

Related Topics

SetNumCols

SetNumRows

SetNumSheets

CGrid class