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

Handling a key event in GDBG

I have a GridDataBoundGrid. I want to setup a hotkey similar to Excel''s that allows a user to select the entire row of the current cell by typing (Shift + Spacebar). I have tried every key event I can find (KeyUp, KeyDown, KeyPress, CurrentCellKeyUp, etc..) In every case, I can get it to select the entire row.. BUT.. I cannot seem to prevent the keyboard event from also activating the current cell and typing a space into it. The e.Handled part seems to have no effect (I believe it may be because the space has already been typed into the active cell by the time I get the message) So how can I trap the (Shift + Spacebar) key event and prevent it from also typing into the active cell? Here is 1 way I have unsucessfully tried to do this: private void gridDataBoundGrid1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Space && e.Shift == true) { // do my stuff here to select the row... e.Handled = true; } } Thanks, Brian

1 Reply

AD Administrator Syncfusion Team October 6, 2005 10:32 PM UTC

One way to do this is to derive teh grid and override ProcessCmdKey. Here is a sample. http://www.syncfusion.com/Support/user/uploads/GDBG_Copy_7193cd4b.zip If you do not want to derive the grid, then you can handle CurrentCellControlKeyMessage. But this causes the cell velue to ''blink'' which you may not want. The above sample has this solution commented out.

Loader.
Live Chat Icon For mobile
Up arrow icon