winform程序,窗体实现enter键转tab键,当焦点到combox后,再按enter键就不起作用了,此时按tab键还是可以的,请教各位大侠这是怎么回事?该怎么解决?补充:当combox的dropDownStyle属性设为DropDownList时enter键能起作用,但我的要求允许客户在combox中输入,所以不能这样解决

解决方案 »

  1.   

    PreviewKeyDown事件中
    if (e.KeyCode == Keys.Enter)
    {
        //todo
    }
      

  2.   

    那就在click事件中如果是回车键并且是这个下拉控件focus时直接让下一个控件focus
      

  3.   

    加了代码
      private void comboBox_Block_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
            }
    enter倒是起作用了,可是不是完全按照我设置的tab顺序来了,自动选择该控件下方的且tab顺序在它后面的控件去了,不知道哪里出了问题
      

  4.   


    还是跟上面一样的问题,跟按tab键的顺序不完全一致
      

  5.   

    问题找到了,原来当焦点在该combobox上时,按一次enter键,却响应两次PreviewKeyDown事件,这是怎么回事啊?