Solved

URGENT!  VB.NET -- Can't dynamically refresh TextBox AutoCompleteSource

Posted on 2013-01-17
2
774 Views
Last Modified: 2013-01-18
Hello everyone,

I am dynamically filling a TextBox's AutoCompleteSource from an Oracle Database.

I want to use a Button click event to initiate action.

I can't seem to get a new list each time the button is clicked.

Here is the code snippet:

        Dim List1 As New List(Of String)
        Dim strSQL As String = "SELECT DISTINCT Value1 from Table1 ORDER BY Value1"
        Try
            Using cnn As New OracleConnection("USER ID=User1;DATA SOURCE=Data1;PASSWORD=PASS1;PERSIST SECURITY INFO=true;")
                Using cmd As New OracleCommand(strSQL, cnn)
                    cnn.Open()
                    Using dr As OracleDataReader = cmd.ExecuteReader
                        While dr.Read()
                            List1.Add(dr("Value1").ToString())
                        End While
                    End Using

                    cnn.Close()
                End Using
            End Using
        Catch ex As Exception

        End Try
        Dim Array1() As String = List1.ToArray
        TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest
        TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
        TextBox1.AutoCompleteCustomSource.AddRange(Array1)

Thanks everyone!
0
Comment
Question by:eq2006
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
Comment Utility
You may want to add

 TextBox1.AutoCompleteCustomSource.Clear()

at the start.
0
 

Author Closing Comment

by:eq2006
Comment Utility
Thanks, works great!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now