Search code examples
c#formstextboxbuffertextchanged

How to Speed up C# Form full text search from TextBox


I need to achieve similar to TextChanged functionality of TextBox field in C# Windows Forms application. In my case TextChanged Event collects data based on TextBox.Text and displays them in tree. As collecting and displaying too much data in my case is time consuming, I'm experiencing slow responses caused by unwanted redraws in GUI. This is of course by design of TextChanged event as it buffers later key-presses and run TextChanged for each letter. I need to achieve that all buffered TextChanged events are skipped resulting only last is executed. In fact as I type i need to change this

l, lo, lon, long, longn, longna, longnam, longname

to this:

l, longname

Solution

  • Use a System.Windows.Forms.Timer to periodically check for changes to your TextBox.