• <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 键

        时间:2023-06-10
      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 键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C# WinForms - 智能文本框控件根据文本框宽度自动格式化路径长度 下一篇:如何在 C# Windows 窗体应用程序中激活拼写检查?

                  相关文章

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

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

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

                    1. <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>
                    2. <tfoot id='NmrTB'></tfoot>