Objective Grid: Programmatically selecting a row after a selection

Article ID: 706
Last updated: 11 Jun, 2018
Article ID: 706
Last updated: 11 Jun, 2018
Revision: 3
Views: 3311
Posted: 23 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


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'.


Cause



Action


Override 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);
}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 706
Last updated: 11 Jun, 2018
Revision: 3
Views: 3311
Posted: 23 Jan, 2001 by Meltreger B.
Updated: 11 Jun, 2018 by Meltreger B.

Others in this category