tags:

views:

134

answers:

1

I have a form that will multiple Panel controls stacked on top of each other, each one being shown/hidden based on other selected options on the form. This has been a real pain to manage in the form designer as the panels don't behave like a full TabControl. However, it doesn't look like you can use a TabControl without the tabs. What is the best way to handle this? Is there a control like the TabControl, but without the tabs?

+5  A: 

You can hide the tabs, very convenient in the designer. Add a new class to your project and paste this code:

using System;
using System.Windows.Forms;

public class TablessControl : TabControl {
  protected override void WndProc(ref Message m) {
    // Hide tabs by trapping the TCM_ADJUSTRECT message
    if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
    else base.WndProc(ref m);
  }
}
Hans Passant
Worked like a champ - thanks.
Jon Tackabury