G
Guest
Hi
How can I send a char to Textbox so that KeyPress event is called? I have a button and with a click I would like to send a char, e.g. "C", to the Textbox. But Textbox1_KeyPress is not catching the event (I can step thru KeyPress ok but nothing goes to TextBox). KeyPress itself works fine with key stroke via keyboard
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Clic
Dim e2 As New System.Windows.Forms.KeyPressEventArgs(CType("C", Char)
TextBox1_KeyPress(TextBox1, e2
End Su
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPres
If Not Char.IsLetter(e.KeyChar) And Not Char.IsControl(e.KeyChar) The
e.Handled = True ' ignor
End I
End Su
TIA.
How can I send a char to Textbox so that KeyPress event is called? I have a button and with a click I would like to send a char, e.g. "C", to the Textbox. But Textbox1_KeyPress is not catching the event (I can step thru KeyPress ok but nothing goes to TextBox). KeyPress itself works fine with key stroke via keyboard
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Clic
Dim e2 As New System.Windows.Forms.KeyPressEventArgs(CType("C", Char)
TextBox1_KeyPress(TextBox1, e2
End Su
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPres
If Not Char.IsLetter(e.KeyChar) And Not Char.IsControl(e.KeyChar) The
e.Handled = True ' ignor
End I
End Su
TIA.