If you open Visual Studio's Tools menu and select the Options command, you'll see an enormous set of options that you can set. The TreeView on the left groups the option pages. You dig through the TreeView to find an option category and a page within the category, and then the area on the right displays that page's options.
This provides a useful alternative to the TabControl.
If you open Visual Studio's Project menu and select Properties at the bottom, you can see an example tab-based property pages. Generally this style is easier to use because it lets you see all of the categories on the tabs all at once. The TreeView style is most appropriate when you have a huge number of pages so you can't practically put them all in separate tabs.
Building a TreeView is easy enough. The tougher questions are:
- How do you associate the nodes in the tree with the property pages?
- How do you build the property pages at design time?
- How do you display the selected property page at run time?
- How do you save and restore the settings on the property pages?
1. How do you associate the nodes in the tree with the property pages?
Edit a TreeView control at design time to build the categories and sub-categories that you want. Set each node's Tag property to the index of the property page that you want it to display.
2. How do you build the property pages at design time?
This example uses a TabControl to hold the property pages because it is easy to use and lets you add controls to its pages at design time. You cannot simply have the TreeView select the appropriate tab, however, because the TabControl displays tabs that you probably don't want. Even if you make the tabs owner-drawn and give them the smallest size possible (1x1 pixel), you see an annoying little bump where the tabs would be.
To avoid that, the example moves the contents of the tabs out of the TabControls onto the form.
Put a Panel control inside each tab and put all of the tab's other controls inside the Panel. When the program's main form loads, the following code moves the Panels onto the form.