Monday, January 7, 2013

AUtoComplete with a text box in VB Win Forms


  1. Dim cmd As New SqlCommand("SELECT columnname FROM table", conn)
  2. Dim ds As New DataSet
  3. Dim da As New SqlDataAdapter(cmd)
  4. da.Fill(ds, "list") // list can be any name u want
  5. Dim col As New AutoCompleteStringCollection
  6. Dim i As Integer
  7. For i = 0 To ds.Tables(0).Rows.Count - 1
  8. col.Add(ds.Tables(0).Rows(i)("columnname").ToString()) //columnname same as in query
  9. Next
  10. TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
  11. TextBox1.AutoCompleteCustomSource = col
  12. TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest

I will do this with a dataset.
http://www.daniweb.com/software-development/vbnet/threads/358691/textbox-autocomplete-from-database

No comments:

Post a Comment