Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two combo box on my form (category and activity) that reads data from the db and display them in their DropDown. under category when I select Beauticians the activity ComboBox automatically fills it self with barber, hair dresser, and manicure but when I reselect construction in the category ComboBox massion, carpentry and plumber get added to the barber, hair dresser, and manicure which is for Beautician.

how do reset the activity ComboBox DropDown when a new category is selected

I tried this but did not work.
C#
this.cboType.Refresh();
this.cboType.Reset();
Posted
Updated 3-Oct-12 5:35am
v3

hi
write the folowing code to clear the data in combobox
C#
comboBox1.Items.Clear();

here combobox1 is an object of combobox.

hope this may resolve your problem.
thanks.
 
Share this answer
 
v2
Comments
mikeoabban 27-Jun-12 11:33am    
thanks is it that simple. it worked
preet88 27-Jun-12 11:54am    
:) your welcome
mark your question as solved by accepting answer it may help others as well.
thanks :)
It sounds like you are updating your second combo box manually after the first one is changed instead of having it bound directly to the database. If this is the case, set the DataSource to nothing before you add your new items. This should blank out your existing data.

Here is a Stack Overflow question that has more details on how to do this:
http://stackoverflow.com/questions/512385/combobox-refresh-after-adding-data-from-childform[^]
 
Share this answer
 
clear the older contents of your 2nd combo box

C#
cb2.items.clear();


then load new items in it based on it.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900