hobbes2103 Posted July 11, 2003 Posted July 11, 2003 Hello! When you execute a program, you can automatically move from one button to the other with the Up and Down arrows of keypad. Now I want to move from a textbox to the other with the Up and Down arrows (which is not automatic). I have this code which can be used with the Keypress event if you know the ascii code of the key : Public Function KeyAscii(ByVal UserKeyArgument As KeyPressEventArgs) As Short KeyAscii = Asc(UserKeyArgument.KeyChar) End Function But the Up and down arrows seem to have no ascii code... Now do you have another solution to this problem?? Quote
Leaders dynamic_sysop Posted July 11, 2003 Leaders Posted July 11, 2003 you cant move from a textbox to another with the Up and Down arrows ( that will just do the same as left and right , move through the text ) but you can do this : Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyCode = Keys.Down Then TextBox2.Focus() End If End Sub Private Sub TextBox2_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyUp If e.KeyCode = Keys.Up Then TextBox1.Focus() End If End Sub hope it helps. Quote
hobbes2103 Posted July 11, 2003 Author Posted July 11, 2003 Thank you, it helps very much! Just a question about this code : how come that if i go down from textbox1 to textbox2 and if there is text in textbox2, the cursor doesn't go automatically to the end of the text (it goes in the middle of the text) Quote
Leaders dynamic_sysop Posted July 11, 2003 Leaders Posted July 11, 2003 if there is text in a textbox you can use the SelectionStart property , eg: Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp If e.KeyCode = Keys.Down Then TextBox2.Focus() TextBox2.SelectionStart = Len(TextBox2.Text) '// go to end of text. End If End Sub Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.