-
Jan 26th, 2014, 04:44 PM
#1
Thread Starter
PowerPoster
[RESOLVED] [VB2010] - how avoid the beep, changing the control focus with return key?
i have these code for change the control focus:
Code:
Private Sub txtMatricula_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles txtMatricula.KeyUp
If e.KeyCode = Keys.Return Then
Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
e.Handled = False
End If
End Sub
but i always ear 1 beep
can i avoid it?
-
Jan 26th, 2014, 04:50 PM
#2
Re: [VB2010] - how avoid the beep, changing the control focus with return key?
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Jan 26th, 2014, 04:55 PM
#3
Thread Starter
PowerPoster
Re: [VB2010] - how avoid the beep, changing the control focus with return key?
Originally Posted by kebo
sorry seems:
e.SuppressKeyPress = True
isn't resolved, i use it with keyup event.. the beep continues
-
Jan 26th, 2014, 04:59 PM
#4
Hyperactive Member
Re: [VB2010] - how avoid the beep, changing the control focus with return key?
Have you tried exactly like so? Below:
Code:
Private Sub TxtBox_Keydown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles TxtBox.Keydown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
'Do more mad stuff
End If
End Sub
Last edited by Mucker; Jan 26th, 2014 at 05:12 PM.
-
Jan 26th, 2014, 05:08 PM
#5
Re: [VB2010] - how avoid the beep, changing the control focus with return key?
Originally Posted by joaquim
sorry seems:
e.SuppressKeyPress = True
isn't resolved, i use it with keyup event.. the beep continues
That's because the beep occurs on the key down, not the keyup.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Jan 26th, 2014, 05:15 PM
#6
Thread Starter
PowerPoster
Re: [VB2010] - how avoid the beep, changing the control focus with return key?
after more tests i found the problems and solutions:
1 - these code works fine with keydown event:
Code:
If e.KeyCode = Keys.Return And e.Alt = False Then
e.SuppressKeyPress = True 'make sure the key is pressed only 1 time and avoid the beep
Me.SelectNextControl(Me.ActiveControl, True, True, True, True) 'these line moves the focus to the next control, by tab order
End If
2 - by some reason don't use the keyup event;
3 - if what only some controls for the return key do the job, just use on all controls you need. if you need use for all controls, use the keydown event from the form;
4 - if you use the form, never forget activate the KeyPreview property.
5 - imagine that you need a newline on text boxes, you can test with alt key.
Code:
Private Sub txtReparacoesNecessarias_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles txtReparacoesNecessarias.KeyDown
If e.KeyCode = Keys.Return And e.Alt = True Then
e.SuppressKeyPress = True
txtReparacoesNecessarias.SelectedText = txtReparacoesNecessarias.SelectedText + vbNewLine
End If
End Sub
i hope these information helps others readers
Last edited by joaquim; Jan 26th, 2014 at 05:28 PM.
-
Jan 26th, 2014, 05:16 PM
#7
Hyperactive Member
Re: [VB2010] - how avoid the beep, changing the control focus with return key?
Originally Posted by kebo
That's because the beep occurs on the key down, not the keyup.
Well it's only 2 words of code to fix it. Handler and sub name renaming. Your reply made my desk hit me in the face. (I thought it was on both for a second, but then realized why would i only disable it on one handle?) :P Think they call that desk palm.
Last edited by Mucker; Jan 26th, 2014 at 05:20 PM.
-
Jan 26th, 2014, 05:29 PM
#8
Thread Starter
PowerPoster
Re: [RESOLVED] [VB2010] - how avoid the beep, changing the control focus with return
what you 2 think about that information that i tested with your, both, help?
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
|