Tab control with no visible tabs

One of my co-workers wanted to use a Windows Forms (2.0, in this case) TabControl as a way of swapping between sets of controls, but without display the actual tabs (controlling the switching entirely through code - a sort of swappable panel stack). After some fiddling around with various control settings, I found that  the following seems to work:
  1. Set SizeMode to Fixed.
  2. Set ItemSize to 0,1. The control won't let you set a size of 0,0, but 0,1 seems to have the desired effect.
  3. Set Appearance to Buttons. This removes the tab control border.
And that's it. You can work with the tab pages easily in the designer, and use the TabControl properties to set the active tab at runtime.

Update - One limitation with this approach is that you can't easily change the background color of a tab control. So if you want, for example, a white background on your form, you're out of luck.

20 Comments

Comments have been disabled for this content.