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

Function key event handling

How do you detect function keys (F1 -> F12) cells in GRIDDATABOUNDGRID (GDBG)? I was only able to capture F1, F2 in keydown events within cell. It appears that each function key will trigger different events. Is that the default behaviour of GDBG in handling function keys? Awaiting your reply, Lance

1 Reply

AD Administrator Syncfusion Team May 28, 2004 08:41 AM UTC

While the grid cell is not actively being edited, then the grid itself gets these keystrokes. In this case, event handlers like grid.CurrentCellKeyDown and grid.KeyDown can be used to catch the keys. But when the current cell is actively being edited, the grid does not automcatically catch these keys. In this case, you can use the grid.CurrentCellControlKeyMessage to catch the function keys. Now this event may be fired more than once (for KeyDown, KeyPress & KeyUp) as it handles all teh key messages in the active cell. So, normally, you would condition do something for only one of these hits. One other thing is that this message does not appear in the designer event list in C#. So, you do have to manually subscribe to it. (Did not check to see if it was in teh VB event dropdown, but probably you would have to use AddHandler there as well to subscribe to it). //subscribe to the event this.gridDataBoundGrid1.CurrentCellControlKeyMessage += new GridCurrentCellControlKeyMessageEventHandler(grid_CurrentCellControlKeyMessage); //the handler private void grid_CurrentCellControlKeyMessage(object sender, GridCurrentCellControlKeyMessageEventArgs e) { Keys keyCode = (Keys)((int)e.Msg.WParam) & Keys.KeyCode; Console.WriteLine(keyCode); Console.WriteLine(e.Msg); }

Live Chat Icon For mobile
Up arrow icon