Find as you type in C #

I am trying to emulate the Find When You Type function, like the address bar function (awesome bar) in FireFox. I want the tooltip to appear below the text box, and the suggestion box contains lines containing what is in the text box. I looked at the autofill function of a regular WinForms text box, but it seems to only be looking for the beginning of lines.

Has anyone built here or have experience implementing something like this?

edit: Some clarification. This is a WinForms project. It should look inside the string, not just at the beginning (which is a normal text field, if I remember correctly). And the suggestions should appear in a pop-up window, such as autocomplete text field.

+4
source share
6 answers

You need to handle the TextChanged event for the text input field, and when changing the text, start a new thread that will apply the new search. If the text changes before you return the results, just start the stream. If the stream returns results in time, show them.

You may get a little more advanced (for example, wait a short time after changing the text so that the user can enter a word without turning off loading useless streams), but essentially it.

+6
source

Previously, there was a discussion on this topic, where the author came to the conclusion that it is best for you to do this.

How can I dynamically change auto-populated entries in a C # drop-down list or text box?

+2
source

I did something vaguely similar, but more like the iTunes® search box than the Awesomebar. My control used a text box to actively filter the grid; so it wasn’t for autocomplete.

... but ... basically I had a DataView of all the matching elements, whenever the TextBox text changed, I updated the filter to hide all the inappropriate elements. It worked well and can satisfy your data filtering needs, but not sure how to use it as an autocomplete source for a text field.

+1
source

I did such a thing for the application not so much time ago.

What I did was make my search function in a new thread, so every time I typed a new letter, it was called a search function in another thread, so I could continue to type.

I can send the code if you need, but that should be enough for you to get started. :)

0
source

Hemmed and hawed about deleting this after I noticed that the OP is editing the mentioned winforms, but I think it will be useful for everyone who comes here to look for the same thing, but for asp.net applications.


Just because no one has mentioned it yet, for a webforms application you absolutely want to do it with ajax (.net controls or pure JS, your choice). This feature is often called “autocomplete,” and one thing you don’t want it to break is by rounding the page-level server.

I suggest you look at this and this .

0
source

I used Search as I type in C # and How do I create a text box Send feedback on KeyUp?

Basically, you use the keyup action to call the postback attached to the trigger in the update panel. then you do your update in the textbox_changed event using dataview or whatever your backend looks like.

0
source

All Articles