views:

531

answers:

1

Basically, I am creating a Windows Form with a Tab Control on it, and I want to have multiple types of tab pages for the different types of objects I will be editing the properties of. Basically like interface in Visual Studio, where you can have multiple tab pages of code, then multiple tabs of resource files, etc.

To do this, I figure that I will need to:

  1. Create a class inheriting from TabPage for each type of tabpage layout I would like.
  2. Make each of these classes accept a certain type of object in the constructor.
  3. In the constructor, create all the controls for that tab page and set the properties.

However, this means that I cannot design the tab pages in Visual Studio (I will need to code the layout by hand).

Am I going about this the correct way? Or is there a different way to approach this problem?

+1  A: 

Have you considered creating a Custom Control for each type of page that you want to display? Rather than having different types of tabs, you can then use Visual Studio to design the layout of each custom control (along with any code that is per-tab), and when a new tab is created, make its sole child control an instance of the relevant type of custom control.

Advantages:

  • This allows you to use VS to design the look and feel of the tab contents
  • If you want to re-use the UI for the contents of the tab elsewhere, it's already decoupled from the tab control (this would even help if at a later date you moved to using windows instead of tabs, for example).
Rob
I agree. You can then add some properties to those custom controls as well, like what kind of icon you want, special toolbars and stuff to add, and handle it in code when you add the tab to the tabcontrol.
Patrick