By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 1,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Use "Enter" to "Tab"

P: n/a
Hi,
I have just built a small application with a form that has one Text Box and
one Check Box and a couple of Command Buttons.

What I am trying to achieve is that if the Text Box has focus and the User
hits the "Enter" button the focus will move to the next Tab item (i.e. the
Check Box). Likewise on the Check Box but obviously if a Command Button has
the focus, it will initiate the Click event

I have set the Forms CancelButton to the button that closes the form and I
have its AcceptButton set to none.

Do I have to trap every keystroke and test for "Enter"? Or is there a
property that I am missing?

Thanks

Doug
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Ken,
Thanks
That does cause the "Enter" Key to tab but when it is pressed there is an
audible Ding! from the PC similar to an Error Warning Ding!

Doug

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Hi,
Set the forms keypreview property to true.

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

End Sub

Ken

-----------------
"Doug Bell" <dug@bigpond> wrote in message
news:eY***************@TK2MSFTNGP11.phx.gbl...
Hi,
I have just built a small application with a form that has one Text Box and one Check Box and a couple of Command Buttons.

What I am trying to achieve is that if the Text Box has focus and the User
hits the "Enter" button the focus will move to the next Tab item (i.e. the
Check Box). Likewise on the Check Box but obviously if a Command Button has the focus, it will initiate the Click event

I have set the Forms CancelButton to the button that closes the form and I
have its AcceptButton set to none.

Do I have to trap every keystroke and test for "Enter"? Or is there a
property that I am missing?

Thanks

Doug

Nov 21 '05 #2

P: n/a
Hi,
Set the forms keypreview property to true.

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

End Sub

Ken

-----------------
"Doug Bell" <dug@bigpond> wrote in message
news:eY***************@TK2MSFTNGP11.phx.gbl...
Hi,
I have just built a small application with a form that has one Text Box and
one Check Box and a couple of Command Buttons.

What I am trying to achieve is that if the Text Box has focus and the User
hits the "Enter" button the focus will move to the next Tab item (i.e. the
Check Box). Likewise on the Check Box but obviously if a Command Button has
the focus, it will initiate the Click event

I have set the Forms CancelButton to the button that closes the form and I
have its AcceptButton set to none.

Do I have to trap every keystroke and test for "Enter"? Or is there a
property that I am missing?

Thanks

Doug

Nov 21 '05 #3

P: n/a
Hi Ken,
Thanks
That does cause the "Enter" Key to tab but when it is pressed there is an
audible Ding! from the PC similar to an Error Warning Ding!

Doug

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Hi,
Set the forms keypreview property to true.

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

End Sub

Ken

-----------------
"Doug Bell" <dug@bigpond> wrote in message
news:eY***************@TK2MSFTNGP11.phx.gbl...
Hi,
I have just built a small application with a form that has one Text Box and one Check Box and a couple of Command Buttons.

What I am trying to achieve is that if the Text Box has focus and the User
hits the "Enter" button the focus will move to the next Tab item (i.e. the
Check Box). Likewise on the Check Box but obviously if a Command Button has the focus, it will initiate the Click event

I have set the Forms CancelButton to the button that closes the form and I
have its AcceptButton set to none.

Do I have to trap every keystroke and test for "Enter"? Or is there a
property that I am missing?

Thanks

Doug

Nov 21 '05 #4

P: n/a
Doug,

I thought this is once provided by Armin Zingler,
\\\
Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress
If e.KeyChar = vbCr Then
e.Handled = True
End If
End Sub
///

I hope thie helps?
Cor

"Doug Bell" <dug@bigpond> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Ken,
Thanks
That does cause the "Enter" Key to tab but when it is pressed there is an
audible Ding! from the PC similar to an Error Warning Ding!

Doug

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Hi,
Set the forms keypreview property to true.

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

End Sub

Ken

-----------------
"Doug Bell" <dug@bigpond> wrote in message
news:eY***************@TK2MSFTNGP11.phx.gbl...
Hi,
I have just built a small application with a form that has one Text Box

and
one Check Box and a couple of Command Buttons.

What I am trying to achieve is that if the Text Box has focus and the
User
hits the "Enter" button the focus will move to the next Tab item (i.e.
the
Check Box). Likewise on the Check Box but obviously if a Command Button

has
the focus, it will initiate the Click event

I have set the Forms CancelButton to the button that closes the form and
I
have its AcceptButton set to none.

Do I have to trap every keystroke and test for "Enter"? Or is there a
property that I am missing?

