【问题标题】:How to open new form when Enter as Tab?Enter as Tab时如何打开新表单?
【发布时间】:2015-06-20 09:06:38
【问题描述】:

当我按下Enter 按钮时,它充当Tab,此代码位于form1_keydown 事件中

 Control nextControl; 
 if (e.KeyCode == Keys.Enter)
 {
 nextControl = GetNextControl(ActiveControl, !e.Shift);
 nextControl.Focus();
 e.SuppressKeyPress = true;
 }

在一个表单中有comboBox,我们按下Enter按钮然后打开New Form
怎么办,因为它在cmb_KeyPressevent 上不起作用

【问题讨论】:

    标签: c# winforms keypress keydown


    【解决方案1】:

    这里你可以写成:

     Control nextControl; 
     if (e.KeyCode == Keys.Enter)
     {
    nextControl = GetNextControl(ActiveControl, !e.Shift);
    nextControl.Focus();
    if(nextControl=Combo)
    {
    KeyPreview=false;   
    }
    e.SuppressKeyPress = true;
    }
    

    【讨论】:

      猜你喜欢
      • 2015-07-06
      • 1970-01-01
      • 1970-01-01
      • 2014-04-07
      • 1970-01-01
      • 2015-07-04
      • 2014-03-14
      • 2010-12-20
      • 1970-01-01
      相关资源
      最近更新 更多