带有 textchanged 事件触发的文本框
我有两个带有文本更改事件的文本框。当我在第一个文本框中输入字符并按 Enter 键时,将触发 textbox1_textchanged 事件。然后我在第二个文本框中输入一些字符并按 Enter 键,textbox2_textchanged 事件也会触发。但是,当我在第一个文本框中移动光标而不更改任何字符并按 Enter 键时,两个文本框都不会触发事件。
我希望在不更改文本框中任何字符的情况下触发相应的文本框事件。 如果我按 Enter 键并在 textbox1/textbox2 中输入某些字符,则必须触发 txt_changed 事件。
我已经尝试过了,但是如果我首先在 textbox2 中输入字符,则 textbox1_textchanged 会被触发。 有什么帮助吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您尚未使用 webforms/mvc 标签进行标记,因此我将继续假设这是一个 WinForms 问题,在这种情况下请查看:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox%28v=VS.100%29.aspx
请参阅“事件”部分文本框支持的所有事件的列表。
我的猜测是您需要关注 Enter 和 Leave 事件,以及已有的 text_changed 事件。
我还假设(我假设了很多,因为你指定的很少)你手头有最新版本的 .NET,而不是黑暗时代的东西,所以我向你指出了 .NET 4.0 参考。
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.