Thanks

Doug


Nov 21 '05 #5

P: n/a
Thanks Cor,

I added "
Me.SelectNextControl(Me.ActiveControl, True, True, True, True)"

and it is working well.

If e.KeyChar = vbCr Then

e.Handled = True

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

Doug
"Cor Ligthert" <no************@planet.nl> wrote in message
news:u1**************@TK2MSFTNGP10.phx.gbl...
Doug,

I thought this is once provided by Armin Zingler,
\\\
Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress
If e.KeyChar = vbCr Then
e.Handled = True
End If
End Sub
///

I hope thie helps?
Cor

"Doug Bell" <dug@bigpond> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Ken,
Thanks
That does cause the "Enter" Key to tab but when it is pressed there is an audible Ding! from the PC similar to an Error Warning Ding!

Doug

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Hi,
Set the forms keypreview property to true.

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

End Sub

Ken

-----------------
"Doug Bell" <dug@bigpond> wrote in message
news:eY***************@TK2MSFTNGP11.phx.gbl...
Hi,
I have just built a small application with a form that has one Text Box

and
one Check Box and a couple of Command Buttons.

What I am trying to achieve is that if the Text Box has focus and the
User
hits the "Enter" button the focus will move to the next Tab item (i.e.
the
Check Box). Likewise on the Check Box but obviously if a Command Button

has
the focus, it will initiate the Click event

I have set the Forms CancelButton to the button that closes the form and I
have its AcceptButton set to none.

Do I have to trap every keystroke and test for "Enter"? Or is there a
property that I am missing?

Thanks

Doug



Nov 21 '05 #6

P: n/a
Doug,

I thought this is once provided by Armin Zingler,
\\\
Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress
If e.KeyChar = vbCr Then
e.Handled = True
End If
End Sub
///

I hope thie helps?
Cor

"Doug Bell" <dug@bigpond> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Ken,
Thanks
That does cause the "Enter" Key to tab but when it is pressed there is an
audible Ding! from the PC similar to an Error Warning Ding!

Doug

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Hi,
Set the forms keypreview property to true.

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

End Sub

Ken

-----------------
"Doug Bell" <dug@bigpond> wrote in message
news:eY***************@TK2MSFTNGP11.phx.gbl...
Hi,
I have just built a small application with a form that has one Text Box

and
one Check Box and a couple of Command Buttons.

What I am trying to achieve is that if the Text Box has focus and the
User
hits the "Enter" button the focus will move to the next Tab item (i.e.
the
Check Box). Likewise on the Check Box but obviously if a Command Button

has
the focus, it will initiate the Click event

I have set the Forms CancelButton to the button that closes the form and
I
have its AcceptButton set to none.

Do I have to trap every keystroke and test for "Enter"? Or is there a
property that I am missing?

Thanks

Doug


Nov 21 '05 #7

P: n/a
Thanks Cor,

I added "
Me.SelectNextControl(Me.ActiveControl, True, True, True, True)"

and it is working well.

If e.KeyChar = vbCr Then

e.Handled = True

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

Doug
"Cor Ligthert" <no************@planet.nl> wrote in message
news:u1**************@TK2MSFTNGP10.phx.gbl...
Doug,

I thought this is once provided by Armin Zingler,
\\\
Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress
If e.KeyChar = vbCr Then
e.Handled = True
End If
End Sub
///

I hope thie helps?
Cor

"Doug Bell" <dug@bigpond> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Ken,
Thanks
That does cause the "Enter" Key to tab but when it is pressed there is an audible Ding! from the PC similar to an Error Warning Ding!

Doug

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Hi,
Set the forms keypreview property to true.

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If e.KeyCode = Keys.Enter Then

Me.SelectNextControl(Me.ActiveControl, True, True, True, True)

End If

End Sub

Ken

-----------------
"Doug Bell" <dug@bigpond> wrote in message
news:eY***************@TK2MSFTNGP11.phx.gbl...
Hi,
I have just built a small application with a form that has one Text Box

and
one Check Box and a couple of Command Buttons.

What I am trying to achieve is that if the Text Box has focus and the
User
hits the "Enter" button the focus will move to the next Tab item (i.e.
the
Check Box). Likewise on the Check Box but obviously if a Command Button

has
the focus, it will initiate the Click event

I have set the Forms CancelButton to the button that closes the form and I
have its AcceptButton set to none.

Do I have to trap every keystroke and test for "Enter"? Or is there a
property that I am missing?

Thanks

Doug



Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.