CGrid Class Description
The CGrid class provides an alternative to the CGridView class for creating a grid control. Whereas a CGridView creates or attaches a view window, the CGrid class sets up a grid to be opened in a dialog. The dialog may be of either the modeless or modal variety accoding to the standard Windows rules for modeless and modal dialogs:. A modal dialog blocks interaction with windows other than itself. 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. After the CGrid is opened into a modeless dialog, further grid processing may be done by attaching its CGridCtrl object using new_gridctrl.
Here is the sequence of operations for creating and using a:
Setup the CGrid using class methods and data.
Open the CGrid into a dialog using new_griddlg or new_griddlgmodal.
Optional: For further work with the modeless dialog's grid control, attach a CGridCtrl using new_gridctrl.
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 modal version of this dialog would be created using new_griddlgmodal. This dialog was by the sample script GridDlg (modeless) test with menu.lua. Note the script commands appearing in the bottom menu group; these were added using the class AddMenu method.
Mira provides 3 ways to create or work with a grid control:
Modeless CGrid dialog.
Modal CGrid dialog.
Modeless CGridView view window.
The first two methods are available for the CGrid class discussed in this topic. The CGridView class is described elsewhere. The primary differences between the CGrid and CGridView classes are as follows:
The
CGrid class does not support all features of the CGridView
class, including multiple grid sheets.
The
CGridView class may attach an existing grid window
from the desktop, whereas the CGrid class cannot attach to
an existing grid.
A
modal CGrid dialog stops the script immediately after
it is created and takes control of the user interface until the
dialog is closed. The script that opened the modal dialog resumes
when the dialog closes.
A
modeless CGrid dialog and a CGridView
window continues executing the script immediately after opening and
become a participating member of the entire Mira desktop.
A
CGridView window and modeless CGrid
dialog can execute other scripts while it is open.
The
CGridView and modeless CGrid dialog
creation functions both return a CGridView
object for working with the displayed grid data. See the discussion
below.
NOTE: |
The Execute Script pop-up menu command is not available for a modal grid dialog. A modal dialog takes control of the user interface as the single top-most window. To execute scripts from a grid window, either create a modeless grid dialog using new_griddlgmodal or use a CGridView window. |
The modeless CGrid dialog's Execute Script menu command may be used to open and execute a script directly from a modeless CGrid dialog. A script executed from the CGridView or modeless CGrid is sent a ParentGrid object of type CGridView that provides access to the window's grid data. 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.
Construction |
Object = CGrid:new() Object = new_grid() |
Destruction |
Object:delete() |
These functions are used to create and attach a new CGrid object as an alternative to using 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.
Creates a new instance of the CGrid class. This is an alternative to the CGrid:new method. |
|
Opens the CGrid object in a modeless dialog. |
|
Opens the CGrid object in a modal dialog |
Creates a new instance of a CGridView object. The grid defaults may also be set using the GridParams table. |
|
Deletes the instance of the CGrid object. |
|
The GridParams table may be used to initialize the properties of the new CGrid object when created. |
Adds a script command to the pop-up menu of the modeless grid dialog. |
|
Adds an "Execute Script" command to the pop-up menu of the modeless grid dialog. |
|
Adjusts the grid within the window for best fit over a range of columns. |
|
Deletes all script commands from the grid dialog's menu. |
|
Finds the top heading column containing the specified string. This is often used to find a grid column using its top heading title. |
|
Finds the side heading row containing the specified string. This is often used to find a grid row using its side heading title. |
|
Finds the grid cell column and row containing the specified string. |
|
Returns the number of columns in the grid. |
|
Returns the number of rows in the grid. |
|
Returns the value of a grid cell. |
|
Sends the grid cursor to the specified cell. |
|
Joins a block of cells into a single cell. |
|
Optimizes the width of all columns. |
|
Optimizes the widths over a column range. |
|
Sets the background color of a cell. |
|
Sets the fot color color of a cell. |
|
Sets the text alignment for a grid column. |
|
Sets the width of a grid column. |
|
Sets the vertical text alignment for a grid row. |
|
Sets the vertical stretch factor for a grid row. |
|
Sets the horizontal text alignment of a side heading column. |
|
Sets the title of a side header cell. |
|
Sets all titles for a side header column. |
|
Sets the vertical stretch factor for a grid heading rows. |
|
Sets the title of a top header cell. |
|
Sets all titles for a top header row. |
|
Sets the vertical text alignmentfor top heading rows. |
|
Sets the width of the side header in screen pixels. |
|
Sets the text color of a cell. |
|
Sets the grid cell value. |
|
Set the horizontal alignment of specific cells or an entire column. The default alignment is "left". |
|
Set the vertical alignment of specific cells or an entire row. The default alignment is "center". |
Mira Pro x64 Script User's Guide, v.8.77 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.