1,105,585 Community Members

Autocompletemode

Member Avatar
Hazuan Nazri
Junior Poster in Training
91 posts since Apr 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 5 [?]
 
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

Member Avatar
ss125
Posting Whiz in Training
200 posts since Jul 2013
Reputation Points: 18 [?]
Q&As Helped to Solve: 22 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Hazuan Nazri
Junior Poster in Training
91 posts since Apr 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 5 [?]
 
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
Member Avatar
ss125
Posting Whiz in Training
200 posts since Jul 2013
Reputation Points: 18 [?]
Q&As Helped to Solve: 22 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
Hazuan Nazri
Junior Poster in Training
91 posts since Apr 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 5 [?]
 
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.

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