|
-
Apr 14th, 2007, 06:58 AM
#1
Thread Starter
Lively Member
Delete key keypress
Hi,
I've noticed that when I press the delete key my current row is deleted in my datagrid.
What is the event for this and how can I carry another operation under this event when the delete key is pressed. 
I could do the operation under this event right
Code:
private void DataGridView_KeyPress(object sender, KeyPressEventArgs e)
{
How do I check whether the Delete key was pressed
Last edited by sunshine123; Apr 14th, 2007 at 07:56 AM.
-
Apr 14th, 2007, 08:18 AM
#2
Re: Delete key keypress
There are three events that relate to keystrokes: KeyDown, KeyPress and KeyUp. KeyDown and KeyUp relate to individual keys on the keyboard and are raised for all keys. KeyPress relates to characters that are sent to the control. For instance, if you press Shift+C you will get two KeyDown and two KeyUp events because you pressed two keys, but only one KeyPress event because only one character is sent to the control. The Delete key does not send a character to the control so it doesn't raise a KeyPress event. You can handle the KeyDown event and test the e.KeyCode property.
Having said that, if your DataGrid is bound to a DataTable I'd be more inclined to handle its RowDeleting or RowDeleted event.
-
Apr 15th, 2007, 12:01 AM
#3
Thread Starter
Lively Member
Re: Delete key keypress
Ok thanks I willl check that out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|