Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a textbox in a c# user control.
I want to make some operation in a case the user edited the text in the textbox, and when the user finishes, he clicks on any other control (the textbox is loosing the focus).
What is the correct event for that?
Posted

1 solution

 
Share this answer
 
Comments
user_code 23-Oct-12 10:46am    
For some reason I don't have it in the textbox..
OriginalGriff 23-Oct-12 11:00am    
So you don't! (I love the consistency of .NET, don't you?)
You can access it by adding an event manually (it is masked in the TextBox control so it doesn't appear in the Events or Intellisense) but for some reason it fires off the Leave event which will do the same job (and you can see that one in the designer!)
Sushil Mate 23-Oct-12 13:55pm    
for user control, he needs to create a eventhandler for lostfocus. if you explained in that way then might be able to understand easily.
OriginalGriff 23-Oct-12 14:19pm    
He isn't talking about a UserControl - he is talking about a standard TextBox.
A standard UserControl already has a LostFocus Event, but a Standard TextBox doesn't - the one it inherits from Control is masked so it is not visible in the designer or in Intellisense, instead it exposes an event called "Leave" which does the same thing under a different name.
Masking Events is the same as masking Properties: http://www.codeproject.com/Tips/56028/Hiding-inherited-properties
Sushil Mate 23-Oct-12 23:55pm    
i might be wrong but if you see his questions tag there you can find textbox & usercontrols. i saw your article, its nice thanks for sharing :)

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