文字改变事件一直在发射? [英] text changed event keeps firing?

查看:47
本文介绍了文字改变事件一直在发射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法停止触发textchanged事件。我有一个控制部分代码的计时器,但触发事件的部分不是。为什么这样的事情会发生,如果可能的话,我怎样才能确保事件只在每个文本发生变化时触发一次而不是经常发生?



提前谢谢





此代码位于计时器控件内,但如何在不使用计时器的情况下更新文本框? textchanged事件仅在添加新添加的文本时触发,但是由定时器以500ms的间隔检查webbrowser控件添加。



  Dim  allelem  As  HtmlElementCollection = WebBrowser1.Document.All 
对于 每个 webelem 作为 HtmlElement allelem
如果 webelem.GetAttribute( id)= div 然后
Dim logtext As String = webelem.InnerText
Dim loghtml As String = webelem.InnerHtml
RichTextBox1.Text = logtext
RichTextBox2。 Text = loghtml
结束 如果
下一步

解决方案

仅回答从未答复的队列中删除 - 由OP解决


< blockquote>通过添加一些控件来捕获与计时器无关的信息来改变逻辑


I am having trouble to stop a textchanged event from firing. I have a timer that controls part of the code but the part that fires the event is not. Why would something like this happen and if possible how can I make sure the event only fires once per text changed and not constantly?.

thank you in advance


this code is within a timer control but how or what can i do to update the textbox without using a timer? the textchanged event only fires when newly added text is added of course but it is added by the timer checking the webbrowser control in intervals of 500ms.

Dim allelem As HtmlElementCollection = WebBrowser1.Document.All
       For Each webelem As HtmlElement In allelem
           If webelem.GetAttribute("id") = "div" Then
               Dim logtext As String = webelem.InnerText
               Dim loghtml As String = webelem.InnerHtml
               RichTextBox1.Text = logtext
               RichTextBox2.Text = loghtml
           End If
       Next

解决方案

Answered only to remove from unanswered queue - solved by OP


changed the logic by adding some controls to capture information not tied to the timer


这篇关于文字改变事件一直在发射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