<< Return to Main Index

< Return to Class Index

CGXGridCore::CanChangeSelection

virtual BOOL CanChangeSelection(CGXRange* pRange, BOOL bIsDragging, BOOL bKey);?

pRange

A pointer to the range-object with the new coordinates. If it is NULL, all selections will be changed (e.g., removed).

bIsDragging

Specifies if the mouse is pressed yet.

bKey

Specifies if the user has selected the cells by pressing SHIFT and an arrow key.

Return Value

You should return TRUE if the range can be selected; FALSE if the range should not be selected.

Remarks

This method is called before a range of cells, rows or columns shall be selected or if the range shall be modified.

When the user is selecting cells by dragging the mouse, this method gets called for each new selection as long as the user presses the mouse. When the user releases the mouse button, the method is called with bIsDragging set to FALSE.

You can override this method if you want to restrict the range to be selected to specific areas. You only need to modify the range passed with pRange to do this or return FALSE.

Example

This example restricts the range which can be selected by the user to row 5-10:

BOOL CSampleView::CanChangeSelection(CGXRange* range, BOOL, BOOL)
{
   if (range)
   {
      range->top = max(range.top, 5);
      range->bottom = min(range.bottom, 10);
   }

   return TRUE;
}

See Also

CGXGridCore::OnChangedSelection CGXGridCore::OnStartSelection

CGXGridCore

Class Overview | Class Members