Murugan.com
Murugan Andezuthu Dharmaratnam

  |  HOME   |  BLOG   |  TWITTER   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  



VB .NET Delay The TextChanged Event of a TextBox using Timer Control

Home   VB.NET   VB .NET Delay The TextChanged Event of a TextBox using Timer Control          



I have seen several articles creating another control to delay the textchanged
property . Ideally subclassing. 

I think the simplest and easiest solution is using a timer control 
and a Booleanflag 

Here's the Sample code. 

I have dragged and dropped a timer control Timer1

double click on it to get the Timer.Tick event
you could set the delay in milliseconds. in the 
interval property. 

I have created a boolean variable bTimerflag. and 
when a user types some thing I need do do some 
useful things only after 1 seconds. 

    Public bTimerFlag As Boolean = False
    Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
        If bTimerFlag = False Then
            bTimerFlag = True
            Timer1.Start()
        End If
    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        bTimerFlag = False
        Timer1.Stop()

'Your Code goes below this line
        tvPost.Nodes.Clear()
        tvPost.Nodes.Add("<>")
        Dim strFilter As String = txtSearch.Text
        PopulateTree(strFilter)
        tvPost.ExpandAll()
' End Your Code
    End Sub





I think the code is self explanatory and if in case 
have difficulty understanding the code send me a mail with the 
problem u are facing or call me Will be
able to help u solve the problem. 





  |  HOME   |  BLOG   |  TWITTER   |  ARTICLES   |  8086  |  C++   |  VC++   |  ASP .NET   |  VB .NET   |  JAVA SCRIPT   |  MS SQL   |  MY   |  VIDEOS   |  DOWNLOADS   |  CONTACT ME   |  

Copyright 2009 @ Murugan Andezuthu Dharmaratnam