XTab's Blog

Ged Mead's Blog at vbCity

This blog hosted by:
http://blogs.vbcity.com      
  Home :: Syndication  :: Login

JunJuly 2008Aug
SMTWTFS
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Archives

Topics

Ramblings

VB.NET

  Another of the new features that came with VB 2005 is the way you can now set ComboBoxes and TextBoxes to autocomplete based on user input.   You know the kind of thing: the user begins to type a string and the system suggests variations on the completed string.  The user then accepts the suggestion or continues typing until they find an acceptable suggestion or until they have entered the whole thing manually.

  It's remarkably easy to implement.  Here's a walkthrough of the main points:

ComboBox

  •     Populate the ComboBox with some list items in the usual way (e.g. by selecting "Items" from the Property Window and typing in a list)
  •   Set its AutoCompleteMode to SuggestAppend
  •   Set the AutoCompleteSource to "ListItems"

   Run the project and type in the first letter(s) of an item you are looking for.   You will see that a dropdown list of filtered items appears and that the best current match is selected.  This suggestion is also entered into the text area of the combobox.  

   You can traverse the dropdown list with the mouse, in which case the items will be highlighted as the mouse passes over them.  Left clicking on a highlighted item will of course select it and place it in the text area.

   You can also traverse the dropdown list using the up and down arrow keys.  This will result in the items being highlighted and also the current highlighted item will appear in the text area of the combobox.    Pressing either the Enter key or the Tab key will confirm the selection of that item and the dropdown list will disappear.

   It's really as simple as that.  Other modes are available - Append and Suggest, separately - but I find SuggestAppend the most useful for a combobox.  I particularly like that everything can be done with keys - typing in the first chars, moving up and down the suggestions with arrow keys, and selecting with the Enter key.

TextBox

   The choices are the same for autocomplete in textboxes, but it's worth highlighting one or two features that are more useful for textboxes than for comboboxes.

   First off, there isn't a "ListItems" choice because of course a text box doesn't have a list by default.    So if you want to create your list of suggestions (and you probably will want to in many cases) then you can select "CustomSource" as your AutoCompleteSource property.  

  Next, select the AutoCompleteCustomSource property and type in or paste in the list of suggestions that you want to see displayed.   Then choose an AutoCompleteMode of Append, Suggest or SuggestAppend.

   Now run the project, type in some characters and the dropdownlist of suggestions will be available as for the combobox example.   (If you choose "Append" as the mode, there won't be a dropdownlist; the closest matching suggestion so far will be entered into the textbox and may change depending on what character you next type in.)

   Worth noting for textbox autocomplete are some additional features.  (These are available for comboboxes too, but I think that in many cases textbox is a better choice for using these).   Go back to the AutoCompleteSource and try changing it to "RecentlyUsedList".  I recommend that you use either Suggest or SuggestAppend again for this experiment.    Run the project and type a character into the textbox; "h" would be a good choice while you're experimenting with this.   You'll see that you get a list of recently visited URLs. 

   Point to note is that if you type in, for example, "v" then you will get all URLs that begin with http://v.. 

   Other pre-packaged and sometimes useful lists include:

  • FileSystem (although note that you have to type in the hard drive letter, colon and backslash before anything happens).
  • HistoryList, which uses IE's history list.
  • AllSystemSources, which combines  theFileSystem list and the AllURL list.

  All in all, this is an easy feature to use and one that can make your application look much more professional and user friendly with very little effort on your part.

 

 

 

 

 

posted on Tuesday, May 08, 2007 1:01 PM

Feedback

# re: AutoComplete ComboBox and TextBox 5/10/2007 6:17 PM David Carter
Remove link from http://v..
Nice advice for newbies

# re: AutoComplete ComboBox and TextBox 5/15/2007 9:44 PM Nurseman
It is obvious

# re: AutoComplete ComboBox and TextBox 7/2/2007 7:15 PM bobas
http://dziewiec.50webs.com/superciccione.html x http://piec.50webs.com/donneallapecorinafoto.html x http://www.freewebs.com/ciachos/immaginicartolinedinatale.html x http://www.freewebs.com/kaplica/fotodellaficagratis.html x http://www.freewebs.com/kolonialny/raccontidisuocereviolentate.html x http://www.freewebs.com/szydera/travestitisexi.html x http://samiec.50webs.com/filmshardgratisdavedere.html x http://piec.50webs.com/fighegiovaniepelose.html x http://klecha.125mb.com/incintegratis.html x http://www.freewebs.com/kolonialny/videoclipnatura.html x http://www.freewebs.com/kolonialny/bdsmracconti.html x http://bulaaa.50webs.com/videogratisdonnaninfomane.html x http://bulaaa.50webs.com/transsexfemminili.html x http://www.freewebs.com/kaplica/supercazziperfighescopate.html x http://www.freewebs.com/koszerny/sitopronoinlinguaitaliana.html x http://www.freewebs.com/koszerny/wwwcercodonnedaleccare.html x http://www.freewebs.com/koszerny/gaynudisperma.html x http://blachor.50webs.com/pronvecchie.html x http://kapielowki.50webs.com/videogratistroiesuinternet.html x http://kapielowki.50webs.com/cartoonsadomasogratis.html x http://www.freewebs.com/sciana/fotobrune.html x http://www.freewebs.com/koszerny/tettegrosseesiliconate.html x http://klecha.125mb.com/perizomitgp.html x http://piec.50webs.com/matureamantidelcazzo.html x http://www.freewebs.com/kaplica/erosmangaracconti.html x http://kapielowki.50webs.com/bellebocchinare.html x http://www.freewebs.com/ciachos/fotoamatorialidiuniversitarie.html x http://blachor.50webs.com/transgiselemilano.html x http://samiec.50webs.com/tettesiliconateitaliane.html x http://www.freewebs.com/serwus/annunciintorino.html x http://dziewiec.50webs.com/eroalmareconunatrans.html x http://kapielowki.50webs.com/scambistispagnolidifrancobolli.html x http://www.freewebs.com/kolonialny/puttanementrescopano.html x http://www.freewebs.com/sciana/ragazzeinvideochiamate.html x http://klecha.125mb.com/listafilmselen.html x http://www.freewebs.com/szydera/storiedifantasmialicata.html x http://www.freewebs.com/szydera/canalisatellitefreemovieserotic.html x http://piec.50webs.com/raccontisupersexy.html x http://bulaaa.50webs.com/pornomaccine.html x http://www.freewebs.com/koszerny/photodivagine.html x http://www.freewebs.com/serwus/wwwvideodipompinaregratisit.html x http://www.freewebs.com/serwus/donnematureanteprima.html x http://www.freewebs.com/ciachos/fotodiragazziniattorinudi.html x http://klecha.125mb.com/flmepono.html x http://siorbacz.125mb.com/veronicalariopute.html x http://samiec.50webs.com/fotosorella.html x http://www.freewebs.com/koszerny/uominimaturicazzodepilato.html x http://www.freewebs.com/kolonialny/fotoexragazzenovara.html x http://www.freewebs.com/waskacipa/fotopompiniamatoriali.html x http://blachor.50webs.com/fotodifichepelosegiapponese.html x

# re: AutoComplete ComboBox and TextBox 9/22/2007 2:50 PM Michel Vanderbeke
Hello,

When I set its AutoCompleteMode to SuggestAppend and the AutoCompleteSource to "ListItems", the KeyPress for the "Enter"-key does not work anymore. How can I slove this?

Many thanks and greetings,

Michel


Post Feedback

Title:
Name:
Url:
Comments: 
Protected by Clearscreen.SharpHIPEnter the code you see: