Programatically triggering tab key functionality in a VB.Net windows application

14,327

Solution 1

You can simulate the SendKeys.Send(string) method (in the Systems.Windows.Forms namespace). To simulate a tab keypress you would call SendKeys.Send("{TAB}").

To see all the key codes, check out http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx

Solution 2

Better late, than never, since i found this post looking for a solution to a similar problem.

Windows Form type has ContainerControl somewhere in its chain of inheritance and that has a method ProcessTabKey(Boolean trueForForward) . It does exactly what you need, inside your form instance this.ProcessTabKey(true) will move focus forward along the tab index and this.ProcessTabKey(false) will move it backward.

Solution 3

Very simple code

Write Down this in KeyDown Event of Datagridview

   If e.KeyCode = Keys.Enter Then
        ' Your code here
        SendKeys.Send("{TAB}")
        e.Handled = True
   End If
Share:
14,327
Ramesh
Author by

Ramesh

Updated on June 04, 2022

Comments

  • Ramesh
    Ramesh almost 2 years

    How can I programatically trigger the tab key functionality in a VB.Net windows application?

    Currently in my application I am using one splitter when I press the tab key, and the focus is moving in the right order.

    However I need to use arrow keys to move the focus to next controls, in the same way that the focus is going when the user presses the tab keys.

    Thanks in Advance