I think, part of the problem is in terminology used. Until you completely understand what is happening, it must be confusing to find how ‘select’ is used to mean both ‘highlight’ and ‘focus’. In this particular case there should be distinction between the two.
Before I proceed, I'd like you to keep in mind that the focused cell can also be (and actually is) highlighted, but a highlighted cell is not necessarily the focused one.
Now, the OnSelectCell
event has to do with focusing. The handler is fired when the cell is clicked or when you are trying to navigate over it with navigation keys. In short, the handler is invoked when there's an attempt to focus a cell. You can prohibit focusing the cell by resetting the CanSelect
parameter (which, again, means essentially CanFocus, because the cell can be selected, i.e. highlighted, without being focused, and you can't control that with OnSelectCell
).
The goRangeSelect
option and TDrawGrid.Selection
property, on the other hand, have to do with selecting as highlighting. The former allows you (the user) to highlight more than one cell, while the latter points to the range of those cells highlighted.
Now to my main point. Upon invoking the handler in question, Selection
is never accurate, i.e. it is not correlated with the ACol
& ARow
parameters that are passed to the handler. Selection
contains the range of cells that were highlighted just before calling the handler, and it never changes by itself within the handler. Whether one cell or more than one, Selection
stays the same until the handler exits. And it is when that happens (the handler exits) that Selection
changes (and the result depends on whether you reset CanSelect
or not, by the way).
So, in conclusion, you cannot use OnSelectCell
to determine the actual Selection
as the result of the user's most recent action. Instead I would suggest following @Sam's advice and use the OnMouseUp
* event. It also allows you to have control over selection: you can correct the final range if you think the user has selected ‘too much’. In the latter case I would probably consider using OnMouseMove
instead, though, as it allows you to respond more smoothly by correcting the range ‘on the fly’.
OnDrawCell
seems fine too as long as you need just to determine the selection.
*Following your comment, I must add, that you'd also have to employ OnKeyUp
as well, to handle selections made with the keyboard.