Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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.

VB
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
Posted
Updated 1-Aug-13 19:50pm
v3
Comments
[no name] 1-Aug-13 18:54pm    
The TextChanged event is going to fire every time the text changes. Without seeing your code it would not be possible to say why your event is firing all of the time.
Draco2013 1-Aug-13 19:23pm    
thank you i think that i have found the issue. its happening due to a different control
Sergey Alexandrovich Kryukov 1-Aug-13 19:43pm    
It could not be due to a different control. Please see my comment below. Next time, please provide a working code sample.
—SA
Sergey Alexandrovich Kryukov 1-Aug-13 19:43pm    
Apparently, not enough information. I recommend avoid using timer. If the event is invoked infinitely, it means that the text is changed in response to the call of the event handler, directly or indirectly.
—SA
Draco2013 2-Aug-13 1:46am    
thank you i have updated my question with some code that works but maybe you can give a different view or opinion about how to go about this.

Answered only to remove from unanswered queue - solved by OP
 
Share this answer
 
Comments
Draco2013 2-Aug-13 2:06am    
this is not solved I need to update my richtextbox in some other way
OriginalGriff 2-Aug-13 2:26am    
My apologies - I was going from your comment:
"thank you i think that i have found the issue. its happening due to a different control"
Draco2013 2-Aug-13 2:59am    
thats ok please help I cannot figure this out any control that has anything to do with this code in the timer just keeps firing what are some other options then using a timer?
Draco2013 2-Aug-13 2:06am    
the code is correct but i need someone to give me an idea how to update the textbox from the webcontrol in some other way?
Draco2013 2-Aug-13 3:07am    
the main problem to this is the logic. the code is dependant on the variables I have declared is it possible to declare them globally so that the richtextbox is only updated when the webelement has changed?.. or can i stop it once it has found a match?
changed the logic by adding some controls to capture information not tied to the timer
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900