How to catch Enter-Key and send Tab-Key

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hello!

I need a simple method to catch the Key-Down-Event, check if the Enter key is pressed and send the Tab-Key.

Public Class Form
> ...
> ...
Private Sub Form_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Windows.Forms.Keys.Enter Then
e.Handled = True
System.Windows.Forms.SendKeys.Send("{TAB}")
End If
End Sub
> ...
> ...
End Class

This Sample works for TextBoxes, but not for buttons. The Button_Clicked-Event raised always.

I also try to insert the code directly into the Button-Code - without success.

How to solve this problem?

Thank you,

Christian
.


Quantcast