<tfoot id='T3eSw'></tfoot>

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

      1. <small id='T3eSw'></small><noframes id='T3eSw'>

        在 VB.Net 中使用 Enter 键的 Tab 键功能

        时间:2023-06-09

        <legend id='1jtR8'><style id='1jtR8'><dir id='1jtR8'><q id='1jtR8'></q></dir></style></legend>

            <small id='1jtR8'></small><noframes id='1jtR8'>

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

                  <tbody id='1jtR8'></tbody>
                • <bdo id='1jtR8'></bdo><ul id='1jtR8'></ul>
                  本文介绍了在 VB.Net 中使用 Enter 键的 Tab 键功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个包含近 20 个文本框和 5 个组合框的表单,一个控件依赖于另一个,现在我想以这样的方式编写表单的代码,按 Enter 键和 Tab 键应该具有相同的功能.

                  I have a form with nearly 20 Textbox and 5 Combobox and one control in dependent on the other, Now I want to write the code for the form in such a way that, Pressing Enter Key and Tab Key should have the same functionality.

                  就像按下 Tab 键一样,当我按下 Enter 键时,焦点移动到下一个控件也应该执行.同样,当我按下 Enter 键时,在按键事件中写入了一些流程代码,但是当我按下 Tab 键时也应该执行此操作.

                  Like on pressing Tab Key the focus moves to next control should also be performed when I press the Enter Key. Similarly when I press the Enter Key, there is some process code written in key press event but this should also be performed when I press the Tab Key.

                  推荐答案

                  我在 Winforms 中完成它的方法是使用 SelectNextControl 方法.

                  The way that I have accomplished it in Winforms is by using the SelectNextControl Method.

                  Private Sub TextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
                      Dim tb As TextBox
                      tb = CType(sender, TextBox)
                  
                      If Char.IsControl(e.KeyChar) Then
                          If e.KeyChar.Equals(Chr(Keys.Return)) Then
                              Me.SelectNextControl(tb, True, True, False, True)
                              e.Handled = True
                          End If
                      End If
                  End Sub
                  

                  如果您使用的是 WPF,则可以使用 TraversalRequest

                  If you are using WPF you can use TraversalRequest

                  Private Sub TextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Input.KeyEventArgs)
                      Dim tb As TextBox
                      tb = CType(sender, TextBox)
                  
                      If e.Key = Key.Return Then
                          tb.MoveFocus(New TraversalRequest(FocusNavigationDirection.Next))
                      ElseIf e.Key = Key.Tab Then
                          Exit Sub
                      End If
                  End Sub
                  

                  至于拦截 Tab 键看看这个 Stackoverflow 问题.

                  As far as intercepting the Tab Key take a look at this Stackoverflow question.

                  这篇关于在 VB.Net 中使用 Enter 键的 Tab 键功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:ASP.NET TextBox LostFocus 事件 下一篇:Windows 窗体文本框不能粘贴汉字吗

                  相关文章

                  1. <legend id='8K5Dh'><style id='8K5Dh'><dir id='8K5Dh'><q id='8K5Dh'></q></dir></style></legend>

                    • <bdo id='8K5Dh'></bdo><ul id='8K5Dh'></ul>

                    1. <small id='8K5Dh'></small><noframes id='8K5Dh'>

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