五维思考

学习要加,骄傲要减,机会要乘,懒惰要除。 http://www.5dthink.cn

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
private void frmLogin_KeyPress(object sender, KeyPressEventArgs e)
{
   //按回车键查找下一个可设置焦点的组件。 
   if (e.KeyChar == (Char)Keys.Enter)
   {
      this.SelectNextControl(this.ActiveControl, true, true, true, true);
      e.Handled = true;
   }
}


第二种方法:可特殊控制

Control current = this.GetNextControl(this.ActiveControl, true);
while (true)
{
   if (current.CanFocus && current.CanSelect)
   {
      current.Focus();
      break;
   }
   current = this.GetNextControl(current, true);
}


posted on 2015-03-07 10:21  五维思考  阅读(743)  评论(0编辑  收藏  举报

QQ群:1. 全栈码农【346906288】2. VBA/VSTO【2660245】