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);
}