.net – disable the default Enter/Return key behavior in a datagridview

.netdatagridviewvb.netwinforms

In vb.net datagridview the default Enter/Return key behavior is to move to the next row is there a quick and easy way to avoid that.

Any suggestions are welcome

Best Solution

You can try something like this in the gridview key down event

Private Sub DataGridView1_Keydown (...) Handlers DataGridView1.KeyDown
   If e.KeyCode = Keys.Enter Then
       ' Your code here
       e.SuppressKeyPress = True
  End If 
End Sub

Another option would be to create a custom grid view control

DataGridView.ProcessDataGridViewKey Method