DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   enter key (http://www.daniweb.com/forums/thread60968.html)

vb_learner Nov 8th, 2006 5:40 pm
enter key
 
Hello :)

Iam using windows application, I want to know how can I move from textbox1 to textbox2 through the tab control key or enter key..

iamthwee Nov 9th, 2006 2:39 pm
Re: enter key
 
or you could just use the mouse and position the cursor in which ever text box you want?

waynespangler Nov 9th, 2006 4:15 pm
Re: enter key
 
Try this:
    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

vb_learner Nov 10th, 2006 2:41 pm
Re: enter key
 
1)the tab works by default right?

2)I added the enter code but still when i start my program the focus is always at the 2nd text box, so what can i do?
3) can i move between textboxes using the ASCII code 13? how?
thanks : )

tgreer Nov 10th, 2006 2:43 pm
Re: enter key
 
You don't want to do this. The "enter" key is universally used to submit a form, or perform a default action. Altering it is a major violation of the User Model.

vb_learner Nov 10th, 2006 2:54 pm
Re: enter key
 
sorry but i didn't understand ;/ ,,
what i meant is using enter key to move from one text box to another..
and how I can do it..

I'm very new to programming. . :)

iamthwee Nov 10th, 2006 2:56 pm
Re: enter key
 
Quote:

Originally Posted by vb_learner (Post 274532)
sorry but i didn't understand ;/ ,,
what i meant is using enter key to move from one text box to another..
and how I can do it..

I'm very new to programming. . :)

In the GUI tab there should be an option in the text box to enable or disable the tab key. If it is disabled you should be able to use it to go through different buttons and text fields.

But using enter to do the same would be frowned upon.

iamthwee Nov 10th, 2006 3:01 pm
Re: enter key
 
1 Attachment(s)
see attachment

vb_learner Nov 14th, 2006 8:40 am
Re: enter key
 
now that i have 3 text boxes .. when i type numbers then press enter the numbers will be cleared??
and that doesn't happen with 2nd and 3rd number?

iamthwee Nov 14th, 2006 3:05 pm
Re: enter key
 
Huh?

When you press the enter button on the keyboard you mean.

Do you have any code?


All times are GMT -4. The time now is 6:19 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC