We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

keydown event

where do i get detailed infomtion about these event.It is critical for my vanilla Data entry . unlike other grids (other vendors) this grid returns even the arrow keys.As am processing the keys myself i donot want it to move to next row on its own.Waht do i do .set e.handled=true in the keydown event?. can i handle also like that.what about keys of the numeric keypad.

3 Replies

AD Administrator Syncfusion Team September 29, 2004 09:28 AM UTC

There are several KeyDown type events since there may be different controls involve is a cell is actively being edited. (The GridControl may have input focus, or the active cell control like a TextBox might have focus). So, catching keystrokes may depend upon exactly what control has focus. If you want to catch them no matter what control has the input focus, you might use the CurrentCellKeyDown event. Here is a handler that ignores any arrow key.
Private Sub gridControl1_CurrentCellKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles gridControl1.CurrentCellKeyDown
      If e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down Or e.KeyCode = Keys.Left Or e.KeyCode = Keys.Right Then
            e.Handled = True ''ignore
       End If
End Sub


MN Mahesh Naik September 29, 2004 10:55 AM UTC

thank you. I have done just that I am as of now wary of any additional controls to make my life miserable. I have got my Good for something progra going . I handle the keystrokes myself. Now the next step is to snare the Rat. In the keydown event is there a translation table or something like that so that i know which symbolic key corresponds to what. Using absolute numerical values is a pain. What about numeric keypad keys. Mine is a Data entry program for a surevy and the data entry operators (Ladies!) prefer not to even look at the beautiful forms on the screen. They use only the numeric pad.Even the arrow keys they want from there only. The long keyboard is used only for alpha. The other 2 grids were handling the arrow keys without giving me a keydown. Your method is NEAT. Do you raise a keydown for all keysstrokes ?. I have got the doc files installed. Tell me the references to browse and i will be much more obliged. I have got the grid readonly while tablestle. I have it "static" via tablestyle and also by using the column styles. I dont know what is required so i put a double property. Mahesh Naik Mumbai,India, 19:25 (IST)


AD Administrator Syncfusion Team September 29, 2004 11:29 AM UTC

The simplest way for you to see how CurrentCellKeyDown works with respect to the arrow keys and the numeric keypad is to just add a handler and output the key to the Output page. Then run the sample in debug and watch the output page as you press the keys. If you are using Static CellType for all cells, then CurrentCellKeyDown should catch most keys. If you are using menu accelerator keys or something of that nature, then you may have to derive the grid and override ProcessCommandKeys to catch such keys.
Private Sub gridControl1_CurrentCellKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles gridControl1.CurrentCellKeyDown
            Console.WriteLine(e.KeyCode.ToString())
End Sub

Loader.
Live Chat Icon For mobile
Up arrow icon