首先设置窗体的 KeyPreview 属性为true
1private void Form1_KeyUp(object sender, KeyEventArgs e)
2 {
3 if (this.ActiveControl.GetType().Name != "XpButton")
4 if (e.KeyCode == Keys.Enter)
5 SendKeys.Send("{TAB}");
6 }
2 {
3 if (this.ActiveControl.GetType().Name != "XpButton")
4 if (e.KeyCode == Keys.Enter)
5 SendKeys.Send("{TAB}");
6 }