anybody can help me?
i want to add code after autocompletemode selected, code for autocomplete mode is running good, this is my code for autocompletemode:

        Dim AutoComp As New AutoCompleteStringCollection()

        Dim acs As String = "select NDP from DAFTARPELAJAR"
        acscmd.CommandText = acs
        Dim acsda As New OleDbDataAdapter(acscmd)
        acsda.Fill(acds)
        For i As Integer = 0 To acds.Tables(0).Rows.Count - 1
            AutoComp.Add(acds.Tables(0).Rows(i)(0).ToString())
        Next
        txtNDP.AutoCompleteMode = AutoCompleteMode.Suggest
        txtNDP.AutoCompleteSource = AutoCompleteSource.CustomSource
        txtNDP.AutoCompleteCustomSource = AutoComp

now i want to bind my database into textbox after the user already click the autocompletemode suggestion, because the query for data bind is refer from the autocompletemode textbox = txtNDP.text, Example:

if autocompletemode.click then
text.bind
endif

Recommended Answers

All 4 Replies

are you using a button or a checkbox to select the autocomplete option in your form?

no, i put it in textbox code, like this :

    Private Sub txtNDP_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNDP.TextChanged
        Dim AutoComp As New AutoCompleteStringCollection()

        Dim acs As String = "select NDP from DAFTARPELAJAR"
        acscmd.CommandText = acs
        Dim acsda As New OleDbDataAdapter(acscmd)
        acsda.Fill(acds)
        For i As Integer = 0 To acds.Tables(0).Rows.Count - 1
            AutoComp.Add(acds.Tables(0).Rows(i)(0).ToString())
        Next
        txtNDP.AutoCompleteMode = AutoCompleteMode.Suggest
        txtNDP.AutoCompleteSource = AutoCompleteSource.CustomSource
        txtNDP.AutoCompleteCustomSource = AutoComp

    End Sub

Fine. then try this.

Place a checkbox in your form to get whether the user needs autocomplete.

then

use the following code to check whether the user needs autocomplete.

If CheckBox1.CheckState = 1 Then

    //if user needs autocomplete
    //Your code for autocomplete here...

else

    //leave it blank

End If

Hope this helps you...

Have a happy coding...:-D

nice, but your code is to make user can choose wether he want to autocomplete or not, for my question is, i want to bind data to my textbox after user click the autocomplete suggestion.

i need to do this because my query for bind data is refer from the autocompletemode textbox = txtNDP.text, code for binding will start working after the txtNDP.text filled and the error will comeout.
hope someone can understand my problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.