<< Return to Main Index

< Return to Class Index

CGXGridCore::GetCoveredCellsRowCol

virtual CGXRange* GetCoveredCellsRowCol(ROWCOL nRow, ROWCOL nCol, CGXRange& range);

nRow

Specifies the row id.

nCol

Specifies the column id.

range

A reference to a range where the result will be stored.

Return Value

Returns a pointer to range with the covered cells. If it is NULL, no covered cell range could be found.

Remarks

Overridable method which returns the corresponding covered cells-range of the specified cell.

An example for usage of covered cells might be headlines for a table.

Normally, the range objects are stored in a rangelist maintained by the parameter-object.

You should override this method if covered cells occur in a specific pattern in your grid and you want to specify these covered cells virtual without explicitly storing them (e.g., because you have several thousand rows; see example). In that case, you also have to override MergeCoveredCells.

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 ImplementCoveredCells 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 returns NULL.

END Control-Factory Specific

Example

Example 1 illustrates how GetCoveredCellsRowCol will return the covered cells range for all cells in the specified area:

// When you specify a range of cells as covered with
SetCoveredCellsRowCol(1,1,5,5);

// GetCoveredCellsRowCol will return the range (1,1,5,5) for all cells in this range:
CGXRange range;
GetCoveredCellsRowCol(1,1,range);   // returns (1,1,5,5);
GetCoveredCellsRowCol(2,2,range);   // returns (1,1,5,5);
GetCoveredCellsRowCol(5,1,range);   // returns (1,1,5,5);
// ...

Example 2 illustrates how to specify covered cells virtually when covered cells occur with a specific pattern.

// every fifth row after row 1, the first three columns are covered:

CGXRange* CMyGrid::GetCoveredCellsRowCol(ROWCOL nRow, ROWCOL nCol, CGXRange& range)
{
   // nRow should be 1,6,11,16,...

   if ((nRow-1)%5 == 0 && nCol >= 1 && nCol <= 3)
   {
      range.SetRange(nRow, 1, nRow, 3);
      return &range;
   }
   // normal cell, not covered:
   return NULL;
}

// it is also necessary to override MergedCoveredCells

void CMyGrid::MergeCoveredCells(CGXRange& area)
{
   // loop through all possible ranges and expand area
   ROWCOL nFirstRow = (area.top-1)%5*5;
   ROWOCL nLastRow = (area.bottom-1)%5*5;

   CGXRange r, t;
   for (ROWCOL nRow = nFistRow; nRow <= nLastRow; nRow += 5)
   {
      r.SetRange(nRow, 1, nRow, 3);
      if (t.IntersectRange(r, area))
         area.UnionRange(r, area);
   }
}

See Also

CGXGridCore::SetCoveredCellsRowCol CGXGridCore::MergeCoveredCells CGXGridParam::GetCoveredCellsList

CGXGridCore

Class Overview | Class Members