zoukankan      html  css  js  c++  java
  • c#中使用Enter代替TAB键的方法

    // 重写以下方法
    protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)

      {

       if(msg.WParam.ToInt32() == (int) Keys.Enter)

       {
        
        SendKeys.Send("{Tab}");

        return true;

       }

       return base.ProcessCmdKey(ref msg, keyData);

      } 

    // 也可处理窗体的KeyDown事件
    // 注:须先将窗体的keypreview属性改为True
      private void Login_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
      {
       if (e.KeyCode==Keys.Enter )
       {
        this.SelectNextControl(this.ActiveControl,true,false,false,true);
       }
       else if(e.KeyCode==Keys.Left )
       {
        this.SelectNextControl(this.ActiveControl,false,true,true,false);
       }
       else if(e.KeyCode==Keys.Up )
       {
        this.SelectNextControl(this.ActiveControl,false,true,true,false);
       }
       else if (e.KeyCode==Keys.Right )
       {
        this.SelectNextControl(this.ActiveControl,true,true,true,false);
       }
       else if(e.KeyCode==Keys.Down )
       {
        this.SelectNextControl(this.ActiveControl,true,true,true,false);
       }

      }

     
  • 相关阅读:
    Sip协议中的严格路由和松路由
    读书有感(转)
    c# ini文件操作类(简单配置文件)
    android ApiDemos学习1 主界面动态ListView显示
    android 长度单位
    ArcGIS Engine 常用方法
    android simcard
    android 屏蔽home键操作
    android activity
    android ListView
  • 原文地址:https://www.cnblogs.com/tyjsjl/p/2156089.html
Copyright © 2011-2022 走看看