Live Chat Icon For mobile
Live Chat Icon

How can I prevent the Enter key from moving to the next cell when the user is actively editing the cell and presses Enter

Platform: WinForms| Category: Datagrid

Override the method ProcessKeyPreview in your DataGrid.


protected override bool ProcessKeyPreview(ref System.Windows.Forms.Message m)
{
	Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
	if((m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP)
		&& keyCode == Keys.Enter )
		return false;
	return true;
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.