• <i id='JuXZY'><tr id='JuXZY'><dt id='JuXZY'><q id='JuXZY'><span id='JuXZY'><b id='JuXZY'><form id='JuXZY'><ins id='JuXZY'></ins><ul id='JuXZY'></ul><sub id='JuXZY'></sub></form><legend id='JuXZY'></legend><bdo id='JuXZY'><pre id='JuXZY'><center id='JuXZY'></center></pre></bdo></b><th id='JuXZY'></th></span></q></dt></tr></i><div id='JuXZY'><tfoot id='JuXZY'></tfoot><dl id='JuXZY'><fieldset id='JuXZY'></fieldset></dl></div>
    <tfoot id='JuXZY'></tfoot>
  • <legend id='JuXZY'><style id='JuXZY'><dir id='JuXZY'><q id='JuXZY'></q></dir></style></legend>
      <bdo id='JuXZY'></bdo><ul id='JuXZY'></ul>
    1. <small id='JuXZY'></small><noframes id='JuXZY'>

        .NET TextBox - 处理 Enter 键

        .NET TextBox - Handling the Enter Key(.NET TextBox - 处理 Enter 键)
      1. <i id='v3mSA'><tr id='v3mSA'><dt id='v3mSA'><q id='v3mSA'><span id='v3mSA'><b id='v3mSA'><form id='v3mSA'><ins id='v3mSA'></ins><ul id='v3mSA'></ul><sub id='v3mSA'></sub></form><legend id='v3mSA'></legend><bdo id='v3mSA'><pre id='v3mSA'><center id='v3mSA'></center></pre></bdo></b><th id='v3mSA'></th></span></q></dt></tr></i><div id='v3mSA'><tfoot id='v3mSA'></tfoot><dl id='v3mSA'><fieldset id='v3mSA'></fieldset></dl></div>
          <tbody id='v3mSA'></tbody>

        <small id='v3mSA'></small><noframes id='v3mSA'>

        <legend id='v3mSA'><style id='v3mSA'><dir id='v3mSA'><q id='v3mSA'></q></dir></style></legend>

          <tfoot id='v3mSA'></tfoot>

              <bdo id='v3mSA'></bdo><ul id='v3mSA'></ul>
                  本文介绍了.NET TextBox - 处理 Enter 键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 .NET TextBox 中,根据用户输入的 Enter 键 (Keys.Enter),假设拥有导致 TextBox 本身的 Enter 键被抑制的键输入(e.Handled = true)?

                  What is definitively the best way of performing an action based on the user's input of the Enter key (Keys.Enter) in a .NET TextBox, assuming ownership of the key input that leads to suppression of the Enter key to the TextBox itself (e.Handled = true)?

                  出于此问题的目的,假设所需的行为不是按下表单的默认按钮,而是应该发生的其他一些自定义处理.

                  Assume for the purposes of this question that the desired behavior is not to depress the default button of the form, but rather some other custom processing that should occur.

                  推荐答案

                  添加按键事件并捕获回车键

                  Add a keypress event and trap the enter key

                  以编程方式看起来有点像这样:

                  Programmatically it looks kinda like this:

                  //add the handler to the textbox
                  this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEnterKeyPress);
                  

                  然后在代码中添加处理程序...

                  Then Add a handler in code...

                  private void CheckEnterKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
                  {
                          if (e.KeyChar == (char)Keys.Return)
                  
                          {
                             // Then Do your Thang
                          }
                  }
                  

                  这篇关于.NET TextBox - 处理 Enter 键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to keep the Text of a Read only TextBox after PostBack()?(PostBack()之后如何保留只读文本框的文本?)
                  Winforms Textbox - Using Ctrl-Backspace to Delete Whole Word(Winforms 文本框 - 使用 Ctrl-Backspace 删除整个单词)
                  C# - Add button click events using code(C# - 使用代码添加按钮单击事件)
                  Multi-color TextBox C#(多色文本框 C#)
                  How can i set the caret position to a specific index in passwordbox in WPF(如何将插入符号位置设置为 WPF 密码框中的特定索引)
                  C# Numeric Only TextBox Control(C# 纯数字文本框控件)
                  <legend id='NmrTB'><style id='NmrTB'><dir id='NmrTB'><q id='NmrTB'></q></dir></style></legend>

                    <tbody id='NmrTB'></tbody>
                    <bdo id='NmrTB'></bdo><ul id='NmrTB'></ul>

                          <small id='NmrTB'></small><noframes id='NmrTB'>

                          • <i id='NmrTB'><tr id='NmrTB'><dt id='NmrTB'><q id='NmrTB'><span id='NmrTB'><b id='NmrTB'><form id='NmrTB'><ins id='NmrTB'></ins><ul id='NmrTB'></ul><sub id='NmrTB'></sub></form><legend id='NmrTB'></legend><bdo id='NmrTB'><pre id='NmrTB'><center id='NmrTB'></center></pre></bdo></b><th id='NmrTB'></th></span></q></dt></tr></i><div id='NmrTB'><tfoot id='NmrTB'></tfoot><dl id='NmrTB'><fieldset id='NmrTB'></fieldset></dl></div>
                          • <tfoot id='NmrTB'></tfoot>