Solved

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

Posted on 2013-01-17
2
789 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
ID: 38789612
You may want to add

 TextBox1.AutoCompleteCustomSource.Clear()

at the start.
0
 

Author Closing Comment

by:eq2006
ID: 38795371
Thanks, works great!
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…

856 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