开发者

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

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.

Howeve开发者_Go百科r 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


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


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