Assume you have controls A, B, C, D and E all with a Visibility property. You also have states 1,2,3,4,5 and 6 in which various combinations of your controls would be displayed.
Currently this is being handled by switch statements for each state: i.e.
Select Case PageState
case "1"
a.visible = false
b.visible = true
c.visible = false
d.visible = true
e.visible = false
case "2"
a.visible = true
b.visible = true
c.visible = false
d.visible = true
e.visible = false
case ...
End Select
As you can imagine, this becomes a pain as every state needs a show/hide statement for each control. How can I refactor this so that adding controls and/or states becomes trivial?
My first instinct is to extend the control and add a collection of states that it should display for but this sounds like overkill.
Edit I was deliberately vague in my question in case this has other implications. In my current instance the "controls" in question are ASP Panels. Does that change anything?