views:

190

answers:

1

I want to develop YUI autocomplete like autocomplete in my program in c#.net (VS2005). It a windows application. Is it possible to show search result in gridview or table when characters are entered in textbox?

A: 

Doing exactly what you requested is very easy. Just add the TextChanged event to your text box and do a search anytime it is changed.

private void textHost_TextChanged(object sender, EventArgs e) { // Do search and update the results }

However, you have to consider that if your search to get results takes more then a trivial amount of time, the user will be annoyed when their is a lag with each character typed. For this you should use BackgroundWorker and do the search in a background thread. When a new key is pressed call the Cancel method on the thread and kick off a new one.

If you want to get even more complicated you can set up a background thread that is signalled each time a key is pressed. If no new signal is received for a half second or so, you start the background search.

Marcus Erickson