1.11M Members

Autocompletemode

 
0
 

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

 
0
 

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

 
0
 

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
 
0
 

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

 
0
 

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.

Isn't it about time forums rewarded their contributors?

Earn rewards points for helping others. Gain kudos. Cash out. Get better answers yourself.

It's as simple as contributing editorial or replying to discussions labeled or OP Kudos

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article