Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to populate a dropdown in object oriented manner. how can i do soo?
Posted
Updated 9-Nov-11 3:24am
v2

1 solution

You just need to have a class that you want to use for selection, call it a Product class. Let this Product class have 4 Properties, ProductID, Description, Price and StockLevel. The first thing to do is gather a group of these into a List<Product> call this ProductList. Then in your form you insert a ComboBox, set it's DataSource property to ProductList, then you set it's DisplayMember property to Description, and it's ValueMember property to ProductID. This will populate the ComboBox with the List, and allow the user to select an individual product, which will be accessible through the Combo's SelectedItem property.

Hope this helps
 
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