简体   繁体   中英

textbox with textchanged event firing

I have two textboxes with textchanged events. When I enter characters in first textbox and press enter, the textbox1_textchanged event is fired. Then I enter some characters in the second textbox and press enter, the textbox2_textchanged event fires as well. However, when I move my cursor in first text box without changing any characters and pressed enter, the events won't fire for both textboxes.

I want the respective textbox events to fire without changing any characters in textboxes. If I press enter with some characters in textbox1/textbox2 its txt_changed events have to fire.

I have tried, but if I enter characters in textbox2 first the textbox1_textchanged get fired. Any help?

Since you haven't tagged with a webforms/mvc tag I'm going to go ahead and assume this is a WinForms question, in which case look at:

http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox%28v=VS.100%29.aspx

See the "Events" section for a list of all the events a textbox supports.

My guess is you'll want to focus on Enter and Leave events, as well as your text_changed events that you already have.

I'm also assuming (I'm assuming a lot since you've specified little) that you have the latest version of .NET at hand and not something from the dark ages, so I've pointed you at the .NET 4.0 reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM