i want to not let the user press the delete key on a data grid. in the datagrid keypress event, i have tried everything...
VB Code:
Private Sub DataGrid1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DataGrid1.KeyPress If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Delete) Then MsgBox("delete") End If If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then MsgBox("enter") End If End Sub Private Sub DataGrid1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGrid1.KeyDown Select Case e.KeyCode Case Keys.Delete MessageBox.Show("You pressed delete") End Select End Sub
the enter is the only thing that works. I am wondering, is there an event with the delete key, and second, how can you not let a user delete a row from a datagrid, but keep a datagrid editable.
thanks,
jeff




Reply With Quote