Private Sub UltraTextEditor1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles UltraTextEditor1.KeyDown
If e.KeyData = Keys.Control + Keys.F2 Then MessageBox.Show("Se ha pulsado la combinación de teclas Control+F2") SendKeys.Send("{%}") End If End Sub
Hereby he returns to me the value "%" when I pulsate contrl F2 after accepting the MessageBox.
----------------------------------------------------------------
If e.KeyData = Keys.Control + Keys.F2 Then SendKeys.Send("{%}") End If End Sub
Hereby he does not return to me the value "%".
----------------------------------------------
Since it can return the value to me without the MessageBox?
Thank you
Private Sub UltraTextEditor1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles UltraTextEditor1.KeyDownIf e.KeyData = Keys.Control + Keys.F2 Then
e.Handled = True
Me.UltraTextEditor1.SelectedText = "%"End IfEnd Sub
If that works. Thank you very much for the solution. Thank you
ok ok ok :)
Private Sub UltraTextEditor1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles UltraTextEditor1.KeyDown If e.KeyData = Keys.Control + Keys.F2 Then
Me.UltraTextEditor1.SelectedText = "%" End If End Sub
I sit it but with this solution it does not work either.
Hi,
I tried this out and I get the same results.
I also get the same results if I do the same thing with the TextBox control.
I think this is probably because the control is in the middle of processing a key when you are calling SendKeys. The MessageBox introduces a delay which causes the control to finish processing the current keystroke before it processes the SendKeys call.
Instead of using SendKeys, you could just modify the Text.
Private Sub UltraTextEditor1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles UltraTextEditor1.KeyDown If e.KeyData = Keys.Control + Keys.F2 Then e.Handled = True Me.UltraTextEditor1.SelectedText = "%" End If End Sub