vb.net auto-suggest function

For those of you who don’t know what auto-suggest is. I won’t define it here, just open up google and begin to type some words. And you will see what auto-suggest means.

Here’s a screenshot of the mini-application that I have made which has auto-suggest functionality. As you can see, it automatically loads up items from the database as you begin to type on the textbox.

autosuggest

Doing this is easy once you know how to read data from a database. You’ll just have to use data reader to do this.

And of course, you need to activate the auto-suggest functionality on the textbox.

Change the properties of the textbox to match the one on the screenshot below:

image

The autoCompleteSource I used is CustomSource, since I’m loading the data from a database.

If you want to load it from recent places you have gone through on your system. You might want to choose file system directory.

You can also load from the sites you have visited in your browser using the AllUrl.

But if you want to load it from either the browser history or the file system directories. You can choose AllSystemSources.

For the code, I won’t show it here. But to give you an idea. You need data reader for this. Then iterate through all of the items that are on the database while the reader still hasn’t reach the end of the database table.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s