Skip to content

LoadEnvironment - cCJGrid

Loads layout information and applies it to the Grid object

Type: Procedure

Syntax

Procedure LoadEnvironment

Call Example

Send LoadEnvironment

Description

LoadEnvironment loads layout information and applies it to the grid object. This is used to restore a user's grid column configuration. LoadEnvironment is called when a grid object is activated (see CreateGridControl). By default, LoadEnvironment does the following:

  1. If a cApplication object does not exist or that application object's pbPreserveEnvironment property is false, it returns and does nothing.

  2. If the grid object's pbRestoreLayout property is false, it returns and does nothing.

  3. It determines the registry key. It does this by getting cApplication object's RegistryKeyString function and appending the grid's psLayoutSection property value. The registry key will be RegistryKeyString + psLayoutSection + "\Grid". If psLayoutSection is blank, an error is raised.

  4. If loads the layout by calling the private message LoadGridLayoutFromRegistry, passing the registry key.

Detecting Changes in Source Layout

When source code changes are made in a grid, the restored layout may interfere with those changes. When this happens, changes made to the grid and its columns will not appear because the old settings are being restored. The grid class attempts to recognize when such a change has occurred by checking if the number of columns has changed. If it has, the previous setting will not be restored. This only catches a small number of the possible changes and it is quite likely that it will not recognize that a change has actually occurred. When this occurs, it will appear that the grid is ignoring your source code changes. The number of columns that appear may be wrong, the ordering and size of the columns may be wrong and some of the grid alignment settings will be wrong.

If this happens, you must tell the system that the menu layout has changed. You can do this by changing (i.e., incrementing) the build number of the grid system by setting the piLayoutBuild property.

During development, it is probably best to disable the loading and saving of the grid's environment. Set pbRestoreLayout of the grid object to False to turn off restore layout for a grid, or set pbPreserveEnvironment of the cApplication object to False to disable restore layout for your entire application.