Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Grid User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.7 Run-Time Initialization

The overridable CGXGridCore::OnGridInitialUpdate() method is the core of the initialization process of a grid view or grid control. You should override this method if you have any one-time initialization such as registering controls, setting the number of rows and columns, or initializing properties or styles.

If you use Objective Grid as a dialog control or an embedded window, you are responsible for calling the CGXGridWnd::Initialize() method yourself. This can be done after creating the window with two-phase construction (like CWnd), or in the OnInitDialog() method of your dialog class. Initialize() will call OnGridInitialUpdate().

If you use the grid as a view, OnInitialUpdate() will be called by the framework after the view is first attached to the document, but before the view is initially displayed. In a workbook, the OnInitialUpdate() method is called for each worksheet, even if it is not visible. The OnInitialUpdate() method will call OnGridInitialUpdate().

The grid component distinguishes between shared and unique attributes. CGXGridCore maintains attributes that are unique to each grid object. Shared attributes such as row heights and cell contents have been moved to an extra class, the CGXGridParam class. Each grid object owns a pointer to a parameter object which is an instance of the CGXGridParam class. The parameter object maintains several other objects that can be shared by associated views of one document. The properties object with profile settings, the data object with the cells map, the print device object with the printer settings, the range lists with selected and covered cells, the Undo/Redo lists, and the column widths and row heights are all maintained by CGXGridParam. The parameter object can be maintained by the document or by the grid object itself.

A main task of OnInitialUpdate() is to attach a parameter object to the grid object. If you do override OnInitialUpdate(), you can create a parameter object of your own and attach it to the grid using CGXGridCore::SetParam(). However, if you do not want to maintain the object yourself, the base class version of OnInitialUpdate() calls OnGridInitialUpdate(), which then creates all necessary objects on the heap. OnGridInitialUpdate() creates only those objects which you did not previously initialize.

Here is an example of allocating the parameter object from the heap when using a stand-alone grid view or grid window.

Another common requirement is to use the grid view attached to a document. In this case, all data should be maintained by the document. You can embed the parameter object in the document.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.