43

I have created a Windows form using a Tab Control, but it has a header with it. I want to hide it. I am not able to do it using any properties of the Tab Control. Is there any property defined for hiding the tab header for the Tab Control without going through the code?

4

5 Answers 5

144

Use following code to hide the tabs or set these properties in design.

    tabControl.Appearance = TabAppearance.FlatButtons;
    tabControl.ItemSize = new Size(0, 1);
    tabControl.SizeMode = TabSizeMode.Fixed;
3
  • 1
    But you can still use Ctrl+Tab to switch between tabs :)
    – Tommix
    Commented Apr 3, 2019 at 23:23
  • 2
    Works well, but turns out the buttons have to be on top. So adding to this answer... tabControl.Alignment = TabAlignment.Top
    – damichab
    Commented May 16, 2021 at 2:45
  • 1
    I've found another question to this problem from 2010 or so but nothing worked after that long time. This solution is simple, easy to use and works.
    – Sundancer
    Commented Jul 3, 2022 at 15:59
4

You want the tab panels without the feature allowing a user to switch between them, so I suppose you want to create few separate sets of controls to be shown to the user one at a time. You can achieve this in several ways (you can choose one of them if you find it appropriate in your case):

  • Use several Panel controls instead of several tabs in the TabControl, however, it would be hard to work in the designer, because all the controls would be visible
  • Use different Forms instead of tabs to keep the layout parts separated. It can be ok, but you may not want to use multiple Forms, so it depends on a specific case.

and finally, the suggested solution:

  • Encapsulate each set of controls in a UserControl. This allows you to keep each layout separately, so you can easily design each of them without the other controls getting in the way ;). The the code handling each of the layouts would also be separated. Then just drag those controls in the Form and use set their visibilities appropriately to show the one you want.

If none of those suggestions work for you, let me know, so I can look for other possible solutions.

6
  • 1
    Thanks for your help Lucas. I'v figured it out how to get rid of the Tab Header. I'v just set the "ShowTabs" properties of the Tab control to false and it worked. Well using Panel control can definitly work. Thank you so much for you help. Will let you know if I face any other difficulty. Commented Apr 27, 2012 at 5:56
  • 1
    I can't see ShowTabs property in TabControl control neither in WinForms nor in WPF. Are you using something different? Anyway, I'm glad you've found the solution :).
    – Lukasz M
    Commented Apr 27, 2012 at 17:25
  • Hi Lucas, I am using simple windows form application. Yes, it has a ShowTabs Property. I can attach a screen shot if you want. Is there any way that I can attach a screen shot. Commented May 7, 2012 at 10:39
  • 3
    Hey, thanks for your response :). I believe you can see this property in the control you use, however, I'm not sure if it's the default TabControl available in .NET. I can't find it even at MSDN listing all the TabControl class members: msdn.microsoft.com/en-us/library/….
    – Lukasz M
    Commented May 7, 2012 at 18:11
  • question was " Tab Control with no Tab Header" you write here absolutely oftopic.
    – Tommix
    Commented Dec 2, 2015 at 9:36
-1

It's more easy as you think, you just drag the panel's window upper, so will be outside of the form.

6
  • can you please elaborate? Commented Dec 16, 2015 at 8:50
  • you stretch the window more upper with your mouse, until it gets out of the form.
    – Phil
    Commented Dec 17, 2015 at 22:45
  • 2
    This mandates tab control at the very top of the window which breaks design guidelines and gives no space to other kind of control arrangement. Commented Jun 2, 2016 at 14:09
  • @NikolaMalešević I agree that this is very ugly, but you could accomplish the same hack by covering the tab header with a Panel even when the control is not at the top of its container.
    – binki
    Commented Mar 2, 2018 at 18:52
  • @binki Or you can just use the top-voted answer above and solve the problem in a nice and elegant way. Let's keep it simple. Commented Mar 3, 2018 at 21:10
-1

Use DrawMode: OwnerDrawFixed will hide TabPage header text DrawMode : OwnerDrawFixed

4
  • But will it hide the entire tab header itself?
    – binki
    Commented Mar 2, 2018 at 18:50
  • @binki Its only hide tab header text look at here photos.app.goo.gl/Ddray3XC8TrQrWx92 This is what question asked for. Please do post me back if it does work Commented Mar 9, 2018 at 2:57
  • The question asked for how to hide the entire tab without hiding the contents of the tab. Not just how to avoid rendering the text within the tab. I think you do not understand the question.
    – binki
    Commented Mar 9, 2018 at 23:23
  • I am sorry I misunderstood the question. I couldn't think of hiding header Commented Mar 10, 2018 at 4:16
-2

Another way to achieve the same (or similar) is: You can remove tabs from TabControl.TabPages collection and then add the tab you want to show.

During the Form initialization I remove tabs (so into the designer I can easily manage them) and in some control event (as button click) I show the tab the user has to see.

Something like that:

// During form load:
ctrTab.TabPages.Clear();

// ...... 

// During button click or some other event:
if(rbSend.Checked)
    ctrTab.TabPages.Add(pgSend);
else
    ctrTab.TabPages.Add(pgReceive);

In this way the user can still see the header tab but just as title of controls group, he can't change/switch the current active tab.

1
  • The question is asking how to entirely hide the tab header—not how to prevent the user from switching to another tab.
    – binki
    Commented Mar 2, 2018 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.