protected override bool ProcessDialogKey(System.Windows.Forms.Keys aKey)        {
            if (aKey == Keys.Enter)
            {
                tbpassword.Focus();                return true;
            }
            else { return false; }
        
        }
如上所示,用ProcessDialogKey方法可以实现了keypress功能。但是在        private void tb_Password_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar =='\r')
                bt_Login.Focus();
        }
这里的keypress也是没有用了,等于就是说ProcessDialogKey屏蔽了所有的keypress功能了怎么样才能在一个form中 即实现combobox的Enter也能实现别的比如textbox的keypress功能呢??

解决方案 »

  1.   

    protected   override   bool   ProcessDialogKey(System.Windows.Forms.Keys   aKey) 

    if(aKey ==Keys.Enter&&this.ActiveControl==this.comboBox1) 

    this.comboBox1.DroppedDown   =   true; 
    base.ProcessDialogKey(aKey); 
    return   true; 

    base.ProcessDialogKey(aKey); 
    return   false; }
      

  2.   

    -------------------------------------------------------你用这样的操作后,问题又出现了。同一个form中的另外的Button又不能使用Enter键了,只能使用空格,还有tab键也失效!!
      

  3.   


    ---------------------------------你用这样的操作后,问题又出现了。同一个form中的另外的Button又不能使用Enter键了,只能使用空格,还有tab键也失效!!