Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# User-controls
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 23-Oct-12 5:32am

1 solution

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

Solution 1

  Permalink  
Comments
user_code at 23-Oct-12 10:46am
   
For some reason I don't have it in the textbox..
OriginalGriff at 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 at 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 at 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 at 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
0 Sergey Alexandrovich Kryukov 535
1 OriginalGriff 275
2 BillWoodruff 260
3 Shweta N Mishra 244
4 Deepu S Nair 230
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,818
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,755


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 23 Oct 2012
Copyright © CodeProject, 1999-2014
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