参考这个,自己改改。5.30 How can I prevent the Enter key from moving to the next cell when the user is actively editing the cell and presses Enter?
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q791q
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q791q
具体代码如下:
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;
}