StringGrids Selection Issues
Original Reporter info from Mantis: wp @wpam
-
Reporter name:
Original Reporter info from Mantis: wp @wpam
- Reporter name:
Description:
In a StringGrid, having the options goRangeSelect and goSelectionActive set, a rectangular range of cells can be selected; the selection can be extended by holding the SHIFT key down when the other corner of the selection rectangle is clicked, or when an arrow key is pressed.
This behavior is broken when the Selection is set by code:
StringGrid1.Selection := TGridRect(Rect(1,1,2,2));
When now the user tries to extend the selection the 1st corner of the selection is forgotten and a new selection is defined starting at the 2nd corner.
Looking into the source code of procedure TCustomGrid.SetSelection, there is a line resetting the internal variable FSelectActive at the end of the method; therefore, the grid "forgets" that it is in selection mode. In my opinion, FSelectActive is should remain at true.
The attached patch removes this line from SetSelection. Now the Selection behavior of the grid is as expected, and I do not see any side effects.
Steps to reproduce:
Run attached program, a rectange between cells (1,1) and (2,2) is selected. Hold the SHIFT key down and click on one of the non-selected cells. The expected behavior is that the selection rectange would extend between cell (1,1) and the clicked cell. The observed behavior is that the selection range extends between cell (2,2) and the selected cell. Therefore, the original selection is "forgotten".