Results 1 to 4 of 4

Thread: [RESOLVED] Texttbox Autocomplete Source From Listbox

  1. #1

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Resolved [RESOLVED] Texttbox Autocomplete Source From Listbox

    Is it possible to have a texttbox autocomplete source set to a listbox's collection?

    I see:

    FileSystem
    HistoryList
    RecentlyUsedList
    AllUrl
    AllSystemSources
    FileSystemDirectories
    CustomSource

    in the texxtbox's autocompletesource property but are unable to make it happin.

    regards
    toe

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Texttbox Autocomplete Source From Listbox

    You would select CustomSource, then add the items in the ListBox to the AutoCompleteCustomSource, e.g.
    vb.net Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.     Me.SetCompleteList(Me.TextBox1, Me.ListBox1.Items)
    3. End Sub
    4.  
    5. Private Sub SetCompleteList(ByVal tb As TextBox, ByVal list As IList)
    6.     Dim source As New AutoCompleteStringCollection
    7.  
    8.     For Each item As Object In list
    9.         source.Add(item.ToString())
    10.     Next item
    11.  
    12.     tb.AutoCompleteCustomSource = source
    13. End Sub
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: Texttbox Autocomplete Source From Listbox

    perfect
    Thankyou

  4. #4
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Re: [RESOLVED] Texttbox Autocomplete Source From Listbox

    Hi there

    sorry to dig this up!

    But this problem is exactly what I'm seeking the solution to, however I'm not sure which controls to name as which, in order to get this solution to work.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width