Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
560
alegar010
posted

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.

----------------------------------------------------------------

Private Sub UltraTextEditor1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs)
      Handles UltraTextEditor1.KeyDown

        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

  • 560
    Verified Answer
    posted

    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

    If that works. Thank you very much for the solution. Thank you

    ok ok ok :)

     

     

  • 560
    posted

     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

    I sit it but with this solution it does not work either.

     

  • 469350
    Offline posted

    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