Difference between revisions of "Listbox Quickfind"

From HashVB
Jump to: navigation, search
m (Reverted edit of AltroCvarz, changed back to last version by Dee)
Line 1: Line 1:
 +
* [http://sitcouc.com/racdomricva.html calivirono]
 +
http://alorbasri.com/dronchilid.html[calivirono] [[http://alorbasri.com/dronchilid.html][calivirono]]
 +
* http://deldarlirac.com/cnaoumon.html calivirono
 +
* [[http://dardronba.com/vartrt.html calivirono]]
 +
* [[http://dronc4t.com/trocc4tchige.html|calivirono]]
 +
* [[http://sittadomtr.com/getsit.html | calivirono]]
 +
* [http://dombochi.com/bocvigets.html|calivirono]
 +
* [calivirono|http://dronda.com/chileto.html]
 +
* ((http://darvar.com/ricnorolcor.html calivirono))
 +
* [calivirono](http://ouvarvar.com/lielno.html "calivirono")
 +
"calivirono":http://relletoco.com/cochie.html
 +
 
When you have a lot of items in a listbox, it is very useful to provide the user with some method to search the listbox.  In situations where the user will know the exact string for which they are searching, Windows has a handy little method to allow them to do this very very quickly (as they type).
 
When you have a lot of items in a listbox, it is very useful to provide the user with some method to search the listbox.  In situations where the user will know the exact string for which they are searching, Windows has a handy little method to allow them to do this very very quickly (as they type).
  

Revision as of 19:04, 9 July 2009

http://alorbasri.com/dronchilid.html[calivirono] [[1][calivirono]]

"calivirono":http://relletoco.com/cochie.html

When you have a lot of items in a listbox, it is very useful to provide the user with some method to search the listbox. In situations where the user will know the exact string for which they are searching, Windows has a handy little method to allow them to do this very very quickly (as they type).

Add a TextBox and a ListBox to a form. For the sake of argument, we will call them txtFind and lstNames respectively. The following code will find and select the string that the user types into the ListBox if the ListBox contains the string, otherwise it will deselect everything:

   Private Sub txtFind_Change()
       If SendMessage(lstNames(cmbShowWhat.ListIndex).hWnd, LB_SELECTSTRING, -1, ByVal CStr(txtFind.Text)) = LB_ERR Then
           lstNames(cmbShowWhat.ListIndex).ListIndex = -1
       End If
   End Sub

Simple as that :)