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?
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.