How to prevent going to next row after editing a DataGridViewTextBoxColumn and pressing EnterKey?

I tried this for changing the Enter behaviour for your Grid by inheriting a customcolumn from
Textbox column and overriding the below event

protected override bool ProcessDialogKey(Keys keyData)
{
    if (keyData == Keys.Enter)
       return base.ProcessDialogKey(Keys.Tab);
    else
       return base.ProcessDialogKey(keyData);
}

So instead of the Enter Key being sent it emulates the action for Tab which will move to the next cell. Hope this helps

Leave a Comment