Click here to Skip to main content
13,046,176 members (59,342 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 23-Oct-12 4:32am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 23 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100