Greetings,
I would like to ask what kind of design pattern will be the best in the scenario described below:
I have a two combobox:
option1 option21
option2 option22
option3 option23
option4 option24
there should be a specific combinations of those two comboboxes – only specific values should be displayed in second combobox depends on the values selected in first combobox.
For instance: If i choose option1 – only option21 and option22 should be visible.
What kind of design patter should i use? I would like to add that I don’t use any DB.
Why does everything have to be a “design pattern”?
It also depends on what your language offers, e.g. in Python you could just do a dict with internal and display values of the dropdowns:
If you have a specific UI API in mind, maybe you could mention that…most APIs (web rendering frameworks, &c) have a canonical way of implementing things.
Edit: For .NET, the same method may work after a quick Googling:
Have a Dictionary(String -> Vector).
In Dictionary, put the values for the first combobox as key, and map the corresponding values in the second as value. The values for the first combobox can then be set using:
the second combobox can be used with
If you clear the second one and re-set it w/ above on every change in the first — done.