Click here to Skip to main content
15,914,416 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
Am just wondering if its possible to have a sub that handles the event of a textbox Textbox.Leave, Textbox.Keypress, and Textbox.KeyDown

Thank you
Posted

1 solution

Yes its possible. Try this way but iam not sure of you will get the required information.

C#
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_Leave);
          this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_Leave);
          this.textBox1.Leave += new System.EventHandler(this.textBox1_Leave);
 
Share this answer
 
Comments
iMaker.ph 12-Jul-13 7:54am    
What I mean is this
Private Sub txtEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.Leave,txtName.Keypress,txtName.Keydown
//
End Sub
Dave Kreskowiak 12-Jul-13 10:58am    
Why don't you try that and find out??

THe biggest problem with doing this is that you lose all of the event args being passed in by each event. So, if you don't need that information, it's find to do this.

If you DO need the information, then you'll have to use seperate event handles for each type of EventArgs you're getting from each event. For example, you can combine all the events that pass in a KeyEventArgs.
ArunRajendra 12-Jul-13 9:25am    
Ok I am not sure of VB.net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900