473,467 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

BindingSource with comboboxes using Autocomplete feature

54 New Member
Please, I'm using vb.net ultimate 2013 and I have about 15 comboboxes being populated with data at runtime.
Now, I used a "for loop"to add autocomplete feature to the comboboxes and it takes a longer time to load the form as a result of the "for loop", looping through each combo box to add the autocomplete feature. I thought of a binding source but how to implement it becomes a problem. Is there any quick way to to add the auto complete feature at runtime? That's my code below.


Expand|Select|Wrap|Line Numbers
  1. 'Connection already established
  2. SQLCon.ConnectionString = DataL1
  3.         SqlQuery = "Select * from Users order by  UserName asc"
  4.         dSet1 = New DataSet : dSet2 = New DataSet : dSet3 = New DataSet : dSet4 = New DataSet
  5.         dSet5 = New DataSet : dSet6 = New DataSet : dSet7 = New DataSet : dSet8 = New DataSet
  6.         dSet9 = New DataSet : dSet10 = New DataSet : dSet11 = New DataSet : dSet12 = New DataSet
  7.         dSet13 = New DataSet : dSet14 = New DataSet : dSet15 = New DataSet
  8.         dTable = New DataSet
  9.         daAdapterRec = New SqlDataAdapter
  10.         daAdapter1 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter2 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter3 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter4 = New SqlDataAdapter(SqlQuery, SQLCon)
  11.         daAdapter5 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter6 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter7 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter8 = New SqlDataAdapter(SqlQuery, SQLCon)
  12.         daAdapter9 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter10 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter11 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter12 = New SqlDataAdapter(SqlQuery, SQLCon)
  13.         daAdapter13 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter14 = New SqlDataAdapter(SqlQuery, SQLCon) : daAdapter15 = New SqlDataAdapter(SqlQuery, SQLCon)
  14.         daAdapter = New SqlDataAdapter(SqlQuery, SQLCon)
  15.         Try
  16.             daAdapter1.Fill(dSet1, "Users") : daAdapter2.Fill(dSet2, "Users") : daAdapter3.Fill(dSet3, "Users") : daAdapter4.Fill(dSet4, "Users") : daAdapter5.Fill(dSet5, "Users") : daAdapter5.Fill(dSet5, "Users")
  17.             daAdapter6.Fill(dSet6, "Users") : daAdapter7.Fill(dSet7, "Users") : daAdapter8.Fill(dSet8, "Users") : daAdapter9.Fill(dSet9, "Users") : daAdapter10.Fill(dSet10, "Users") : daAdapter11.Fill(dSet11, "Users")
  18.             daAdapter12.Fill(dSet12, "Users") : daAdapter13.Fill(dSet13, "Users") : daAdapter14.Fill(dSet14, "Users") : daAdapter15.Fill(dSet15, "Users")
  19.             daAdapter.Fill(dTable, "Users")
  20.             'From1
  21.             frmtracking.cboFrom1.DataSource = dTable.Tables("Users")
  22.             frmtracking.cboFrom1.DisplayMember = "UserName"
  23.             frmTracking.cboFrom1.Text = frmVisibleNot.txtUsername.Text.Trim
  24.  
  25.             'To1
  26.             frmtracking.cboTo1.DataSource = dSet1.Tables("Users")
  27.             frmtracking.cboTo1.DisplayMember = "UserName"
  28.             'To2
  29.             frmtracking.cboTo2.DataSource = dSet2.Tables("Users")
  30.             frmtracking.cboTo2.DisplayMember = "UserName"
  31.             'To3
  32.             frmtracking.cboTo3.DataSource = dSet3.Tables("Users")
  33.             frmtracking.cboTo3.DisplayMember = "UserName"
  34.             'To4
  35.             frmtracking.cboTo4.DataSource = dSet4.Tables("Users")
  36.             frmtracking.cboTo4.DisplayMember = "UserName"
  37.             'To5
  38.             frmtracking.cboTo5.DataSource = dSet5.Tables("Users")
  39.             frmtracking.cboTo5.DisplayMember = "UserName"
  40.             'To6
  41.             frmtracking.cboTo6.DataSource = dSet6.Tables("Users")
  42.             frmtracking.cboTo6.DisplayMember = "UserName"
  43.             'To7
  44.             frmtracking.cboTo7.DataSource = dSet7.Tables("Users")
  45.             frmtracking.cboTo7.DisplayMember = "UserName"
  46.             'To8
  47.             frmtracking.cboTo8.DataSource = dSet8.Tables("Users")
  48.             frmtracking.cboTo8.DisplayMember = "UserName"
  49.             'To9
  50.             frmtracking.cboTo9.DataSource = dSet9.Tables("Users")
  51.             frmtracking.cboTo9.DisplayMember = "UserName"
  52.             'To10
  53.             frmtracking.cboTo10.DataSource = dSet10.Tables("Users")
  54.             frmtracking.cboTo10.DisplayMember = "UserName"
  55.             'To11
  56.             frmtracking.cboTo11.DataSource = dSet11.Tables("Users")
  57.             frmtracking.cboTo11.DisplayMember = "UserName"
  58.             'To12
  59.             frmtracking.cboTo12.DataSource = dSet12.Tables("Users")
  60.             frmtracking.cboTo12.DisplayMember = "UserName"
  61.             frmtracking.cboTo12.Text = ""
  62.             'To13
  63.             frmtracking.cboTo13.DataSource = dSet13.Tables("Users")
  64.             frmtracking.cboTo13.DisplayMember = "UserName"
  65.             'To14
  66.             frmtracking.cboTo14.DataSource = dSet14.Tables("Users")
  67.             frmtracking.cboTo14.DisplayMember = "UserName"
  68.             'To15
  69.             frmtracking.cboTo15.DataSource = dSet15.Tables("Users")
  70.             frmTracking.cboTo15.DisplayMember = "UserName"
  71.             'Auto Complete All the Fields
  72.             Dim col As New AutoCompleteStringCollection
  73.             Dim i As Integer
  74.             For i = 0 To dTable.Tables(0).Rows.Count - 1
  75.                 col.Add(dTable.Tables(0).Rows(i)("UserName").ToString.Trim())
  76.                 frmTracking.cboTo1.AutoCompleteSource = AutoCompleteSource.CustomSource
  77.                 frmTracking.cboTo1.AutoCompleteCustomSource = col
  78.                 frmTracking.cboTo1.AutoCompleteMode = AutoCompleteMode.Suggest
  79.             Next
  80.  
  81.             'Auto Complete All the Fields
  82.             Dim col2 As New AutoCompleteStringCollection
  83.             Dim ii As Integer
  84.             For ii = 0 To dSet2.Tables(0).Rows.Count - 1
  85.                 col2.Add(dSet2.Tables(0).Rows(ii)("UserName").ToString.Trim())
  86.                 frmTracking.cboTo2.AutoCompleteSource = AutoCompleteSource.CustomSource
  87.                 frmTracking.cboTo2.AutoCompleteCustomSource = col2
  88.                 frmTracking.cboTo2.AutoCompleteMode = AutoCompleteMode.Suggest
  89.             Next
  90.             'Auto Complete All the Fields
  91.             Dim col3 As New AutoCompleteStringCollection
  92.             Dim iii As Integer
  93.             For iii = 0 To dSet3.Tables(0).Rows.Count - 1
  94.                 col3.Add(dSet3.Tables(0).Rows(iii)("UserName").ToString.Trim())
  95.                 frmTracking.cboTo3.AutoCompleteSource = AutoCompleteSource.CustomSource
  96.                 frmTracking.cboTo3.AutoCompleteCustomSource = col3
  97.                 frmTracking.cboTo3.AutoCompleteMode = AutoCompleteMode.Suggest
  98.             Next
  99.             'Auto Complete All the Fields
  100.             Dim col4 As New AutoCompleteStringCollection
  101.             Dim iv As Integer
  102.             For iv = 0 To dSet4.Tables(0).Rows.Count - 1
  103.                 col4.Add(dSet4.Tables(0).Rows(iv)("UserName").ToString.Trim())
  104.                 frmTracking.cboTo4.AutoCompleteSource = AutoCompleteSource.CustomSource
  105.                 frmTracking.cboTo4.AutoCompleteCustomSource = col4
  106.                 frmTracking.cboTo4.AutoCompleteMode = AutoCompleteMode.Suggest
  107.             Next
  108.             'Auto Complete All the Fields
  109.             Dim col5 As New AutoCompleteStringCollection
  110.             Dim v As Integer
  111.             For v = 0 To dSet5.Tables(0).Rows.Count - 1
  112.                 col5.Add(dSet5.Tables(0).Rows(v)("UserName").ToString.Trim())
  113.                 frmTracking.cboTo5.AutoCompleteSource = AutoCompleteSource.CustomSource
  114.                 frmTracking.cboTo5.AutoCompleteCustomSource = col5
  115.                 frmTracking.cboTo5.AutoCompleteMode = AutoCompleteMode.Suggest
  116.             Next
  117.             Dim col6 As New AutoCompleteStringCollection
  118.             Dim vi As Integer
  119.             For vi = 0 To dSet6.Tables(0).Rows.Count - 1
  120.                 col6.Add(dSet6.Tables(0).Rows(vi)("UserName").ToString.Trim())
  121.                 frmTracking.cboTo6.AutoCompleteSource = AutoCompleteSource.CustomSource
  122.                 frmTracking.cboTo6.AutoCompleteCustomSource = col6
  123.                 frmTracking.cboTo6.AutoCompleteMode = AutoCompleteMode.Suggest
  124.             Next
  125.  
  126.  
  127.             Dim col7 As New AutoCompleteStringCollection
  128.             Dim vii As Integer
  129.             For vii = 0 To dSet7.Tables(0).Rows.Count - 1
  130.                 col7.Add(dSet7.Tables(0).Rows(vii)("UserName").ToString.Trim())
  131.                 frmTracking.cboTo7.AutoCompleteSource = AutoCompleteSource.CustomSource
  132.                 frmTracking.cboTo7.AutoCompleteCustomSource = col7
  133.                 frmTracking.cboTo7.AutoCompleteMode = AutoCompleteMode.Suggest
  134.             Next
  135.  
  136.             Dim col8 As New AutoCompleteStringCollection
  137.             Dim viii As Integer
  138.             For viii = 0 To dSet8.Tables(0).Rows.Count - 1
  139.                 col8.Add(dSet8.Tables(0).Rows(viii)("UserName").ToString.Trim())
  140.                 frmTracking.cboTo8.AutoCompleteSource = AutoCompleteSource.CustomSource
  141.                 frmTracking.cboTo8.AutoCompleteCustomSource = col8
  142.                 frmTracking.cboTo8.AutoCompleteMode = AutoCompleteMode.Suggest
  143.             Next
  144.  
  145.             Dim col9 As New AutoCompleteStringCollection
  146.             Dim ix As Integer
  147.             For ix = 0 To dSet9.Tables(0).Rows.Count - 1
  148.                 col9.Add(dSet9.Tables(0).Rows(ix)("UserName").ToString.Trim())
  149.                 frmTracking.cboTo9.AutoCompleteSource = AutoCompleteSource.CustomSource
  150.                 frmTracking.cboTo9.AutoCompleteCustomSource = col9
  151.                 frmTracking.cboTo9.AutoCompleteMode = AutoCompleteMode.Suggest
  152.             Next
  153.  
  154.  
