Click here to Skip to main content
15,895,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I will try to explain. Is this possible? :

Visual studio (vb.net)

1. Create a textbox and fill data from mysql database.
2. While I write in same textbox show coincidences with any part of the text

Can anybody help me please?

What I have tried:

Part 1:

Create a textbox and in form load :

Sub Autocompletar()


    Dim Cmd As MySqlCommand
    Dim Reader As MySqlDataReader = Nothing
    Dim AutoComp As New AutoCompleteStringCollection
    Try

        Cmd = New MySqlCommand
        Cmd.Connection = Conexion
        Cmd.CommandText = "SELECT * from articulos where cantidad>0"


        Reader = Cmd.ExecuteReader()
        If Reader.HasRows Then
            While (Reader.Read())
                AutoComp.Add(Reader.GetString("nombre"))
            End While


        End If


    Catch ex As Exception
        MsgBox(ex.Message)

    End Try

    With TextBox1

        .AutoCompleteMode = AutoCompleteMode.Suggest
        .AutoCompleteSource = AutoCompleteSource.CustomSource
        .AutoCompleteCustomSource = AutoComp
        .Clear()
        .Focus()

    End With

    Reader.Close()

End Sub
Posted
Comments
[no name] 6-Jul-18 11:28am    
Do you mean you're trying to highlight what you're typing where it can be found in the data returned from the database?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900