tbeck1983
asked on
How to send shif+enter when enter key is pressed
I have a richtextbox control on a form. If a user presses enter on the richtextbox I want to send a shift+enter instead. Problem with my code is it goes into an infinate loop.
Private Sub txtNotes_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtNotes.KeyDown
If e.KeyCode = Keys.Enter Then
e.Handled = True
SendKeys.Send("+ENTER")
End If
End Sub
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank's for the quick post. However, it still loops on the sendkeys event.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks for the reply. It still loops though.
Really? I did it on my pc, it only executed once. Sorry it's not working for you.
How about this instead?...
Just check to see if Shift is pressed down with Enter...and if not, send it:
Just check to see if Shift is pressed down with Enter...and if not, send it:
Private Sub txtNotes_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtNotes.KeyDown
If Not e.Shift AndAlso e.KeyCode = Keys.Enter Then
e.Handled = True
SendKeys.Send("+{ENTER}")
End If
End Sub
ASKER