Apr 23 '14 #1
0 1287

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

Similar topics

3
by: Pete | last post by:
I'm currently doing a database that uses comboboxes to look up records in other tables, whether they be lookup tables or otherwise. When a user needs to add an item to one of these tables, the...
0
by: peter78 | last post by:
I wanted to implement an autocomplete feature on the combobox where you would type in partial text and it would try to match it for you. It doesn't exist in .Net yet, but I'm guessing it will in...
5
by: jdzemke | last post by:
I am getting 'options' is null or not an object using when using a dynamic dataset with a dropdown list in an html form. I am filling-in a text field and filtering the values in the drop-down. ...
0
by: =?ISO-8859-15?Q?Mathias_W=FChrmann?= | last post by:
Hi everbody, everytime I use autocomplete feature for textbox or combobox, my application crashes with a Win32-Error exactly at the point, where the autocomplete should kick in. I have no...
2
by: VB Programmer | last post by:
Using the membership/roles feature in ASP.NET 2.0. What is the best, cleanest way to "delete" a user? Thanks!
3
by: Therasa | last post by:
Dear All, I need the coding for AutoComplete feature in asp.net 1.1 dropdown(combo) box. Pls kindly help me to resolve this problem ASAP. Thanks in Advance. Regards, Therasa.
1
by: MOHAMEDRIYASALI | last post by:
Hi, I am doing my final year project named "Tamil digital library search-Thirukkural" in which the various kurals are stored in ms access. They are searched and then retrieved.Now i need to finish...
0
Shafi hashmi
by: Shafi hashmi | last post by:
I have a windows form in C# which has a TextBox TextBox has AutoComplete set which has values as follows: Ab Ac Bc Bd When I type 'A' in the TextBox I get the list of:
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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 ...

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.