Delete Key DataGrid

I'd like for users to be able to select a row in a datagrid and press the delete key on the keyboard and have the row deleted. I've got the code written to detect what row they're on and update the dataSet... but I don't know how to handle it when they click the delete key?
[278 byte] By [WWG] at [2007-12-16]
# 1

Private Sub DataGrid1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DataGrid1.KeyPress

If e.KeyChar().Equals(System.Windows.Forms.Keys.Delete) Then

End If

End Sub

DMan1 at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
I'm doing this in c#. I'm using the KeyPress event but it throwing an error:

Here's my code:

if(e.KeyChar().Equals(System.Windows.Forms.Keys.Delete))
{
MessageBox.Show("Delete");
}

Error:

System.Windows.Forms.KeyPressEventArgs.KeyChar' denotes a property where a method was expected.

Any ideas?

WWG at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3

e.keychar() <-

use the key-up event and keycode method instead like:


If (e.KeyCode.Equals(System.Windows.Forms.Keys.Delete))
{
MessageBox
.Show("Delete")
}


DMan1 at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
Thanks D-Man. That code works some of the time. When I highlight a row in the datagrid, and then press the delete key, the event isn't captured. Seems like I need to override something in the grid.
WWG at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms General...