Solved

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

Posted on 2013-01-17
2
781 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WPF - Tooltips for ComboBox items 5 37
Visual Studio 2013 Shortcut (VB) 4 34
.Net Web Site IIS Web.Config Content-Security-Policy 1 44
Code works but it's slow 24 44
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

17 Experts available now in Live!

Get 1:1 Help Now