When a user left clicks a row or drags the mouse over a row that contains special data, I want to be able to automatically select some of the rows that follow it.
Imagine if a definition of a structure is stored into a grid as shown below.
abc STRUCT
element1 int
element2 bool
END_STRUCT
When the user selects the row containing 'abc', I want to automatically select the whole structure that includes the rows containing 'element1', 'element2' and 'END_STRUCT'.
Any suggestions?
I recommend overriding OnChangeSelection. Here is a simplified sample how to override this method. The sample code will always select two additional rows as soon as the user selects more than one column in a row.
BOOL CGXBrowserGrid::CanChangeSelection(CGXRange* pRange, BOOL bIsDragging, BOOL bKey)
{
if (pRange != NULL && pRange->GetWidth() > 1)
pRange->SetCells(pRange->top, pRange->left, pRange->bottom+2, pRange->right);
return CGXGridCore::CanChangeSelection(pRange, bIsDragging, bKey);
}