473,473 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

BindingSource with ComboBox

54 New Member
'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
1 2023
kadghar
1,295 Recognized Expert Top Contributor
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

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

Similar topics

2
by: bds | last post by:
I'm new to .net 2.0 and I'm trying to figure out the best way to create a form that has a couple of controls and one of the controls is a combo box with a data bound list of items from another...
2
by: Crazy Cat | last post by:
I am using a data-bound combobox with dropdownstyle set to dropdownlist. Teh combobox is bound to a bindingsource which is in turn bound to a table in my database. The table has only 4 rows and I...
1
by: Bill Nguyen | last post by:
Is there a way to add a new item to a combobox after Datasource property is set to a recordset? Thanks Bill
19
by: active | last post by:
I'm using a ComboBox to display objects of a class I've defined, say CQQ. Works great except somehow I occasionally set an Item to a String object instead of an object of type CQQ. It looks...
3
by: Przemek M. Zawada | last post by:
Dear Group, I'm developing sample window form, using DataGridView control, which is filled with data through BindingSource, which is based on type of object, as follow: public sampleClass {...
5
by: Randy | last post by:
Hi, I'm have a form with a listbox and a few textboxes on it. Based on the user's selection in the listbox, I want the bindingsource to update the textboxes with the corresponding values. I have...
3
by: Gerrit | last post by:
Hi, I try to learn programming in c# with databinding controls. Now I have a problem with a ComboBox with the advanced properties for databinding, I want to set the DataSourceUpdateMode to...
1
by: Andrus | last post by:
I need to enter null value from combobox to business object property. My combobox datasource does not contain ValueMember with null value. So I tried to create combobox which stores null to bound...
4
by: sree078 | last post by:
I've a list of items which I bound to multiple combo boxes. In the due course in the code...I had to add an item into one combo box...but I don't want it to be reflected into any other combo...
1
by: Rekha Sharma | last post by:
Private Sub DGVColumnHeader_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.DataGridView1.DataSource = Me.bs Dim i As Integer = -1...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.