Solved

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

Posted on 2013-01-17
2
812 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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 …
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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

724 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