Objective Grid: Preventing the user from selecting multiple rows

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

Problem


How can I prevent the user from selecting more than one row at a time?


Cause



Action


There are several alternatives:

  1. Turn off the grid selection mechanism (call EnableSelection()).  Add a handler for mouse clicks yourself (OnLButtonClickedRowCol()) and then call SelectRange() to select the one row.
  2. Another solution is to override CanChangeSelection() as follows:

BOOL CMyGrid::CanChangeSelection(CGXRange* pRange, BOOL bIsDragging, BOOL bKey)
{
if (pRange != NULL && pRange->GetHeight() > 1)
return FALSE;
return CGXGridCore::CanChangeSelection(pRange, bIsDragging, bKey);
}

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

Others in this category