KyeDown N KeyPress Event in VB.NET
-----------------------------------
Private Sub TextBox1_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown, TextBox2.KeyDown
If e.KeyCode = Keys.Tab Then
If sender.Name = "TextBox1" Then
TextBox2.Focus()
e.Handled = True
ElseIf sender.Name = "TextBox2" Then
TextBox1.Focus()
e.Handled = True
End If
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress, TextBox2.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
If sender.name = "TextBox1" Then
TextBox2.Focus()
e.Handled = True
ElseIf sender.name = "TextBox2" Then
TextBox1.Focus()
e.Handled = True
End If
End If
End Sub
No comments:
Post a Comment