40

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?

binki
  • 7,754
  • 5
  • 64
  • 110
Running Rabbit
  • 2,634
  • 15
  • 48
  • 69
  • I suppose it's possible to resize it to 1px, so it's nearly invisible. Take a look at answer here: http://stackoverflow.com/questions/9998672/winforms-how-to-show-hide-elements-in-designer/9998835#9998835. – Lukasz M Apr 25 '12 at 17:02
  • I have tried to resize it but its still not working...Is their any other way around to get this problem solved? – Running Rabbit Apr 26 '12 at 06:30
  • Did you try to set y position to negative ... something? – sventevit Apr 26 '12 at 19:04
  • possible duplicate of [Creating Wizards for Windows Forms in C#](http://stackoverflow.com/questions/2340566/creating-wizards-for-windows-forms-in-c-sharp) – Hans Passant Apr 26 '12 at 19:23

5 Answers5

136

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;
Romil Kumar Jain
  • 20,239
  • 9
  • 63
  • 92
  • 1
    But you can still use Ctrl+Tab to switch between tabs :) – Tommix Apr 03 '19 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 May 16 '21 at 02:45
  • 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 Jul 03 '22 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.

Lukasz M
  • 5,635
  • 2
  • 22
  • 29
  • 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. – Running Rabbit Apr 27 '12 at 05: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 Apr 27 '12 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. – Running Rabbit May 07 '12 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: http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.aspx. – Lukasz M May 07 '12 at 18:11
  • question was " Tab Control with no Tab Header" you write here absolutely oftopic. – Tommix Dec 02 '15 at 09:36
  • The solution I described should give you similar result to tabs with hidden headers, so I suppose it's rather not off-topic ;). If the goal was to prevent users from manually switching between different layouts (tabs), this is one of the ways to achieve it. – Lukasz M Dec 05 '15 at 22:34
-1

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

Phil
  • 87
  • 1
  • 2
  • 9
  • can you please elaborate? – Enamul Hassan Dec 16 '15 at 08:50
  • you stretch the window more upper with your mouse, until it gets out of the form. – Phil Dec 17 '15 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. – Nikola Malešević Jun 02 '16 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 Mar 02 '18 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. – Nikola Malešević Mar 03 '18 at 21:10
  • @NikolaMalešević The top voted answer is easier to implement it but it is still just as much a hack as this one is. For now, I’m just not going to use a `TabControl` in the first place ;-) – binki Mar 05 '18 at 19:54
-1

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

monikapatelIT
  • 977
  • 14
  • 26
  • But will it hide the entire tab header itself? – binki Mar 02 '18 at 18:50
  • @binki Its only hide tab header text look at here https://photos.app.goo.gl/Ddray3XC8TrQrWx92 This is what question asked for. Please do post me back if it does work – monikapatelIT Mar 09 '18 at 02: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 Mar 09 '18 at 23:23
  • I am sorry I misunderstood the question. I couldn't think of hiding header – monikapatelIT Mar 10 '18 at 04: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.

Massimo
  • 137
  • 1
  • 4
  • The question is asking how to entirely hide the tab header—not how to prevent the user from switching to another tab. – binki Mar 02 '18 at 18:51