Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Windows form to develop Windows application.
I have two combobox one in Category and other one is Items.
When i change category then it should fill items related to category.
What should do for it or to use which property of combobox.

I have done in ASP.NET Application not in C#.net.
Have some idea to do it.
Posted

Hi,

If you are using database connection for combobox filling then

Do coding on category.SelectedIndexChanged. When selected gets changed then pass that index or selected value to database and fetch items related to that category and bind it to the second combobox. Use Property called Selectedvalue or SelectedIndex to retrive current selection of a category
 
Share this answer
 
What you are referring to is "Cascading Dropwdowns".

See this link to an example http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx[^]

At the bottom of the link, there is another link to an example which uses a database for the data source.

Hope this helps.
 
Share this answer
 
Hi
Firstly Load database value to combobox category on form load event then double click on category combobox to get the event which is selected index change in this pass where query to the database and selected data load to new combobox which is items combobox in C#

I have tested this code is run successfully on my computer.
 
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