views:

57

answers:

3

I'm trying to create an options menu in a C# forms project, and I'm curious if there's a less ugly way to do this. I have a ListBox that has the different categories of options, and when you select a category, the options for that category appear in a panel on the right. Basically, something identical to the options menu in Visual Studio itself.

Obviously, different controls have to use the same real estate here, as every category has different options which need to be displayed in the same area of my form. So when you select a category, the controls for every other category must become hidden.

I'm currently using a different Panel object for each category (13 currently), but designing each panel is a headache because i need to drag the other 12 panels out of the way each time I need to alter one. Is there a better way to do this? I'm open to any suggestions, whether its a complete change in the implementation, or even just a Visual Studio tip for working with 1 of 13 panels that all overlap.

If all else fails I could use a TabControl rendered horizontally, but I don't like how that looks.

Thanks in advance.

+1  A: 

I can think of three alternate approaches:

  1. (Ok) Use a tab control that doesn't display the headers for the user.
  2. (Better) Create user controls for each option page, so you have different designer files for each.
  3. (Better yet?) Dynamically generate the UI based on some descriptive information, so there are no designer files to deal with at all.
John Fisher
I think I'll go with the User Control idea, seems to be the glaring solution I was too blind to think of. Out of curiosity though, can you remove the headers from the default TabControl? Or do you mean a custom tab control?
brydgesk
It's been quite a while since I've done WinForms development, but I think you could remove the headers.
John Fisher
+1  A: 

Take a look at the UserControl class. You can design on it with the Forms Designer, than programatically place it to the right of your ListBox when items are selected. Create a different UserControl for each category of options that you have.

Matthew Ferreira
A: 

First you should know when you are in Design Mode that there is a drop down menu from the Properties Windows (View->Prpoerties Menu), that allows you to select a control. So you don't need to move other controls out of the way encesarily.

Second, I would make the options panel for each category it's own user or custom control. This way you can edit the panel itself seperately. Then you have the option of showing/hiding that custom control when it's category is selected, or even dynamically creating the control.

AaronLS
The drop-down doesn't bring the selected control to the top of the z-order. So if I select one from the drop down and drag a component onto it, it puts the component on the top component, not the selected component.I like the user control idea though.
brydgesk