none
how to autocomplete city textbox on selected state RRS feed

  • General discussion

  • Private Sub AutoCompleteState()
            con = New OleDbConnection(connString)
            con.Open()
            query = "SELECT * FROM [State]"
            Dim cmd As New OleDbCommand(query, con)
            Dim ds As New DataSet
            Dim da As New OleDbDataAdapter(cmd)
            da.Fill(ds, "State")                  'list can of be any name u want


            Dim col As New AutoCompleteStringCollection
            Dim i As Integer
            For i = 0 To ds.Tables(0).Rows.Count - 1
                col.Add(ds.Tables(0).Rows(i)("State_Name").ToString())
            Next
            txtRcv_State.AutoCompleteSource = AutoCompleteSource.CustomSource
            txtRcv_State.AutoCompleteCustomSource = col
            txtRcv_State.AutoCompleteMode = AutoCompleteMode.SuggestAppend


            con.Close()
        End Sub

    ****************************************************************************


        Private Sub AutoCompleteCity()
            con = New OleDbConnection(connString)
            con.Open()
            query = "SELECT * FROM [City]"
            Dim cmd As New OleDbCommand(query, con)
            Dim ds As New DataSet
            Dim da As New OleDbDataAdapter(cmd)
            da.Fill(ds, "City")                  'list can of be any name u want


            Dim col As New AutoCompleteStringCollection
            Dim i As Integer
            For i = 0 To ds.Tables(0).Rows.Count - 1
                col.Add(ds.Tables(0).Rows(i)("City_Name").ToString())


            Next
            txtRcv_City.AutoCompleteSource = AutoCompleteSource.CustomSource
            txtRcv_City.AutoCompleteCustomSource = col
            txtRcv_City.AutoCompleteMode = AutoCompleteMode.SuggestAppend


            con.Close()
        End Sub

    Wednesday, March 14, 2018 7:30 AM

All replies

  • Hello,

    What is the purpose for this post?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, March 14, 2018 9:10 AM
    Moderator