When a user presses the 'Tab' key, I would like for the active cell to move 'down' instead of 'across'. To accomplish this, I've replaced the KeyActionMapping for my grid and replaced the 'NextCellByTab'/'PrevCellByTab' with 'BelowCell'/'AboveCell'. I did the same thing with NextRowByTab/PrevRowByTab - replacing those with 'BelowRow'/'AboveRow'.
When I press 'tab' the selected cell move down instead of over to the right; it is exactly what I want. When it reaches the bottom, it starts again at the top in the next column to the right. PERFECT!
When I press 'shift+tab' the select cell moves up, instead of over to the left; so far so good. However, when it reaches the top of ANY column, it stops. It won't go back to the previous column. So I can go through all of my cells, correctly, using the tab key - but 'Shift+tab' which performs the Above Cell action doesn't work the same way. It stops as soon as it hits the top of any column.
Can anyone tell me what I might have done wrong, or what I can do to get the shift+tab to perform exactly like the 'tab' key is - only in reverse?
Thanks!
Hi Rob,
To test this out, I put a couple of buttons on a form with a grid and in the code for the buttons, I put a call to PerformAction. One button called AboveCell and the other BelowCell.
When I call BelowCell and the active cell was in the last row of the grid, calling BelowCell simply stops working and does nothing. And it's the same with AboveCell for the top row.
So the wrapping around behavior you are seeing here must be caused by another mapping somewhere in the KeyActionMapping. There must be some other mapping to the tab key that is causing the focus to wrap back to the top of the grid. I'm not sure what that is, but you might want to loop through the KeyActionMappings and examine any mapping for the tab key to see which one might be causing it to wrap. If you find one, maybe you can duplicate the same thing to wrap at the top of the grid.
Another option would be to handle the BeforePerformAction event and trap for the AboveCell action when the first row in the grid is active. Then you could cancel the action and set focus to the cell you want at the bottom of the grid.