By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

BindingSource with ComboBox

P: 54
'Nothing gets populated and the autocomplete feature does not work as well. Please review the code for me. Thanks
Expand|Select|Wrap|Line Numbers
  1. 'Connection established already 
  2. SQLCon.ConnectionString = DataL1
  3. SqlQuery = "Select * from Users order by  UserName asc"
  4. ds = New DataSet 
  5. da = New SqlDataAdapter(SqlQuery, SQLCon)
  6. Try
  7.     da.Fill(ds, "Users")
  8.     Dim bs = new BindingSource()
  9.     bs.DataSource = ds.Tables(0)
  10.     frmtracking.cboFrom1.DataSource = bs
  11.  
  12.     Dim bs1 = new BindingSource()
  13.     bs1.DataSource = ds.Tables(0)
  14.     frmtracking.cboFrom2.DataSource = bs1
  15.  
  16.     .... repeat for the other combos
  17.  
  18.  
  19.     Dim col As New AutoCompleteStringCollection
  20.     Dim i As Integer
  21.     For i = 0 To dTable.Tables(0).Rows.Count - 1
  22.         col.Add(dTable.Tables(0).Rows(i)("UserName").ToString.Trim())
  23.     Next
  24.     frmTracking.cboTo1.AutoCompleteSource = AutoCompleteSource.CustomSource
  25.     frmTracking.cboTo1.AutoCompleteCustomSource = col
  26.     frmTracking.cboTo1.AutoCompleteMode = AutoCompleteMode.Suggest
  27.  
  28.  
  29.     frmTracking.cboFrom1.AutoCompleteSource = AutoCompleteSource.CustomSource
  30.     frmTracking.cboFrom1.AutoCompleteCustomSource = col
  31.     frmTracking.cboFrom1.AutoCompleteMode = AutoCompleteMode.Suggest
  32.  
  33.  
Apr 24 '14 #1
Share this Question
Share on Google+
1 Reply


kadghar
Expert 100+
P: 1,295
For populating, try using the DataSet directly:

Expand|Select|Wrap|Line Numbers
  1. cboFrom2.Datasource = ds.Tables(0)
For the autocomplete, it seems fine, but I use this syntax instead:

Expand|Select|Wrap|Line Numbers
  1. col.Add(dTable.Tables(0).Rows(i).Item("UserName").ToString.Trim())
HTH
Apr 24 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.