就是按小键盘的enter,相当于按tab

解决方案 »

  1.   

    <script language="javascript" event="onkeydown" for="document">
            if(event.keyCode==13)
                event.keyCode=9;
    </script>
      

  2.   

    KeyDown事件中          
                if (e.KeyCode == System.Windows.Forms.Keys.Enter)
                {
                    //发送TAB键
                    System.Windows.Forms.SendKeys.Send("{TAB}");
                }
      

  3.   

    参考如下代码:
    public class KeyFilter : IMessageFilter
    {
        #region IMessageFilter Members
        const int WM_KEYDOWN = 0x0100;
        const int VK_RETURN = 13;
        private Form parent;
        public KeyFilter(Form parent)
        {
            this.parent = parent;
        }    public bool PreFilterMessage(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_KEYDOWN:
                    if (VK_RETURN != ((int)m.WParam & 0xff)) return false;
                    if (!(parent.ActiveControl is TextBox)) return false;
                    if (((int)m.LParam & 0x1000000) != 0)
                    {
                        //MessageBox.Show("小键盘回车");
                        SendKeys.Send("{TAB}");
                        return true; // 过滤
                    }
                    else
                    {
                        //MessageBox.Show("大键盘回车");
                    }
                    break;
            }
            return false;
        }
        #endregion
    }private void Form1_Load(object sender, EventArgs e)
    {
        Application.AddMessageFilter(new KeyFilter(this));
    }private void textBox1_KeyDown(object sender, KeyEventArgs e)
      

  4.   

                  private void textBox1_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Return)
                {
                    System.Windows.Forms.SendKeys.Send("{Tab}");
                }
            }============================================================================
     private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (Conv)
                {
                    e.KeyChar = Convert.ToChar(9);
                } 
            }        bool Conv = false;
            private void textBox1_KeyDown(object sender, KeyEventArgs e)
            {
                Conv  = false;
                if (e.KeyCode == Keys.Return)
                {
                    Conv = true;
                }
            }
      

  5.   

    我有一个?:TAB  什么时候下是 水平制表符,什么时候下是“切换键” 
      

  6.   


    打错误了,不好意思,应更正应为同3楼的代码:e.KeyCode == System.Windows.Forms.Keys.Enter
      

  7.   

    小键盘的回车是Keys.Enter吗 那大键盘的回车是什么啊
      

  8.   

     if (((int)m.LParam & 0x1000000) != 0)
                    {
                        //MessageBox.Show("小键盘回车");
                        SendKeys.Send("{TAB}");
                        return true; // 过滤
                    }
    这个条件为真 说明什么啊。
      

  9.   

    说明是小键盘 囧了解详细情况要查msdn
    WM_KEYDOWN Message
    The WM_KEYDOWN message is posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed.ParameterswParam
    Specifies the virtual-key code of the nonsystem key.lParam
    Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table.消息参数lParam包括扩展键的标志,0x1000000字位上就表示是否为小键盘。
      

  10.   

    这个我查了,在哪能查到LParam每个值分别对应什么啊。小键盘enter的LParam>0x1000000还是就是啊
      

  11.   

    本帖最后由 zswang 于 2010-04-09 13:11:38 编辑
      

  12.   

    多谢 技术牛人都很nice啊,在哪能查到哪位对应标记什么啊
      

  13.   

    if (VK_RETURN != ((int)m.WParam & 0xff)) return false;
    ((int)m.WParam & 0xff)),是把高位都置零是把
    假如不先((int)m.WParam & 0xff)),直接跟VK_RETURN 比较,那样什么情况下会出错