Hiding tab headers on a TabControl in C#

After browsing around a little bit, I found an interesting solution if you need to hide the tab headers on a tab control. I found it here, posted on the MSDN social forums by “nobugz” (Hans Passant). Here is his solution:

class YourTabControl : 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;
            base.WndProc(ref m);

Basically, you define your own class that extends TabControl. The custom class overrides the WndProc method, which is responsible for processing Windows messages sent to windows and controls. The new version filters out the message which is responsible for drawing the tab headers. Very clever.

To use it, you can make a normal TabControl using the designer. Then, in the Designer code, change the following line (in the InitializeComponent method):

this.tabControl1 =  new System.Windows.Forms.TabControl();


this.tabControl1 =  new YourTabControl();

Finally, near the bottom of the Designer code should be a line that looks like this:

private System.Windows.Forms.TabControl tabControl1;

Change it to:

private YourTabControl tabControl1;

Another clever thing about this is that, as you will notice, tab headers are still visible while in Design mode.

Join the Conversation


  1. Thank you!
    I had found the code sample, but you have to do this manipulation
    to get it working!

  2. I implemented this, and I see that the Tabs are an all-or-nothing visible or not currently;
    Is it possible to extend the class so that individual tabs are visible or not?

  3. Is there a way to manipulate this code in order to show and hide the tabs at runtime, such as by clicking a button?

      1. Thanks, a simple boolean toggle works, however it wont redraw the tabs immediately. I have to switch hidden tabs programmatically and then they display. Ive tried .Refresh(), .Invalidate() and .Update() but none seem to force an instant redraw.

        If an immediate redraw isn’t possible I’ll just do a work around for a quick switch and switch back between tabs.

          1. I tried both, the TabControl and the whole Form, neither caused the tabs to be redisplayed immediately, although it still appeared to be redrawing (background image flickered, things like that). Tabs still would not redisplay until they were switched.

Leave a comment

Leave a Reply