Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

illogical SelectCell results

 Post Reply Post Reply
Author
Wilbourn David View Drop Down
Member
Member
Avatar

Joined: 18 Aug 2010
Posts: 46
Post Options Post Options   Quote Wilbourn David Quote  Post ReplyReply Direct Link To This Post Topic: illogical SelectCell results
    Posted: 13 Aug 2019 at 2:11am
I am having problems understanding the Row and Col results I get when I select a range of cells in an AdvStringGrid. 
If I monitor the ARow & ACol values from the OnSelectCell event I get the expected results when I just click in a cell. However if I monitor the Grid.Row/Col, Grid.SelectedRow/ColCount properites or select a range of cells using Shift-click the results seem illogical to me:

The Grid.Row / Grid.Col, Grid.SelectedRow / Grid.SelectedColCount and Grid.Selection properties are changed to the position of the cell or size of block that has just been left.  
All seven properties/values are only updated when Shift is not used. 

e.g. Click @ 0,0 then Shift-click @ 2,2: ARow & ACol are 0,0; the others are still for the cell clicked before 0,0. Click @ 1,1: Arow & ACol are now 1,1, .Row & .Col are 0,0 and .SelectRow/ColCount are 3,3  

Am I doing something wrong? I have tried this with a very simple test app with everything in it's default state so I don't think it can be some odd setting I have messed up. 

How can I get the current range of a cell selection when I Shift-click at the end of the range?

Back to Top
Wilbourn David View Drop Down
Member
Member
Avatar

Joined: 18 Aug 2010
Posts: 46
Post Options Post Options   Quote Wilbourn David Quote  Post ReplyReply Direct Link To This Post Posted: 13 Aug 2019 at 10:59am
Ok, I have found a solution. (it is always better to code at 10:00 than 02:00!). I need to use the OnClickCell event, not the OnSelectCell event. That does update the Selection as expected.

However, I suppose the original question remains: why the odd values when I use OnSelectCell?
Back to Top
Collins Stephen View Drop Down
New Member
New Member
Avatar

Joined: 14 Jan 2019
Posts: 13
Post Options Post Options   Quote Collins Stephen Quote  Post ReplyReply Direct Link To This Post Posted: 14 Aug 2019 at 10:44am
Hi David,

As I understand it, OnSelectCell is called BEFORE the cell is actually selected, so Grid.Row/Col etc will still have the 'old' values. And you can in fact stop the selection of this new cell by setting CanSelect to FALSE in the OnSelectCell event.

Hope that helps?

Steve.
Back to Top
Wilbourn David View Drop Down
Member
Member
Avatar

Joined: 18 Aug 2010
Posts: 46
Post Options Post Options   Quote Wilbourn David Quote  Post ReplyReply Direct Link To This Post Posted: 17 Aug 2019 at 1:43pm
Hi Steve,
That certainly matches the results I have seen. I suppose it's really a matter of semantics, it would probably be more accurate to call it something like "OnBeforeSelectCell" but that is just getting cumbersome!

David.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down