|
-
Mar 4th, 2009, 02:04 AM
#1
Thread Starter
Lively Member
Using Enter key when moving controls
Hi.
How would i do it in my code if i Want to use an "ENTER" key when transferring control?
thanks!
-
Mar 4th, 2009, 02:56 AM
#2
Addicted Member
Re: Using Enter key when moving controls
Hmm, not to sure what you mean, do you mean you push enter and the something moves? :/
-
Mar 4th, 2009, 04:56 AM
#3
Thread Starter
Lively Member
Re: Using Enter key when moving controls
Yes.
For example:
Textbox1 TextBox2 TextBox3.
After i input item on TextBox1 and I press ENTER, the control will go to TextBox2 and so on.
Thanks.
-
Mar 4th, 2009, 05:17 AM
#4
Member
Re: Using Enter key when moving controls
Try adding a KeyPress event handler to each textbox to detect when Enter is pressed and set the focus to the next box.
-
Mar 4th, 2009, 06:18 AM
#5
Re: Using Enter key when moving controls
Hi,
I think you mean that if you put some text in textbox1 the the carret goes to te next textbox2.
If so you could try something like this:
vb Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _ Handles TextBox1.KeyPress, TextBox2.KeyPress, TextBox3.KeyPress If Not TextBox1.Text = "" Then If e.KeyChar = Chr(Keys.Enter) Then TextBox2.Focus() e.Handled = True End If End If If Not TextBox2.Text = "" Then If e.KeyChar = Chr(Keys.Enter) Then TextBox3.Focus() e.Handled = True End If End If If Not TextBox3.Text = "" Then If e.KeyChar = Chr(Keys.Enter) Then MsgBox("You filled all textboxes") e.Handled = True Else TextBox3.Focus() End If End If End Sub
Wkr,
sparrow1
Last edited by sparrow1; Mar 4th, 2009 at 06:31 AM.
-
Mar 4th, 2009, 07:56 AM
#6
Re: Using Enter key when moving controls
-
Mar 4th, 2009, 07:56 AM
#7
Re: Using Enter key when moving controls
Please mark you thread resolved using the Thread Tools as shown
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|