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
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
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.SuppessKeyPress = True
End If
End Sub
Another option would be to create a custom grid view control
Override the DataGridView (write your own that inherits from it), and process the OnKeyDown method.
public partial class UserControl1 : DataGridView
{
public UserControl1()
{
InitializeComponent();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
return;
base.OnKeyDown(e);
}
}