<< Return to Main Index

< Return to Class Index

CGXGridCore::SetFloatCellsMode

void SetFloatCellsMode(WORD nMode, BOOL bRedraw = TRUE);

nMode

nMode can be one of:

bRedraw

TRUE if grid shall be redrawn, FALSE if not.

Remarks

With SetFloatCellsMode you can turn on and off the calculation of floating cells in the grid.

Floating cells are cells that can automatically expand over empty neighboring cells when the text does not fit into the cell.

An example of floating cells is when the user types text into a cell. The cell will automatically expand while the user is entering more characters than will fit into the cell. Another example for the usage of floating cells is to paste a big text file into the grid. All the text will be displayed and no longer be clipped by cell boundaries.

Floating cells is a very popular feature of MS-Excel that served as an example for the implementation of floating cells in Objective Grid.

How can I use floating cells in my grid?

To enable floating cells, add the following line in OnInitialUpdate (or OnInitDialog)

     SetFloatCellsMode(gxnFloatDelayEval);

With floating cells enabled for the grid, you can enable and disable floating for individual cells with

Please note that certain cell types do ignore the settings specified with SetFloatCell and SetFloodCell. This is because Objective Grid checks CanFloatCell to determine if a specific cell supports floating. With CGXEditControl, CanFloatCell will return the settings as specified with the style attribute, but other cell types like combo boxes or list boxes simply return FALSE.

How does it work?

Floating cells work very much like covered cells with the difference that you can still access and change the individual cells of the covered cell. For example, if cells A5 to E5 are floated you can still click and change cells in the range B5 to E5. For example, if you change cell D5, the cells will automatically become unflooded.

Floating cells have to be calculated depending on the size of the text in a cell. When you type text in a cell, the size of the text will always be calculated and if the text does not fit into a cell, the cell will automatically be expanded.

Many other operations affect floating cells. For example, changing the font for a whole column, resizing a column, or zooming a view affects floating cells. If one of these operations is executed, all affected columns have to be re-evaluated. Re-evaluating all cells in a column can be a very time-consuming operation if you have a grid with many rows. Objective Grid solves this problem by delaying the evaluation of floating cells until they are displayed. The user will not notice any delay when he resizes a column or changes the font of a column.

You can use floating cells in two modes:

gxnFloatDelayEval improves performance a lot and is recommended.

gxnFloatEvalOnDisplay has the advantage that you don’t have to worry about marking cells to be reevaluated when you use the grid by overriding GetStyleRowCol, and the values of the cells can change without notification to the grid.

With gxnFloatDelayEval, the DelayFloatCells method is responsible for marking ranges of cells to be reevaluated.

Typical reasons for calling this function are:

      DelayFloatCells(CGXRange().SetTable());
       DelayFloatCells(CGXRange().SetCols(nFromCol, nToCol));

All grid operations (resizing columns, changing the styles of cells, hiding columns, etc.) take care of properly calling DelayFloatCells. You will have to call this function very rarely.

The evaluation of floating cells is done on demand with the method EvalFloatCells when the user scrolls though the grid.

EvalFloatCells checks the given range if there are cells to be reevaluated and will then mark these cells so that they will not be reevaluated again.

With GetFloatedCellsRowCol you can check if a specific cell is a floated cell.

With GetCellRangeRowCol you can check if a specific cell is a spanned cell, no matter if it is covered, floated or merged.

Control-Factory Specific ->

This method has been implemented using the abstraction mechanism as discussed in the chapter "Reducing the size of your application" in the user's guide. A call to the ImplementFloatCells method from within the control factory class' InitializeGridComponents method will make the concrete implementation of this method available to your application.

If no concrete implementation is available this method performs no action. A warning will be displayed in the debug window.

END Control-Factory Specific

See Also

CGXGridCore::GetFloatCellsMode CGXGridCore::DelayFloatCells CGXGridCore::EvalFloatCells CGXGridCore::GetFloatedCellsRowCol CGXGridCore::GetCellRangeRowCol CGXStyle::SetFloatCell CGXStyle::SetFloodCell CGXControl::CanFloatCell

CGXGridCore

Class Overview | Class Members