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.
Pages: 1
Topic closed
I am having trouble with the detection of the keyboard events. There are no problems with the code for CellMouseEventArgs, eg. CellMouseMove.
Your guidance will be appreciated please regarding the BeforeCellKeyDown, AfterCellKeyDown and the CellKeyUp events. Otherwise, the Grid control functions very well for me, thank-you.
Imports unvell.ReoGrid
Imports unvell.ReoGrid.Events
Sub Form1_Load ....
Dim WSheet = MyGrid.CurrentWorksheet
AddHandler WSheet.CellMouseMove, AddressOf Grid_CellMouseMove
AddHandler WSheet.CellKeyUp, AddressOf GSheet_CellKeyUp
End Sub
Private Sub Grid_CellMouseMove(ByVal sender As Object, ByVal e As CellMouseEventArgs)
' No problems here
Dim msXY As ReoGridPos = e.CellPosition
....
End Sub
Private Sub GSheet_CellKeyUp(ByVal sender As Object, ByVal e As CellKeyDownEventArgs)
' Does not work
MessageBox.Show("Worked?", " ", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Offline
Could you tell me why you need to get key-up events?
Since most keys pressed inside worksheet will cause cell editing event, when the cell changed to Edit Mode, the cell key-up event will not be raised. Key down events (BeforeCellKeyDown and AfterCellKeyDown) should work.
So to get key-up event it is necessary to make the cell editing operation not be caused, there are several methods to disable cell editing, one of that is by handling BeforeCellEdit event:
Dim WSheet = grid.CurrentWorksheet
AddHandler WSheet.CellMouseMove, AddressOf Grid_CellMouseMove
AddHandler WSheet.BeforeCellEdit, AddressOf GSheet_BeforeCellEdit ' <- Here
AddHandler WSheet.CellKeyUp, AddressOf GSheet_CellKeyUp
...
Private Sub GSheet_BeforeCellEdit(ByVal sender As Object, ByVal e As CellBeforeEditEventArgs)
' Disable cell edit
e.IsCancelled = True
End Sub
Offline
Thank-you Jing for your quick response. Re. key-up events, it was the way I interpreted the documentation; your words "most keys pressed inside worksheet will cause cell editing event" are the relevant ones. It now works though I found that Me.StartPosition = ... inactivated AddHandler Sheet.AfterCellKeyDown unless Me.StartPosition = was placed at the end of the Load Sub.
Offline
Pages: 1
Topic closed