CGrid Class Description


The CGrid class provides an alternative to the CGridView class for creating a grid control. Whereas a CGridView attaches to or creates a grid view window, the CGrid class opens a dialog window which may be of either the modeless or modal variety. These dialogs follow the standard Windows rules for modeless and modal dialogs. A modal dialog blocks interaction with windows other than itself whereas a modeless dialog permits interaction with other windows. A modeless dialog is created using new_griddlgmodal and a modal dialog is created using new_griddlg.

As with CGridView derived grid windows, a modeless CGrid derived dialog can execute other scripts while it is open. The script executed from the window or dialog is automatically given a CGridView class object for working with the data in parent grid. See the description below, under "Executing Scripts from a Grid Dialog."

The primary differences between the CGrid and CGridView classes are as follows:

bullet.gif    The CGrid does not support all features of the CGridView class, including multiple grid sheets.

bullet.gif    Whereas the CGridView class can either create a grid window or attach to an existing grid window, the CGrid class can only create a dialog window and cannot attach to an existing grid.

bullet.gif    A modal grid dialog created from a CGrid object stops the script that opened it and blocks interaction with other windows while it remains open. The script that opened the modal dialog resumes when the dialog closes.

bullet.gif    A modeless grid dialog created from a CGrid object continues the script immediately after opening and permits interaction with other Mira windows while open. The modeless dialog ends when you manually close it.

The figure below shows a modeless grid dialog created using new_griddlg, and with various embellishments and script commands added to the pop-up command menu. The script commands appearing in the bottom group were added using the class AddMenu command. The modal version of this dialog would be created using new_griddlgmodal. The pop-up menu for the modal version does not support script commands. This dialog was created by the sample script GridDlg (modeless) test with menu.lua.

Executing Scripts from a Grid Dialog

The dialog's Execute Script menu command may be used to open and execute a script directly from a modeless CGrid dialog. When a script is executed from this command, it is automatically sent a CGridView object named ParentGrid that provides access to the window's grid control. You can use this name directly in the script or you can rename it, like G = ParentGrid. A sample script to call from a Grid Window is provided named Execute from Grid Dialog test.lua.

Usage

Construction

Object = CGrid:new()

Object = new_grid()

Destruction

Object:delete()

Creation - Non-class Functions

This function is normally used to create and attach a new CGrid object as an alternative to the class-based new method. The new_griddlg and new_griddlgmodal methods are the only way to open the CGrid in a new grid dialog.

new_grid

Creates a new instance of the CGrid class. The grid defaults may also be set using the GridParams table. This is an alternative to the CGrid:new method.

new_griddlg

Opens the CGrid object in a modeless dialog.

new_griddlgmodal

Opens the CGrid object in a modal dialog

Construction and Destruction - Class Methods

new

Creates a new instance of a CGridView object. The grid defaults may also be set using the GridParams table.

delete

Deletes the instance of the CGrid object.

GridParams table

The GridParams table may be used to initialize the properties of the new CGrid object when created.

CGrid Methods

AddMenu

Adds a script command to the pop-up menu of the modeless grid dialog.

AddMenuExecute

Adds an "Execute Script" command to the pop-up menu of the modeless grid dialog.

BestFit

Adjusts the grid within the window for best fit over a range of columns.

DeleteMenus

Deletes all script commands from the grid dialog's menu.

TH_FindCol

Finds the top heading column containing the specified string. This is often used to find a grid column using its top heading title.

SH_FindRow

Finds the side heading row containing the specified string. This is often used to find a grid row using its side heading title.

FindCell

Finds the grid cell column and row containing the specified string.

GetNumCols

Returns the number of columns in the grid.

GetNumRows

Returns the number of rows in the grid.

Get

Returns the value of a grid cell.

GotoCell

Sends the grid cursor to the specified cell.

JoinCells

Joins a block of cells into a single cell.

Optimize

Optimizes the width of all columns.

OptimizeRange

Optimizes the widths over a column range.

SetBkColor

Sets the background color of a cell.

SetFontColor

Sets the fot color color of a cell.

SetHorzAlign

Sets the text alignment for a grid column.

SetColWidth

Sets the width of a grid column.

SetVertAlign

Sets the vertical text alignment for a grid row.

SetRowStretch

Sets the vertical stretch factor for a grid row.

SetSH_HorzAlign

Sets the horizontal text alignment of a side heading column.

SetSH_Title

Sets the title of a side header cell.

SetSH_Titles

Sets all titles for a side header column.

SetTH_RowStretch

Sets the vertical stretch factor for a grid heading rows.

SetTH_Title

Sets the title of a top header cell.

SetTH_Titles

Sets all titles for a top header row.

SetTH_VertAlign

Sets the vertical text alignmentfor top heading rows.

SetSH_Width

Sets the width of the side header in screen pixels.

SetFontColor

Sets the text color of a cell.

Set

Sets the grid cell value.

SetHorzAlign

Set the horizontal alignment of specific cells or an entire column. The default alignment is "left".

SetVertAlign

Set the vertical alignment of specific cells or an entire row. The default alignment is "center".

Related Topics

Script Classes, CGridView class, new_griddlg, new_griddlgmodal, Contents


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.