Multiple collections with 1 listbox

JohnM

Well-known member
Joined
Jul 2, 2004
Messages
116
Location
Massachusetts
Programming Experience
1-3
I habe an application where the user selects a city within a state. I entered all the cities in the state into a collection tied into the listbox. Is it possible to have a collection within the application for each of the 50 states and use the same listbox? Have 50 collections and code it so that user selects the state and the listbox shows the cities from that state.

Thank you for your time

John M
 
Use a Hashtable. The keys would be the state names and the values would be arrays or ArrayLists containing the city names for that state. When the user selects a state you use the name to get the corresponding list of cities from the Hashtable and bind that to the ListBox.
 
Back
Top