Click here to Skip to main content
11,921,889 members (56,878 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
Hi guys, I have many Comboboxes in my form (win forms). i was setting the dropdownstyle as DropDown for Autocomplete. If we are entering the data into first combobox then related data coming into the second combobox and so on. If we are clear the data of first combobox(Autocomplete), second comboboxes also cleared. But problem is doesn't cleared the second Combobox and also remaining comboboxes.

I wrote single method for all comboboxes(Autocomplete )

Public Sub AutoCompleteDropDown(ByVal str As String, ByVal AutoDropDown As ComboBox, ByVal strText As String)
           AutoDropDown.AutoCompleteCustomSource = Nothing
           Dim dt As DataTable = GetTable(str)
           If dt.Rows.Count > 0 Then
               For Each prow As DataRow In dt.Rows
               MessageBox.Show("No " & AutoDropDown.Name.Remove(0, 3) & " exists", strText, MessageBoxButtons.OK, MessageBoxIcon.Information)
               Exit Sub
           End If
           AutoDropDown.AutoCompleteMode = AutoCompleteMode.Suggest
           AutoDropDown.AutoCompleteSource = AutoCompleteSource.ListItems
           For Each drjob As DataRow In dt.Rows
           AutoDropDown.AutoCompleteCustomSource = DropDownCollection
       Catch ex As Exception
           MessageBox.Show(ex.Message, strText, MessageBoxButtons.OK, MessageBoxIcon.Information)
       End Try
   End Sub

first calling in load page for 1st combobox and load the data to 2nd combobox in 1st combobox
Posted 12-Mar-13 0:48am
Edited 14-Mar-13 11:40am
Maciej Los209.9K
Karthik Harve 12-Mar-13 6:09am
could show your code, where you are clearing the comboboxes on change of first combobox ?
CH Guravaiah 12-Mar-13 6:17am
in 1st combobox , i was cleared the remaining comboboxes .
Example : combobox2.items.clear(); and combobox2.text=string.empty
agnesn88 13-Mar-13 2:40am
you can download some free sample codes here--->

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 568
1 Dave Kreskowiak 285
2 Sergey Alexandrovich Kryukov 173
3 Richard MacCutchan 155
4 ppolymorphe 135
0 OriginalGriff 7,036
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,286
3 George Jonsson 2,840
4 Suvendu Shekhar Giri 2,216

Advertise | Privacy | Mobile
Web03 | 2.8.151120.1 | Last Updated 14 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100