Winfrom 中怎样在回车时设置焦点

  1. 请先设置窗体的keyPreView属性为True,确认控件的键盘事件向窗体注册;
  2. 在窗体的KeyPress事件中编写如下代码:
    1 private void Form1_KeyPress(object sender, KeyPressEventArgs e) 
    2 {
    3 if (e.KeyChar == (char)13)
    4 {
    5 ...
    6 }
    7 }
posted @ 2012-03-01 11:17  一篮饭特稀  阅读(226)  评论(0编辑  收藏  举报