Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable the default Enter/Return key behavior in a datagridview

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

like image 744
Ramji Avatar asked Dec 11 '09 10:12

Ramji


1 Answers

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

Private Sub DataGridView1_Keydown (...) Handles 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

like image 50
Adriaan Stander Avatar answered Sep 19 '22 01:09

Adriaan Stander