回车键当Tab键使用

 #region 回车键当Tab键使用
        private void enter_KeyPress(object sender, KeyPressEventArgs e)
        {
            foreach (Control c in this.Controls)
            {
                c.KeyPress += new System.Windows.Forms.KeyPressEventHandler(sendEnter);
            }
        }
        private void sendEnter(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                //使按键生效
                e.Handled = true;
                //发送按键指令
                SendKeys.Send("{Tab}");
            }
        }
        #endregion

使用 KeyChar 属性在运行时对击键取样,在特定运行时环境下修改击键。 例如,您可以使用 KeyChar 在用户输入邮政编码时禁用非数字按键,将数据输入字段中所有的字母按键都改为大写,或监视键盘或其他按键输入设备的特定组合键。

您可以获取或设置以下键:

  • a-z,A-Z。

  • Ctrl。

  • 标点符号。

  • 键盘顶部和数字键盘上的数字键。

  • Enter。

您不能获取或设置以下键:

    • Tab 键。

    • Insert 和 Delete。

    • Home。

    • End。

    • Page Up 和 Page Down。

    • F1-F2。

    • Alt。

    • 箭头键。

原文地址:https://www.cnblogs.com/swtool/p/3840175.html