回车跳转控件焦点
通过重写 ProcessCmdKey 方法
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
int WM_KEYDOWN = 256;
int WM_SYSKEYDOWN = 260;
if (msg.Msg == WM_KEYDOWN | msg.Msg == WM_SYSKEYDOWN)
{
switch (keyData)
{
case Keys.Enter:
base.ProcessDialogKey(Keys.Tab);
break;
default:
return base.ProcessCmdKey(ref msg, keyData);
}
}
return false;
}
}
{
public Form1()
{
InitializeComponent();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
int WM_KEYDOWN = 256;
int WM_SYSKEYDOWN = 260;
if (msg.Msg == WM_KEYDOWN | msg.Msg == WM_SYSKEYDOWN)
{
switch (keyData)
{
case Keys.Enter:
base.ProcessDialogKey(Keys.Tab);
break;
default:
return base.ProcessCmdKey(ref msg, keyData);
}
}
return false;
}
}