You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Hello Jing,
I just seen something interesting..
When i use this code it does the movement of the Tab key and enter key, but if press tab and shift-Enter it moves from right to left and not up. Also, When you tab back to the Column "A", it does not go to the preview row, but does go to the next row.
One thing i did notice why it might be doing is, it might not be looking at the shift keypress and when does shift+enter, it is using the same SelectionForwardDirection that was last set.
if have test with out the tab keypress if press enter it sets but tab key and enter key events to same SelectionForwardDirections.
AddHandler rgMainControl.BeforeCellKeyDown, Sub(s, e)
If e.KeyCode = Keys.Enter Then
rgMainControl.SelectionForwardDirection = SelectionForwardDirection.Down
nonNumberEntered = True
Exit Sub
End If
If e.KeyCode = Keys.Tab Then
rgMainControl.SelectionForwardDirection = SelectionForwardDirection.Right
nonNumberEntered = True
Exit Sub
End If
End Sub
Shane
Last edited by asparatu (2015-01-07 02:35:50)
Offline
You proposed very interesting usage, focus-selection moved horizontally by pressing Enter, and moved vertically by pressing Tab; Nice idea!
Just I found your code does not go back to left cell if Shift+Tab pressed, might need this:
VB.NET:
Dim sheet = grid.CurrentWorksheet
AddHandler sheet.BeforeCellKeyDown, Sub(s, e)
If (e.KeyCode And Keys.Enter) = Keys.Enter Then
sheet.SelectionForwardDirection = SelectionForwardDirection.Down
nonNumberEntered = True
ElseIf (e.KeyCode And Keys.Tab) = Keys.Tab Then
sheet.SelectionForwardDirection = SelectionForwardDirection.Right
nonNumberEntered = True
End If
End Sub
I'd like to add this into documentation as example code on website.
Excel doesn't go back to previous row when Shift+Enter pressed. I think that is because that Excel has an expandable column count, it might spread to 16384 columns (max-column), go back to previous row need put the focus at 16384 column, it's not user-friendly.
The problem is which column should be the target column when focus-selection moved to previous row, I haven't found a rule about it.
Last edited by Jingwood (2015-01-07 03:00:55)
Offline
Hello Jing,
Ok.. I didnt think about it would go back to previous row at the very end.. i can see that would not be very user-friendly also.. And that code work fine.. it worked the way i wanted to work now..
I was going to change to this, but i like the way you did it better..
If (e.Modifiers = Keys.Shift AndAlso e.KeyCode = Keys.Enter) or (e.Keycode = Keys.Enter) Then
sheet.SelectionForwardDirection = SelectionForwardDirection.Down
nonNumberEntered = True
end if
that should work also, but yours is cleaner.. then my code
Shane
Last edited by asparatu (2015-01-07 03:19:15)
Offline