VB. NET WEB FORM Autocomplete textbox with dataset - from ado .net dataset designer
A basic dataset in VB.NET with the get method.
I will use this method to return all the data from the list. I have no idea as to how much calls i am going to be placing on this dataset, it will be wise to call this at "Form Load" and save the list on the client in some kind of generic list, etc.
' A global vairable to hold the list
Dim col As New AutoCompleteStringCollection
' populate only on the form load to ensure one call is made to the database
Private Sub OwnersPartiesFrm_Load(sender As System.Object, e As System.EventArgs) Handles 'Load List of Known Names
Dim KnownnNamesDF As New KnownNamesDSTableAdapters.ListofNameTableAdapter
Dim KnownNamesDT As New KnownNamesDS.ListofNameDataTable
KnownNamesDT = KnownnNamesDF.GetData()
For i = 0 To KnownNamesDT.Rows.Count - 1
col.Add(KnownNamesDT(i).KnownNames.ToString)
Next
End Sub
'Use the variable to populate on the textbox enter event ( better performance over the text changed event)
Private Sub TextBoxName_Enter(sender As System.Object, e As System.EventArgs) Handles TextBoxName.Enter
TextBoxName.AutoCompleteMode = AutoCompleteMode.Suggest
TextBoxName.AutoCompleteSource = AutoCompleteSource.CustomSource
TextBoxName.AutoCompleteCustomSource = col
End Sub
Sunday, January 27, 2013
Monday, January 7, 2013
AUtoComplete with a text box in VB Win Forms
Dim cmd As New SqlCommand("SELECT columnname FROM table", conn)Dim ds As New DataSetDim da As New SqlDataAdapter(cmd)da.Fill(ds, "list") // list can be any name u wantDim col As New AutoCompleteStringCollectionDim i As IntegerFor i = 0 To ds.Tables(0).Rows.Count - 1col.Add(ds.Tables(0).Rows(i)("columnname").ToString()) //columnname same as in queryNextTextBox1.AutoCompleteSource = AutoCompleteSource.CustomSourceTextBox1.AutoCompleteCustomSource = colTextBox1.AutoCompleteMode = AutoCompleteMode.Suggest
I will do this with a dataset.
http://www.daniweb.com/software-development/vbnet/threads/358691/textbox-autocomplete-from-database
Subscribe to:
Comments (Atom)
