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
460
How to add KeyPress Event in UltraTextEditor
posted

I tried the following code.

    Private Sub AddNewDefinition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddDefinition.Click

      AddHandler NewGradeDefinition.GradeRepresentation.KeyPress, AddressOf DontAcceptSpaces

     End Sub

    Private Sub DontAcceptSpaces(ByVal sender As Object, ByVal e As KeyPressEventArgs)
        If e.KeyChar = " "c Then
            e.Handled = False
        End If
    End Sub

 

When I typed into the textbox(a ultratextEditor type) it doest call the DontAcceptSpaces subroutine.

It was running fine on .NET's textbox but not in ultratexteditor, how can I add this event in my control programmatically on runtime?

  • 69832
    Suggested Answer
    Offline posted

    Assuming that 'NewGradeDefinition.GradeRepresentation' references the UltraTextEditor, the event handler registration looks correct. I don't know if the e.KeyChar = " "c condition will evaluate to true for the space key; you might have to use CHR(34). Also, you have to set Handled to true, not false, to "eat" the key.