I have already read this question which talks about the same thing but I had a specific question about the design. As you know the options dialog in VS is a TreeView control on the left and a panel like control on the right which houses all the options for the current selection of the TreeView control. Based on the advice given in the above question I decided to build a UserControl for each “panel” of options. I am trying to decide the best way to make the selected panel visible and all other panels hidden when you user picks a specific node in the TreeView. In my event handler for when a new node in the TreeView is selected a do the following:
If e.Node.Name.CompareTo("PanelAName") = 0 Then
PanelA.Visible = True
PanelA.Enabled = True
PanelB.Visible = False
PanelB.Enabled = False
ElseIf e.Node.Name.CompareTo("PanelBName") = 0 Then
PanelA.Visible = False
PanelA.Enabled = False
PanelB.Visible = True
PanelB.Enabled = True
End If
The only problem is instead having just the two panels in the sample code I am going to have like 15-25. While I could certainly still do it like this it seems like a lot more lines of code then should be need. Any suggestions on a better way?
You can try utilizing the Tag property of the node to hold the name of the associated panel, then try looping over the panels in the form and compare the node name with the panel name:
You can add a reference from each panel into the node’s tag property, as well: