Hide Tab Header on C# TabControl












41















I am developing a Windows Form Application with several pages. I am using a TabControl to implement this. Instead of using the header to switch between tabs, I want my application to control this e.g. the next tab should open after the user has filled in a text box and clicked the next button.










share|improve this question

























  • @Dan W How is a TabPage without the top thumb/selector significantly different than a Panel?

    – None of the Above
    Apr 19 '15 at 23:11








  • 1





    @Plutonix: Because in the designer, it would be a lot easier to switch between different groups of widgets by switching tabs.

    – Dan W
    Apr 20 '15 at 16:52











  • myPanelTabs(n).BringToFront Done. or mess with visible.

    – None of the Above
    Apr 20 '15 at 17:00








  • 1





    @Plutonix: That's code though, I want to be able to switch what's in a given area from the Forms designer with a single click actually while I'm in the Forms designer.

    – Dan W
    Apr 21 '15 at 21:25











  • @MickyDuncan: The program as it appears to the user would be anything but a wizard. They only see one of the tabs according to the software version they choose, and the other tabs/pages are permanently inaccessible as they would be irrelevant. But yes, a developer could use the idea to implement a wizard type system.

    – Dan W
    Apr 23 '15 at 20:55


















41















I am developing a Windows Form Application with several pages. I am using a TabControl to implement this. Instead of using the header to switch between tabs, I want my application to control this e.g. the next tab should open after the user has filled in a text box and clicked the next button.










share|improve this question

























  • @Dan W How is a TabPage without the top thumb/selector significantly different than a Panel?

    – None of the Above
    Apr 19 '15 at 23:11








  • 1





    @Plutonix: Because in the designer, it would be a lot easier to switch between different groups of widgets by switching tabs.

    – Dan W
    Apr 20 '15 at 16:52











  • myPanelTabs(n).BringToFront Done. or mess with visible.

    – None of the Above
    Apr 20 '15 at 17:00








  • 1





    @Plutonix: That's code though, I want to be able to switch what's in a given area from the Forms designer with a single click actually while I'm in the Forms designer.

    – Dan W
    Apr 21 '15 at 21:25











  • @MickyDuncan: The program as it appears to the user would be anything but a wizard. They only see one of the tabs according to the software version they choose, and the other tabs/pages are permanently inaccessible as they would be irrelevant. But yes, a developer could use the idea to implement a wizard type system.

    – Dan W
    Apr 23 '15 at 20:55
















41












41








41


18






I am developing a Windows Form Application with several pages. I am using a TabControl to implement this. Instead of using the header to switch between tabs, I want my application to control this e.g. the next tab should open after the user has filled in a text box and clicked the next button.










share|improve this question
















I am developing a Windows Form Application with several pages. I am using a TabControl to implement this. Instead of using the header to switch between tabs, I want my application to control this e.g. the next tab should open after the user has filled in a text box and clicked the next button.







c# winforms tabcontrol






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 24 '15 at 14:06









Arun A S

4,23231733




4,23231733










asked Aug 5 '11 at 8:31









Hossein MobasherHossein Mobasher

2,62343464




2,62343464













  • @Dan W How is a TabPage without the top thumb/selector significantly different than a Panel?

    – None of the Above
    Apr 19 '15 at 23:11








  • 1





    @Plutonix: Because in the designer, it would be a lot easier to switch between different groups of widgets by switching tabs.

    – Dan W
    Apr 20 '15 at 16:52











  • myPanelTabs(n).BringToFront Done. or mess with visible.

    – None of the Above
    Apr 20 '15 at 17:00








  • 1





    @Plutonix: That's code though, I want to be able to switch what's in a given area from the Forms designer with a single click actually while I'm in the Forms designer.

    – Dan W
    Apr 21 '15 at 21:25











  • @MickyDuncan: The program as it appears to the user would be anything but a wizard. They only see one of the tabs according to the software version they choose, and the other tabs/pages are permanently inaccessible as they would be irrelevant. But yes, a developer could use the idea to implement a wizard type system.

    – Dan W
    Apr 23 '15 at 20:55





















  • @Dan W How is a TabPage without the top thumb/selector significantly different than a Panel?

    – None of the Above
    Apr 19 '15 at 23:11








  • 1





    @Plutonix: Because in the designer, it would be a lot easier to switch between different groups of widgets by switching tabs.

    – Dan W
    Apr 20 '15 at 16:52











  • myPanelTabs(n).BringToFront Done. or mess with visible.

    – None of the Above
    Apr 20 '15 at 17:00








  • 1





    @Plutonix: That's code though, I want to be able to switch what's in a given area from the Forms designer with a single click actually while I'm in the Forms designer.

    – Dan W
    Apr 21 '15 at 21:25











  • @MickyDuncan: The program as it appears to the user would be anything but a wizard. They only see one of the tabs according to the software version they choose, and the other tabs/pages are permanently inaccessible as they would be irrelevant. But yes, a developer could use the idea to implement a wizard type system.

    – Dan W
    Apr 23 '15 at 20:55



















@Dan W How is a TabPage without the top thumb/selector significantly different than a Panel?

– None of the Above
Apr 19 '15 at 23:11







@Dan W How is a TabPage without the top thumb/selector significantly different than a Panel?

– None of the Above
Apr 19 '15 at 23:11






1




1





@Plutonix: Because in the designer, it would be a lot easier to switch between different groups of widgets by switching tabs.

– Dan W
Apr 20 '15 at 16:52





@Plutonix: Because in the designer, it would be a lot easier to switch between different groups of widgets by switching tabs.

– Dan W
Apr 20 '15 at 16:52













myPanelTabs(n).BringToFront Done. or mess with visible.

– None of the Above
Apr 20 '15 at 17:00







myPanelTabs(n).BringToFront Done. or mess with visible.

– None of the Above
Apr 20 '15 at 17:00






1




1





@Plutonix: That's code though, I want to be able to switch what's in a given area from the Forms designer with a single click actually while I'm in the Forms designer.

– Dan W
Apr 21 '15 at 21:25





@Plutonix: That's code though, I want to be able to switch what's in a given area from the Forms designer with a single click actually while I'm in the Forms designer.

– Dan W
Apr 21 '15 at 21:25













@MickyDuncan: The program as it appears to the user would be anything but a wizard. They only see one of the tabs according to the software version they choose, and the other tabs/pages are permanently inaccessible as they would be irrelevant. But yes, a developer could use the idea to implement a wizard type system.

– Dan W
Apr 23 '15 at 20:55







@MickyDuncan: The program as it appears to the user would be anything but a wizard. They only see one of the tabs according to the software version they choose, and the other tabs/pages are permanently inaccessible as they would be irrelevant. But yes, a developer could use the idea to implement a wizard type system.

– Dan W
Apr 23 '15 at 20:55














9 Answers
9






active

oldest

votes


















13














You can replace tabcontrol with a hand made panel that mimic like you want:



class MultiPagePanel : Panel
{
private int _currentPageIndex;
public int CurrentPageIndex
{
get { return _currentPageIndex; }
set
{
if (value >= 0 && value < Controls.Count)
{
Controls[value].BringToFront();
_currentPageIndex = value;
}
}
}

public void AddPage(Control page)
{
Controls.Add(page);
page.Dock = DockStyle.Fill;
}
}


And then add pages and set current visible page:



MultiPagePanel p;

// MyTabPage is a Control derived class that represents one page on your form.
MyTabPage page = new MyTabPage();
p.AddPage(page);

p.CurrentPageIndex = 0;





share|improve this answer


























  • Good idea, thank you :) but you defined public void AddPage(Control Page) and you use p.AddPage() without argument. how should i do to solve it ?!

    – Hossein Mobasher
    Aug 5 '11 at 9:07













  • Sorry, Chrome messed up my code. Fixed the sample.

    – Flexible TreeView Team
    Aug 5 '11 at 19:44











  • Thank you very much :)

    – Hossein Mobasher
    Aug 5 '11 at 20:42






  • 2





    just stumbled on this thread and found an error: if (value >= 0 && value < (Controls.Count - 1)) should be if (value >= 0 && value < Controls.Count). otherwise you will miss some panels.

    – benst
    Jul 2 '13 at 14:11



















93














Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. It shows the tabs at design time so you can easily switch between them while designing. They are hidden at runtime, use the SelectedTab or SelectedIndex property in your code to switch the page.



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);
}
}





share|improve this answer


























  • Thanks for your opinion :)

    – Hossein Mobasher
    Aug 5 '11 at 10:53






  • 22





    Erm, it's not an opinion. This works well on all Windows versions.

    – Hans Passant
    Aug 5 '11 at 10:57






  • 3





    Hi, could you update your code in the case where the left/right arrows disappear too? (They otherwise show when there are more tabs than can be contained by the StackPanel box). Thanks so much; being able to switch views like this on the fly is incredibly handy.

    – Dan W
    Jul 29 '12 at 22:11








  • 1





    Please edit your example from class TablessControl to public class TablessControl to make it show up in the Toolbox when using it from a different assembly.

    – Nebula
    Nov 29 '12 at 9:11






  • 1





    Probably. You could just set the SizeMode to Fixed and ItemSize.Width to 0 in OnHandleCreated if DesignMode is false. Never a problem that way.

    – Hans Passant
    Apr 17 '15 at 20:23



















19














tabControl1.Appearance = TabAppearance.FlatButtons;
tabControl1.ItemSize = new Size(0, 1);
tabControl1.SizeMode = TabSizeMode.Fixed;





share|improve this answer
























  • Avoid code only answers. Add some description about your solution.

    – ughai
    May 14 '15 at 8:55











  • That is by far the easiest way, that worked well for me.You could do it in the designer's properties if you wish.

    – dmihailescu
    Jul 31 '15 at 19:40











  • Solution that avoids creating a new inherited control. Nicely done.

    – Daniel
    Nov 9 '15 at 19:05











  • It's a shame that the very best answer to this has zero explanation behind it. You can set everything but ItemSize in the designer props and simply set the ItemSize on PageLoad. This should be the top answer IMHO. MS should just have this feature as an option though.

    – krowe2
    Jan 5 '16 at 16:41








  • 1





    Also, you'll probably want to use, tabControl1.TabStop = False;

    – krowe2
    Jan 5 '16 at 16:54



















16














Create new UserControl, name it for example TabControlWithoutHeader and change inherited UserControl to TabControl and add some code. Result code should look like:



public partial class TabControlWithoutHeader: TabControl
{
public TabControlWithoutHeader()
{
InitializeComponent();
}

protected override void WndProc(ref Message m)
{
if (m.Msg == 0x1328 && !DesignMode)
m.Result = (IntPtr)1;
else
base.WndProc(ref m);
}
}


After compile you will have TabControlWithoutHeader control in ToolBox. Drop it on form, in designer you will see headers, but at runtime they'll be hidden. If you want to hide them in designer too, then remove && !DesignMode.



Hope that helps.



http://social.msdn.microsoft.com/Forums/windows/en-US/c290832f-3b84-4200-aa4a-7a5dc4b8b5bb/tabs-in-winform?forum=winforms






share|improve this answer


























  • Thanks for your answer, it works very well :)

    – Hossein Mobasher
    Aug 5 '11 at 8:54








  • 1





    Attribution is required at SO.

    – Hans Passant
    Aug 5 '11 at 11:05






  • 2





    @Hans sorry I cant understand what you wrote

    – Reniuz
    Aug 5 '11 at 11:21








  • 2





    You maybe wrong Cody Gray, just check the time

    – volody
    Oct 31 '13 at 16:03






  • 1





    Ok I'am not a wizard to know who is creator of original code and especially who hides under different nickname in different site. So thank you @MatthewWatson for explanation what other where talking about. :)

    – Reniuz
    Mar 14 '14 at 11:40



















9














I was needing this code but in VB.net so I converted it. If someone needs this code in VB.Net there it is



Imports System
Imports System.Windows.Forms

Public Class TablessControl
Inherits System.Windows.Forms.TabControl

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
' Hide tabs by trapping the TCM_ADJUSTRECT message
If (m.Msg = Convert.ToInt32("0x1328", 16) And Not DesignMode) Then
m.Result = CType(1, IntPtr)
Else
MyBase.WndProc(m)
End If
End Sub

End Class


and thanks to @Hans Passant for the answer in C#






share|improve this answer































    5














    To complement Hans Passant's existing answer, I've found four ways to hide the arrows from the user when the numbers of tabs exceeds the width of the TablessControl. No single solution is necessarily perfect for everyone, but may be for you (or at least a combination of them).



    Solution 1:



    Simply enable Multiline. This will prevent the arrows from appearing in the first place. However, bear in mind, you may lose WYSIWYG in the designer because the vertical space will be adjusted downwards vertically, and controls within the TablessControl may even be 'chopped off' at the bottom (again, only in developer mode though).



    Solution 2:



    A more advanced solution which solves the WYSIWYG problem above is to only enable Multiline once the program gets running. Simply add this constructor to the TablessControl class:



    public TablessControl()
    {
    bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
    if (!designMode) Multiline = true;
    }


    To the developer, they will still appear as a single line of tabs.



    Solution 3:



    Decrease the font size of the TablessControl. Each tab should shrink accordingly. Since the user never gets to see the tabs, it shouldn't matter much if you set the font sizes to even 4pt.



    However be careful, because the TablessControl's contents may also be resized. If this happens, re-edit the font size for each widget inside, and at that point, they'll thankfully stay at that size even if you then decide to re-change the main TablessControl's font size again.



    This approach also has the advantage of more closely showing the true WYSIWYG vertical real-estate to the developer (which can look fine for the user, but may be cut off slightly at the bottom in the designer due to the height of the tabs).



    This solution can be combined with Solution 1 and 2 for accumulated advantages.



    Solution 4:



    This solution isn't necessarily so great if any of the tabs have text which are long. Thanks to Hans for suggesting it.



    First set the TablessControl's SizeMode to 'Fixed', and then reduce the TablessControl's ItemSize Width property to a smaller number to reduce each tab's width. Feel free also to adjust the ItemSize Height property to help address the aforementioned WYSIWYG issue, though Solution 3 may be more helpful for that problem.



    This solution can be combined with the above solutions to further accumulate advantages.






    share|improve this answer

































      4














      If you really want to do this, yo can do something like this



       tcActionControls.Region = new Region(new RectangleF(
      tbPageToShow.Left,
      tbPageToShow.Top,
      tbPageToShow.Width,
      tbPageToShow.Height)
      );


      Where tcActionControls is your TabControl and tbPageToShow is a TabPage to show in this precise moment.



      Should work for you.



      Regards.






      share|improve this answer































        1














        You can try removing the TabPage from the TabPageCollection :



        TabControl.TabPageCollection tabCol = tabControl1.TabPages;



                foreach (TabPage tp in tabCol)
        {
        if(condition)
        {
        tabCol.Remove(tp);
        }
        }





        share|improve this answer
























        • The question is about removing the HEADER ROW (containing the names of the tabs) at the top of the visible tab contents. This is not an answer to that question.

          – ToolmakerSteve
          May 20 '17 at 9:28











        • tabControl.Appearance = TabAppearance.FlatButtons; tabControl.ItemSize = new Size(0, 1); tabControl.SizeMode = TabSizeMode.Fixed; foreach (TabPage tab in tabControl.TabPages) { tab.Text = ""; }

          – marz
          Dec 8 '17 at 8:45



















        0














        This solution appears to work well -
        How to hide tabs in the tab control?




        1. Insert Tabcontrol into a form, the default name being tabcontrol1.



        2. Ensure that tabcontrol1 is selected in the Properties pane in visual studio and change the following properties:



          a. Set Appearance to Buttons



          b. Set ItemSize 0 for Width and 1 for Height



          c. Set Multiline to True



          d. Set SizeMode to Fixed




        This is best done after your have finished your design time tasks as it hides them in the designer as well - making it difficult to navigate!






        share|improve this answer

























          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6953487%2fhide-tab-header-on-c-sharp-tabcontrol%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          9 Answers
          9






          active

          oldest

          votes








          9 Answers
          9






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          13














          You can replace tabcontrol with a hand made panel that mimic like you want:



          class MultiPagePanel : Panel
          {
          private int _currentPageIndex;
          public int CurrentPageIndex
          {
          get { return _currentPageIndex; }
          set
          {
          if (value >= 0 && value < Controls.Count)
          {
          Controls[value].BringToFront();
          _currentPageIndex = value;
          }
          }
          }

          public void AddPage(Control page)
          {
          Controls.Add(page);
          page.Dock = DockStyle.Fill;
          }
          }


          And then add pages and set current visible page:



          MultiPagePanel p;

          // MyTabPage is a Control derived class that represents one page on your form.
          MyTabPage page = new MyTabPage();
          p.AddPage(page);

          p.CurrentPageIndex = 0;





          share|improve this answer


























          • Good idea, thank you :) but you defined public void AddPage(Control Page) and you use p.AddPage() without argument. how should i do to solve it ?!

            – Hossein Mobasher
            Aug 5 '11 at 9:07













          • Sorry, Chrome messed up my code. Fixed the sample.

            – Flexible TreeView Team
            Aug 5 '11 at 19:44











          • Thank you very much :)

            – Hossein Mobasher
            Aug 5 '11 at 20:42






          • 2





            just stumbled on this thread and found an error: if (value >= 0 && value < (Controls.Count - 1)) should be if (value >= 0 && value < Controls.Count). otherwise you will miss some panels.

            – benst
            Jul 2 '13 at 14:11
















          13














          You can replace tabcontrol with a hand made panel that mimic like you want:



          class MultiPagePanel : Panel
          {
          private int _currentPageIndex;
          public int CurrentPageIndex
          {
          get { return _currentPageIndex; }
          set
          {
          if (value >= 0 && value < Controls.Count)
          {
          Controls[value].BringToFront();
          _currentPageIndex = value;
          }
          }
          }

          public void AddPage(Control page)
          {
          Controls.Add(page);
          page.Dock = DockStyle.Fill;
          }
          }


          And then add pages and set current visible page:



          MultiPagePanel p;

          // MyTabPage is a Control derived class that represents one page on your form.
          MyTabPage page = new MyTabPage();
          p.AddPage(page);

          p.CurrentPageIndex = 0;





          share|improve this answer


























          • Good idea, thank you :) but you defined public void AddPage(Control Page) and you use p.AddPage() without argument. how should i do to solve it ?!

            – Hossein Mobasher
            Aug 5 '11 at 9:07













          • Sorry, Chrome messed up my code. Fixed the sample.

            – Flexible TreeView Team
            Aug 5 '11 at 19:44











          • Thank you very much :)

            – Hossein Mobasher
            Aug 5 '11 at 20:42






          • 2





            just stumbled on this thread and found an error: if (value >= 0 && value < (Controls.Count - 1)) should be if (value >= 0 && value < Controls.Count). otherwise you will miss some panels.

            – benst
            Jul 2 '13 at 14:11














          13












          13








          13







          You can replace tabcontrol with a hand made panel that mimic like you want:



          class MultiPagePanel : Panel
          {
          private int _currentPageIndex;
          public int CurrentPageIndex
          {
          get { return _currentPageIndex; }
          set
          {
          if (value >= 0 && value < Controls.Count)
          {
          Controls[value].BringToFront();
          _currentPageIndex = value;
          }
          }
          }

          public void AddPage(Control page)
          {
          Controls.Add(page);
          page.Dock = DockStyle.Fill;
          }
          }


          And then add pages and set current visible page:



          MultiPagePanel p;

          // MyTabPage is a Control derived class that represents one page on your form.
          MyTabPage page = new MyTabPage();
          p.AddPage(page);

          p.CurrentPageIndex = 0;





          share|improve this answer















          You can replace tabcontrol with a hand made panel that mimic like you want:



          class MultiPagePanel : Panel
          {
          private int _currentPageIndex;
          public int CurrentPageIndex
          {
          get { return _currentPageIndex; }
          set
          {
          if (value >= 0 && value < Controls.Count)
          {
          Controls[value].BringToFront();
          _currentPageIndex = value;
          }
          }
          }

          public void AddPage(Control page)
          {
          Controls.Add(page);
          page.Dock = DockStyle.Fill;
          }
          }


          And then add pages and set current visible page:



          MultiPagePanel p;

          // MyTabPage is a Control derived class that represents one page on your form.
          MyTabPage page = new MyTabPage();
          p.AddPage(page);

          p.CurrentPageIndex = 0;






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 22 '15 at 20:44









          Ark-kun

          4,1222042




          4,1222042










          answered Aug 5 '11 at 8:57









          Flexible TreeView TeamFlexible TreeView Team

          1914




          1914













          • Good idea, thank you :) but you defined public void AddPage(Control Page) and you use p.AddPage() without argument. how should i do to solve it ?!

            – Hossein Mobasher
            Aug 5 '11 at 9:07













          • Sorry, Chrome messed up my code. Fixed the sample.

            – Flexible TreeView Team
            Aug 5 '11 at 19:44











          • Thank you very much :)

            – Hossein Mobasher
            Aug 5 '11 at 20:42






          • 2





            just stumbled on this thread and found an error: if (value >= 0 && value < (Controls.Count - 1)) should be if (value >= 0 && value < Controls.Count). otherwise you will miss some panels.

            – benst
            Jul 2 '13 at 14:11



















          • Good idea, thank you :) but you defined public void AddPage(Control Page) and you use p.AddPage() without argument. how should i do to solve it ?!

            – Hossein Mobasher
            Aug 5 '11 at 9:07













          • Sorry, Chrome messed up my code. Fixed the sample.

            – Flexible TreeView Team
            Aug 5 '11 at 19:44











          • Thank you very much :)

            – Hossein Mobasher
            Aug 5 '11 at 20:42






          • 2





            just stumbled on this thread and found an error: if (value >= 0 && value < (Controls.Count - 1)) should be if (value >= 0 && value < Controls.Count). otherwise you will miss some panels.

            – benst
            Jul 2 '13 at 14:11

















          Good idea, thank you :) but you defined public void AddPage(Control Page) and you use p.AddPage() without argument. how should i do to solve it ?!

          – Hossein Mobasher
          Aug 5 '11 at 9:07







          Good idea, thank you :) but you defined public void AddPage(Control Page) and you use p.AddPage() without argument. how should i do to solve it ?!

          – Hossein Mobasher
          Aug 5 '11 at 9:07















          Sorry, Chrome messed up my code. Fixed the sample.

          – Flexible TreeView Team
          Aug 5 '11 at 19:44





          Sorry, Chrome messed up my code. Fixed the sample.

          – Flexible TreeView Team
          Aug 5 '11 at 19:44













          Thank you very much :)

          – Hossein Mobasher
          Aug 5 '11 at 20:42





          Thank you very much :)

          – Hossein Mobasher
          Aug 5 '11 at 20:42




          2




          2





          just stumbled on this thread and found an error: if (value >= 0 && value < (Controls.Count - 1)) should be if (value >= 0 && value < Controls.Count). otherwise you will miss some panels.

          – benst
          Jul 2 '13 at 14:11





          just stumbled on this thread and found an error: if (value >= 0 && value < (Controls.Count - 1)) should be if (value >= 0 && value < Controls.Count). otherwise you will miss some panels.

          – benst
          Jul 2 '13 at 14:11













          93














          Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. It shows the tabs at design time so you can easily switch between them while designing. They are hidden at runtime, use the SelectedTab or SelectedIndex property in your code to switch the page.



          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);
          }
          }





          share|improve this answer


























          • Thanks for your opinion :)

            – Hossein Mobasher
            Aug 5 '11 at 10:53






          • 22





            Erm, it's not an opinion. This works well on all Windows versions.

            – Hans Passant
            Aug 5 '11 at 10:57






          • 3





            Hi, could you update your code in the case where the left/right arrows disappear too? (They otherwise show when there are more tabs than can be contained by the StackPanel box). Thanks so much; being able to switch views like this on the fly is incredibly handy.

            – Dan W
            Jul 29 '12 at 22:11








          • 1





            Please edit your example from class TablessControl to public class TablessControl to make it show up in the Toolbox when using it from a different assembly.

            – Nebula
            Nov 29 '12 at 9:11






          • 1





            Probably. You could just set the SizeMode to Fixed and ItemSize.Width to 0 in OnHandleCreated if DesignMode is false. Never a problem that way.

            – Hans Passant
            Apr 17 '15 at 20:23
















          93














          Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. It shows the tabs at design time so you can easily switch between them while designing. They are hidden at runtime, use the SelectedTab or SelectedIndex property in your code to switch the page.



          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);
          }
          }





          share|improve this answer


























          • Thanks for your opinion :)

            – Hossein Mobasher
            Aug 5 '11 at 10:53






          • 22





            Erm, it's not an opinion. This works well on all Windows versions.

            – Hans Passant
            Aug 5 '11 at 10:57






          • 3





            Hi, could you update your code in the case where the left/right arrows disappear too? (They otherwise show when there are more tabs than can be contained by the StackPanel box). Thanks so much; being able to switch views like this on the fly is incredibly handy.

            – Dan W
            Jul 29 '12 at 22:11








          • 1





            Please edit your example from class TablessControl to public class TablessControl to make it show up in the Toolbox when using it from a different assembly.

            – Nebula
            Nov 29 '12 at 9:11






          • 1





            Probably. You could just set the SizeMode to Fixed and ItemSize.Width to 0 in OnHandleCreated if DesignMode is false. Never a problem that way.

            – Hans Passant
            Apr 17 '15 at 20:23














          93












          93








          93







          Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. It shows the tabs at design time so you can easily switch between them while designing. They are hidden at runtime, use the SelectedTab or SelectedIndex property in your code to switch the page.



          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);
          }
          }





          share|improve this answer















          Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. It shows the tabs at design time so you can easily switch between them while designing. They are hidden at runtime, use the SelectedTab or SelectedIndex property in your code to switch the page.



          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);
          }
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 23 '16 at 6:27

























          answered Aug 5 '11 at 10:18









          Hans PassantHans Passant

          788k10613012079




          788k10613012079













          • Thanks for your opinion :)

            – Hossein Mobasher
            Aug 5 '11 at 10:53






          • 22





            Erm, it's not an opinion. This works well on all Windows versions.

            – Hans Passant
            Aug 5 '11 at 10:57






          • 3





            Hi, could you update your code in the case where the left/right arrows disappear too? (They otherwise show when there are more tabs than can be contained by the StackPanel box). Thanks so much; being able to switch views like this on the fly is incredibly handy.

            – Dan W
            Jul 29 '12 at 22:11








          • 1





            Please edit your example from class TablessControl to public class TablessControl to make it show up in the Toolbox when using it from a different assembly.

            – Nebula
            Nov 29 '12 at 9:11






          • 1





            Probably. You could just set the SizeMode to Fixed and ItemSize.Width to 0 in OnHandleCreated if DesignMode is false. Never a problem that way.

            – Hans Passant
            Apr 17 '15 at 20:23



















          • Thanks for your opinion :)

            – Hossein Mobasher
            Aug 5 '11 at 10:53






          • 22





            Erm, it's not an opinion. This works well on all Windows versions.

            – Hans Passant
            Aug 5 '11 at 10:57






          • 3





            Hi, could you update your code in the case where the left/right arrows disappear too? (They otherwise show when there are more tabs than can be contained by the StackPanel box). Thanks so much; being able to switch views like this on the fly is incredibly handy.

            – Dan W
            Jul 29 '12 at 22:11








          • 1





            Please edit your example from class TablessControl to public class TablessControl to make it show up in the Toolbox when using it from a different assembly.

            – Nebula
            Nov 29 '12 at 9:11






          • 1





            Probably. You could just set the SizeMode to Fixed and ItemSize.Width to 0 in OnHandleCreated if DesignMode is false. Never a problem that way.

            – Hans Passant
            Apr 17 '15 at 20:23

















          Thanks for your opinion :)

          – Hossein Mobasher
          Aug 5 '11 at 10:53





          Thanks for your opinion :)

          – Hossein Mobasher
          Aug 5 '11 at 10:53




          22




          22





          Erm, it's not an opinion. This works well on all Windows versions.

          – Hans Passant
          Aug 5 '11 at 10:57





          Erm, it's not an opinion. This works well on all Windows versions.

          – Hans Passant
          Aug 5 '11 at 10:57




          3




          3





          Hi, could you update your code in the case where the left/right arrows disappear too? (They otherwise show when there are more tabs than can be contained by the StackPanel box). Thanks so much; being able to switch views like this on the fly is incredibly handy.

          – Dan W
          Jul 29 '12 at 22:11







          Hi, could you update your code in the case where the left/right arrows disappear too? (They otherwise show when there are more tabs than can be contained by the StackPanel box). Thanks so much; being able to switch views like this on the fly is incredibly handy.

          – Dan W
          Jul 29 '12 at 22:11






          1




          1





          Please edit your example from class TablessControl to public class TablessControl to make it show up in the Toolbox when using it from a different assembly.

          – Nebula
          Nov 29 '12 at 9:11





          Please edit your example from class TablessControl to public class TablessControl to make it show up in the Toolbox when using it from a different assembly.

          – Nebula
          Nov 29 '12 at 9:11




          1




          1





          Probably. You could just set the SizeMode to Fixed and ItemSize.Width to 0 in OnHandleCreated if DesignMode is false. Never a problem that way.

          – Hans Passant
          Apr 17 '15 at 20:23





          Probably. You could just set the SizeMode to Fixed and ItemSize.Width to 0 in OnHandleCreated if DesignMode is false. Never a problem that way.

          – Hans Passant
          Apr 17 '15 at 20:23











          19














          tabControl1.Appearance = TabAppearance.FlatButtons;
          tabControl1.ItemSize = new Size(0, 1);
          tabControl1.SizeMode = TabSizeMode.Fixed;





          share|improve this answer
























          • Avoid code only answers. Add some description about your solution.

            – ughai
            May 14 '15 at 8:55











          • That is by far the easiest way, that worked well for me.You could do it in the designer's properties if you wish.

            – dmihailescu
            Jul 31 '15 at 19:40











          • Solution that avoids creating a new inherited control. Nicely done.

            – Daniel
            Nov 9 '15 at 19:05











          • It's a shame that the very best answer to this has zero explanation behind it. You can set everything but ItemSize in the designer props and simply set the ItemSize on PageLoad. This should be the top answer IMHO. MS should just have this feature as an option though.

            – krowe2
            Jan 5 '16 at 16:41








          • 1





            Also, you'll probably want to use, tabControl1.TabStop = False;

            – krowe2
            Jan 5 '16 at 16:54
















          19














          tabControl1.Appearance = TabAppearance.FlatButtons;
          tabControl1.ItemSize = new Size(0, 1);
          tabControl1.SizeMode = TabSizeMode.Fixed;





          share|improve this answer
























          • Avoid code only answers. Add some description about your solution.

            – ughai
            May 14 '15 at 8:55











          • That is by far the easiest way, that worked well for me.You could do it in the designer's properties if you wish.

            – dmihailescu
            Jul 31 '15 at 19:40











          • Solution that avoids creating a new inherited control. Nicely done.

            – Daniel
            Nov 9 '15 at 19:05











          • It's a shame that the very best answer to this has zero explanation behind it. You can set everything but ItemSize in the designer props and simply set the ItemSize on PageLoad. This should be the top answer IMHO. MS should just have this feature as an option though.

            – krowe2
            Jan 5 '16 at 16:41








          • 1





            Also, you'll probably want to use, tabControl1.TabStop = False;

            – krowe2
            Jan 5 '16 at 16:54














          19












          19








          19







          tabControl1.Appearance = TabAppearance.FlatButtons;
          tabControl1.ItemSize = new Size(0, 1);
          tabControl1.SizeMode = TabSizeMode.Fixed;





          share|improve this answer













          tabControl1.Appearance = TabAppearance.FlatButtons;
          tabControl1.ItemSize = new Size(0, 1);
          tabControl1.SizeMode = TabSizeMode.Fixed;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 14 '15 at 7:05









          GeographGeograph

          8911012




          8911012













          • Avoid code only answers. Add some description about your solution.

            – ughai
            May 14 '15 at 8:55











          • That is by far the easiest way, that worked well for me.You could do it in the designer's properties if you wish.

            – dmihailescu
            Jul 31 '15 at 19:40











          • Solution that avoids creating a new inherited control. Nicely done.

            – Daniel
            Nov 9 '15 at 19:05











          • It's a shame that the very best answer to this has zero explanation behind it. You can set everything but ItemSize in the designer props and simply set the ItemSize on PageLoad. This should be the top answer IMHO. MS should just have this feature as an option though.

            – krowe2
            Jan 5 '16 at 16:41








          • 1





            Also, you'll probably want to use, tabControl1.TabStop = False;

            – krowe2
            Jan 5 '16 at 16:54



















          • Avoid code only answers. Add some description about your solution.

            – ughai
            May 14 '15 at 8:55











          • That is by far the easiest way, that worked well for me.You could do it in the designer's properties if you wish.

            – dmihailescu
            Jul 31 '15 at 19:40











          • Solution that avoids creating a new inherited control. Nicely done.

            – Daniel
            Nov 9 '15 at 19:05











          • It's a shame that the very best answer to this has zero explanation behind it. You can set everything but ItemSize in the designer props and simply set the ItemSize on PageLoad. This should be the top answer IMHO. MS should just have this feature as an option though.

            – krowe2
            Jan 5 '16 at 16:41








          • 1





            Also, you'll probably want to use, tabControl1.TabStop = False;

            – krowe2
            Jan 5 '16 at 16:54

















          Avoid code only answers. Add some description about your solution.

          – ughai
          May 14 '15 at 8:55





          Avoid code only answers. Add some description about your solution.

          – ughai
          May 14 '15 at 8:55













          That is by far the easiest way, that worked well for me.You could do it in the designer's properties if you wish.

          – dmihailescu
          Jul 31 '15 at 19:40





          That is by far the easiest way, that worked well for me.You could do it in the designer's properties if you wish.

          – dmihailescu
          Jul 31 '15 at 19:40













          Solution that avoids creating a new inherited control. Nicely done.

          – Daniel
          Nov 9 '15 at 19:05





          Solution that avoids creating a new inherited control. Nicely done.

          – Daniel
          Nov 9 '15 at 19:05













          It's a shame that the very best answer to this has zero explanation behind it. You can set everything but ItemSize in the designer props and simply set the ItemSize on PageLoad. This should be the top answer IMHO. MS should just have this feature as an option though.

          – krowe2
          Jan 5 '16 at 16:41







          It's a shame that the very best answer to this has zero explanation behind it. You can set everything but ItemSize in the designer props and simply set the ItemSize on PageLoad. This should be the top answer IMHO. MS should just have this feature as an option though.

          – krowe2
          Jan 5 '16 at 16:41






          1




          1





          Also, you'll probably want to use, tabControl1.TabStop = False;

          – krowe2
          Jan 5 '16 at 16:54





          Also, you'll probably want to use, tabControl1.TabStop = False;

          – krowe2
          Jan 5 '16 at 16:54











          16














          Create new UserControl, name it for example TabControlWithoutHeader and change inherited UserControl to TabControl and add some code. Result code should look like:



          public partial class TabControlWithoutHeader: TabControl
          {
          public TabControlWithoutHeader()
          {
          InitializeComponent();
          }

          protected override void WndProc(ref Message m)
          {
          if (m.Msg == 0x1328 && !DesignMode)
          m.Result = (IntPtr)1;
          else
          base.WndProc(ref m);
          }
          }


          After compile you will have TabControlWithoutHeader control in ToolBox. Drop it on form, in designer you will see headers, but at runtime they'll be hidden. If you want to hide them in designer too, then remove && !DesignMode.



          Hope that helps.



          http://social.msdn.microsoft.com/Forums/windows/en-US/c290832f-3b84-4200-aa4a-7a5dc4b8b5bb/tabs-in-winform?forum=winforms






          share|improve this answer


























          • Thanks for your answer, it works very well :)

            – Hossein Mobasher
            Aug 5 '11 at 8:54








          • 1





            Attribution is required at SO.

            – Hans Passant
            Aug 5 '11 at 11:05






          • 2





            @Hans sorry I cant understand what you wrote

            – Reniuz
            Aug 5 '11 at 11:21








          • 2





            You maybe wrong Cody Gray, just check the time

            – volody
            Oct 31 '13 at 16:03






          • 1





            Ok I'am not a wizard to know who is creator of original code and especially who hides under different nickname in different site. So thank you @MatthewWatson for explanation what other where talking about. :)

            – Reniuz
            Mar 14 '14 at 11:40
















          16














          Create new UserControl, name it for example TabControlWithoutHeader and change inherited UserControl to TabControl and add some code. Result code should look like:



          public partial class TabControlWithoutHeader: TabControl
          {
          public TabControlWithoutHeader()
          {
          InitializeComponent();
          }

          protected override void WndProc(ref Message m)
          {
          if (m.Msg == 0x1328 && !DesignMode)
          m.Result = (IntPtr)1;
          else
          base.WndProc(ref m);
          }
          }


          After compile you will have TabControlWithoutHeader control in ToolBox. Drop it on form, in designer you will see headers, but at runtime they'll be hidden. If you want to hide them in designer too, then remove && !DesignMode.



          Hope that helps.



          http://social.msdn.microsoft.com/Forums/windows/en-US/c290832f-3b84-4200-aa4a-7a5dc4b8b5bb/tabs-in-winform?forum=winforms






          share|improve this answer


























          • Thanks for your answer, it works very well :)

            – Hossein Mobasher
            Aug 5 '11 at 8:54








          • 1





            Attribution is required at SO.

            – Hans Passant
            Aug 5 '11 at 11:05






          • 2





            @Hans sorry I cant understand what you wrote

            – Reniuz
            Aug 5 '11 at 11:21








          • 2





            You maybe wrong Cody Gray, just check the time

            – volody
            Oct 31 '13 at 16:03






          • 1





            Ok I'am not a wizard to know who is creator of original code and especially who hides under different nickname in different site. So thank you @MatthewWatson for explanation what other where talking about. :)

            – Reniuz
            Mar 14 '14 at 11:40














          16












          16








          16







          Create new UserControl, name it for example TabControlWithoutHeader and change inherited UserControl to TabControl and add some code. Result code should look like:



          public partial class TabControlWithoutHeader: TabControl
          {
          public TabControlWithoutHeader()
          {
          InitializeComponent();
          }

          protected override void WndProc(ref Message m)
          {
          if (m.Msg == 0x1328 && !DesignMode)
          m.Result = (IntPtr)1;
          else
          base.WndProc(ref m);
          }
          }


          After compile you will have TabControlWithoutHeader control in ToolBox. Drop it on form, in designer you will see headers, but at runtime they'll be hidden. If you want to hide them in designer too, then remove && !DesignMode.



          Hope that helps.



          http://social.msdn.microsoft.com/Forums/windows/en-US/c290832f-3b84-4200-aa4a-7a5dc4b8b5bb/tabs-in-winform?forum=winforms






          share|improve this answer















          Create new UserControl, name it for example TabControlWithoutHeader and change inherited UserControl to TabControl and add some code. Result code should look like:



          public partial class TabControlWithoutHeader: TabControl
          {
          public TabControlWithoutHeader()
          {
          InitializeComponent();
          }

          protected override void WndProc(ref Message m)
          {
          if (m.Msg == 0x1328 && !DesignMode)
          m.Result = (IntPtr)1;
          else
          base.WndProc(ref m);
          }
          }


          After compile you will have TabControlWithoutHeader control in ToolBox. Drop it on form, in designer you will see headers, but at runtime they'll be hidden. If you want to hide them in designer too, then remove && !DesignMode.



          Hope that helps.



          http://social.msdn.microsoft.com/Forums/windows/en-US/c290832f-3b84-4200-aa4a-7a5dc4b8b5bb/tabs-in-winform?forum=winforms







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 30 '14 at 15:58









          benblasdell

          169311




          169311










          answered Aug 5 '11 at 8:48









          ReniuzReniuz

          10.2k13555




          10.2k13555













          • Thanks for your answer, it works very well :)

            – Hossein Mobasher
            Aug 5 '11 at 8:54








          • 1





            Attribution is required at SO.

            – Hans Passant
            Aug 5 '11 at 11:05






          • 2





            @Hans sorry I cant understand what you wrote

            – Reniuz
            Aug 5 '11 at 11:21








          • 2





            You maybe wrong Cody Gray, just check the time

            – volody
            Oct 31 '13 at 16:03






          • 1





            Ok I'am not a wizard to know who is creator of original code and especially who hides under different nickname in different site. So thank you @MatthewWatson for explanation what other where talking about. :)

            – Reniuz
            Mar 14 '14 at 11:40



















          • Thanks for your answer, it works very well :)

            – Hossein Mobasher
            Aug 5 '11 at 8:54








          • 1





            Attribution is required at SO.

            – Hans Passant
            Aug 5 '11 at 11:05






          • 2





            @Hans sorry I cant understand what you wrote

            – Reniuz
            Aug 5 '11 at 11:21








          • 2





            You maybe wrong Cody Gray, just check the time

            – volody
            Oct 31 '13 at 16:03






          • 1





            Ok I'am not a wizard to know who is creator of original code and especially who hides under different nickname in different site. So thank you @MatthewWatson for explanation what other where talking about. :)

            – Reniuz
            Mar 14 '14 at 11:40

















          Thanks for your answer, it works very well :)

          – Hossein Mobasher
          Aug 5 '11 at 8:54







          Thanks for your answer, it works very well :)

          – Hossein Mobasher
          Aug 5 '11 at 8:54






          1




          1





          Attribution is required at SO.

          – Hans Passant
          Aug 5 '11 at 11:05





          Attribution is required at SO.

          – Hans Passant
          Aug 5 '11 at 11:05




          2




          2





          @Hans sorry I cant understand what you wrote

          – Reniuz
          Aug 5 '11 at 11:21







          @Hans sorry I cant understand what you wrote

          – Reniuz
          Aug 5 '11 at 11:21






          2




          2





          You maybe wrong Cody Gray, just check the time

          – volody
          Oct 31 '13 at 16:03





          You maybe wrong Cody Gray, just check the time

          – volody
          Oct 31 '13 at 16:03




          1




          1





          Ok I'am not a wizard to know who is creator of original code and especially who hides under different nickname in different site. So thank you @MatthewWatson for explanation what other where talking about. :)

          – Reniuz
          Mar 14 '14 at 11:40





          Ok I'am not a wizard to know who is creator of original code and especially who hides under different nickname in different site. So thank you @MatthewWatson for explanation what other where talking about. :)

          – Reniuz
          Mar 14 '14 at 11:40











          9














          I was needing this code but in VB.net so I converted it. If someone needs this code in VB.Net there it is



          Imports System
          Imports System.Windows.Forms

          Public Class TablessControl
          Inherits System.Windows.Forms.TabControl

          Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
          ' Hide tabs by trapping the TCM_ADJUSTRECT message
          If (m.Msg = Convert.ToInt32("0x1328", 16) And Not DesignMode) Then
          m.Result = CType(1, IntPtr)
          Else
          MyBase.WndProc(m)
          End If
          End Sub

          End Class


          and thanks to @Hans Passant for the answer in C#






          share|improve this answer




























            9














            I was needing this code but in VB.net so I converted it. If someone needs this code in VB.Net there it is



            Imports System
            Imports System.Windows.Forms

            Public Class TablessControl
            Inherits System.Windows.Forms.TabControl

            Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
            ' Hide tabs by trapping the TCM_ADJUSTRECT message
            If (m.Msg = Convert.ToInt32("0x1328", 16) And Not DesignMode) Then
            m.Result = CType(1, IntPtr)
            Else
            MyBase.WndProc(m)
            End If
            End Sub

            End Class


            and thanks to @Hans Passant for the answer in C#






            share|improve this answer


























              9












              9








              9







              I was needing this code but in VB.net so I converted it. If someone needs this code in VB.Net there it is



              Imports System
              Imports System.Windows.Forms

              Public Class TablessControl
              Inherits System.Windows.Forms.TabControl

              Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
              ' Hide tabs by trapping the TCM_ADJUSTRECT message
              If (m.Msg = Convert.ToInt32("0x1328", 16) And Not DesignMode) Then
              m.Result = CType(1, IntPtr)
              Else
              MyBase.WndProc(m)
              End If
              End Sub

              End Class


              and thanks to @Hans Passant for the answer in C#






              share|improve this answer













              I was needing this code but in VB.net so I converted it. If someone needs this code in VB.Net there it is



              Imports System
              Imports System.Windows.Forms

              Public Class TablessControl
              Inherits System.Windows.Forms.TabControl

              Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
              ' Hide tabs by trapping the TCM_ADJUSTRECT message
              If (m.Msg = Convert.ToInt32("0x1328", 16) And Not DesignMode) Then
              m.Result = CType(1, IntPtr)
              Else
              MyBase.WndProc(m)
              End If
              End Sub

              End Class


              and thanks to @Hans Passant for the answer in C#







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Oct 8 '12 at 10:40









              abottoniabottoni

              3401918




              3401918























                  5














                  To complement Hans Passant's existing answer, I've found four ways to hide the arrows from the user when the numbers of tabs exceeds the width of the TablessControl. No single solution is necessarily perfect for everyone, but may be for you (or at least a combination of them).



                  Solution 1:



                  Simply enable Multiline. This will prevent the arrows from appearing in the first place. However, bear in mind, you may lose WYSIWYG in the designer because the vertical space will be adjusted downwards vertically, and controls within the TablessControl may even be 'chopped off' at the bottom (again, only in developer mode though).



                  Solution 2:



                  A more advanced solution which solves the WYSIWYG problem above is to only enable Multiline once the program gets running. Simply add this constructor to the TablessControl class:



                  public TablessControl()
                  {
                  bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
                  if (!designMode) Multiline = true;
                  }


                  To the developer, they will still appear as a single line of tabs.



                  Solution 3:



                  Decrease the font size of the TablessControl. Each tab should shrink accordingly. Since the user never gets to see the tabs, it shouldn't matter much if you set the font sizes to even 4pt.



                  However be careful, because the TablessControl's contents may also be resized. If this happens, re-edit the font size for each widget inside, and at that point, they'll thankfully stay at that size even if you then decide to re-change the main TablessControl's font size again.



                  This approach also has the advantage of more closely showing the true WYSIWYG vertical real-estate to the developer (which can look fine for the user, but may be cut off slightly at the bottom in the designer due to the height of the tabs).



                  This solution can be combined with Solution 1 and 2 for accumulated advantages.



                  Solution 4:



                  This solution isn't necessarily so great if any of the tabs have text which are long. Thanks to Hans for suggesting it.



                  First set the TablessControl's SizeMode to 'Fixed', and then reduce the TablessControl's ItemSize Width property to a smaller number to reduce each tab's width. Feel free also to adjust the ItemSize Height property to help address the aforementioned WYSIWYG issue, though Solution 3 may be more helpful for that problem.



                  This solution can be combined with the above solutions to further accumulate advantages.






                  share|improve this answer






























                    5














                    To complement Hans Passant's existing answer, I've found four ways to hide the arrows from the user when the numbers of tabs exceeds the width of the TablessControl. No single solution is necessarily perfect for everyone, but may be for you (or at least a combination of them).



                    Solution 1:



                    Simply enable Multiline. This will prevent the arrows from appearing in the first place. However, bear in mind, you may lose WYSIWYG in the designer because the vertical space will be adjusted downwards vertically, and controls within the TablessControl may even be 'chopped off' at the bottom (again, only in developer mode though).



                    Solution 2:



                    A more advanced solution which solves the WYSIWYG problem above is to only enable Multiline once the program gets running. Simply add this constructor to the TablessControl class:



                    public TablessControl()
                    {
                    bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
                    if (!designMode) Multiline = true;
                    }


                    To the developer, they will still appear as a single line of tabs.



                    Solution 3:



                    Decrease the font size of the TablessControl. Each tab should shrink accordingly. Since the user never gets to see the tabs, it shouldn't matter much if you set the font sizes to even 4pt.



                    However be careful, because the TablessControl's contents may also be resized. If this happens, re-edit the font size for each widget inside, and at that point, they'll thankfully stay at that size even if you then decide to re-change the main TablessControl's font size again.



                    This approach also has the advantage of more closely showing the true WYSIWYG vertical real-estate to the developer (which can look fine for the user, but may be cut off slightly at the bottom in the designer due to the height of the tabs).



                    This solution can be combined with Solution 1 and 2 for accumulated advantages.



                    Solution 4:



                    This solution isn't necessarily so great if any of the tabs have text which are long. Thanks to Hans for suggesting it.



                    First set the TablessControl's SizeMode to 'Fixed', and then reduce the TablessControl's ItemSize Width property to a smaller number to reduce each tab's width. Feel free also to adjust the ItemSize Height property to help address the aforementioned WYSIWYG issue, though Solution 3 may be more helpful for that problem.



                    This solution can be combined with the above solutions to further accumulate advantages.






                    share|improve this answer




























                      5












                      5








                      5







                      To complement Hans Passant's existing answer, I've found four ways to hide the arrows from the user when the numbers of tabs exceeds the width of the TablessControl. No single solution is necessarily perfect for everyone, but may be for you (or at least a combination of them).



                      Solution 1:



                      Simply enable Multiline. This will prevent the arrows from appearing in the first place. However, bear in mind, you may lose WYSIWYG in the designer because the vertical space will be adjusted downwards vertically, and controls within the TablessControl may even be 'chopped off' at the bottom (again, only in developer mode though).



                      Solution 2:



                      A more advanced solution which solves the WYSIWYG problem above is to only enable Multiline once the program gets running. Simply add this constructor to the TablessControl class:



                      public TablessControl()
                      {
                      bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
                      if (!designMode) Multiline = true;
                      }


                      To the developer, they will still appear as a single line of tabs.



                      Solution 3:



                      Decrease the font size of the TablessControl. Each tab should shrink accordingly. Since the user never gets to see the tabs, it shouldn't matter much if you set the font sizes to even 4pt.



                      However be careful, because the TablessControl's contents may also be resized. If this happens, re-edit the font size for each widget inside, and at that point, they'll thankfully stay at that size even if you then decide to re-change the main TablessControl's font size again.



                      This approach also has the advantage of more closely showing the true WYSIWYG vertical real-estate to the developer (which can look fine for the user, but may be cut off slightly at the bottom in the designer due to the height of the tabs).



                      This solution can be combined with Solution 1 and 2 for accumulated advantages.



                      Solution 4:



                      This solution isn't necessarily so great if any of the tabs have text which are long. Thanks to Hans for suggesting it.



                      First set the TablessControl's SizeMode to 'Fixed', and then reduce the TablessControl's ItemSize Width property to a smaller number to reduce each tab's width. Feel free also to adjust the ItemSize Height property to help address the aforementioned WYSIWYG issue, though Solution 3 may be more helpful for that problem.



                      This solution can be combined with the above solutions to further accumulate advantages.






                      share|improve this answer















                      To complement Hans Passant's existing answer, I've found four ways to hide the arrows from the user when the numbers of tabs exceeds the width of the TablessControl. No single solution is necessarily perfect for everyone, but may be for you (or at least a combination of them).



                      Solution 1:



                      Simply enable Multiline. This will prevent the arrows from appearing in the first place. However, bear in mind, you may lose WYSIWYG in the designer because the vertical space will be adjusted downwards vertically, and controls within the TablessControl may even be 'chopped off' at the bottom (again, only in developer mode though).



                      Solution 2:



                      A more advanced solution which solves the WYSIWYG problem above is to only enable Multiline once the program gets running. Simply add this constructor to the TablessControl class:



                      public TablessControl()
                      {
                      bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
                      if (!designMode) Multiline = true;
                      }


                      To the developer, they will still appear as a single line of tabs.



                      Solution 3:



                      Decrease the font size of the TablessControl. Each tab should shrink accordingly. Since the user never gets to see the tabs, it shouldn't matter much if you set the font sizes to even 4pt.



                      However be careful, because the TablessControl's contents may also be resized. If this happens, re-edit the font size for each widget inside, and at that point, they'll thankfully stay at that size even if you then decide to re-change the main TablessControl's font size again.



                      This approach also has the advantage of more closely showing the true WYSIWYG vertical real-estate to the developer (which can look fine for the user, but may be cut off slightly at the bottom in the designer due to the height of the tabs).



                      This solution can be combined with Solution 1 and 2 for accumulated advantages.



                      Solution 4:



                      This solution isn't necessarily so great if any of the tabs have text which are long. Thanks to Hans for suggesting it.



                      First set the TablessControl's SizeMode to 'Fixed', and then reduce the TablessControl's ItemSize Width property to a smaller number to reduce each tab's width. Feel free also to adjust the ItemSize Height property to help address the aforementioned WYSIWYG issue, though Solution 3 may be more helpful for that problem.



                      This solution can be combined with the above solutions to further accumulate advantages.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Apr 17 '15 at 21:15

























                      answered Apr 17 '15 at 18:27









                      Dan WDan W

                      1,43132754




                      1,43132754























                          4














                          If you really want to do this, yo can do something like this



                           tcActionControls.Region = new Region(new RectangleF(
                          tbPageToShow.Left,
                          tbPageToShow.Top,
                          tbPageToShow.Width,
                          tbPageToShow.Height)
                          );


                          Where tcActionControls is your TabControl and tbPageToShow is a TabPage to show in this precise moment.



                          Should work for you.



                          Regards.






                          share|improve this answer




























                            4














                            If you really want to do this, yo can do something like this



                             tcActionControls.Region = new Region(new RectangleF(
                            tbPageToShow.Left,
                            tbPageToShow.Top,
                            tbPageToShow.Width,
                            tbPageToShow.Height)
                            );


                            Where tcActionControls is your TabControl and tbPageToShow is a TabPage to show in this precise moment.



                            Should work for you.



                            Regards.






                            share|improve this answer


























                              4












                              4








                              4







                              If you really want to do this, yo can do something like this



                               tcActionControls.Region = new Region(new RectangleF(
                              tbPageToShow.Left,
                              tbPageToShow.Top,
                              tbPageToShow.Width,
                              tbPageToShow.Height)
                              );


                              Where tcActionControls is your TabControl and tbPageToShow is a TabPage to show in this precise moment.



                              Should work for you.



                              Regards.






                              share|improve this answer













                              If you really want to do this, yo can do something like this



                               tcActionControls.Region = new Region(new RectangleF(
                              tbPageToShow.Left,
                              tbPageToShow.Top,
                              tbPageToShow.Width,
                              tbPageToShow.Height)
                              );


                              Where tcActionControls is your TabControl and tbPageToShow is a TabPage to show in this precise moment.



                              Should work for you.



                              Regards.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Aug 5 '11 at 8:42









                              TigranTigran

                              55.2k569103




                              55.2k569103























                                  1














                                  You can try removing the TabPage from the TabPageCollection :



                                  TabControl.TabPageCollection tabCol = tabControl1.TabPages;



                                          foreach (TabPage tp in tabCol)
                                  {
                                  if(condition)
                                  {
                                  tabCol.Remove(tp);
                                  }
                                  }





                                  share|improve this answer
























                                  • The question is about removing the HEADER ROW (containing the names of the tabs) at the top of the visible tab contents. This is not an answer to that question.

                                    – ToolmakerSteve
                                    May 20 '17 at 9:28











                                  • tabControl.Appearance = TabAppearance.FlatButtons; tabControl.ItemSize = new Size(0, 1); tabControl.SizeMode = TabSizeMode.Fixed; foreach (TabPage tab in tabControl.TabPages) { tab.Text = ""; }

                                    – marz
                                    Dec 8 '17 at 8:45
















                                  1














                                  You can try removing the TabPage from the TabPageCollection :



                                  TabControl.TabPageCollection tabCol = tabControl1.TabPages;



                                          foreach (TabPage tp in tabCol)
                                  {
                                  if(condition)
                                  {
                                  tabCol.Remove(tp);
                                  }
                                  }





                                  share|improve this answer
























                                  • The question is about removing the HEADER ROW (containing the names of the tabs) at the top of the visible tab contents. This is not an answer to that question.

                                    – ToolmakerSteve
                                    May 20 '17 at 9:28











                                  • tabControl.Appearance = TabAppearance.FlatButtons; tabControl.ItemSize = new Size(0, 1); tabControl.SizeMode = TabSizeMode.Fixed; foreach (TabPage tab in tabControl.TabPages) { tab.Text = ""; }

                                    – marz
                                    Dec 8 '17 at 8:45














                                  1












                                  1








                                  1







                                  You can try removing the TabPage from the TabPageCollection :



                                  TabControl.TabPageCollection tabCol = tabControl1.TabPages;



                                          foreach (TabPage tp in tabCol)
                                  {
                                  if(condition)
                                  {
                                  tabCol.Remove(tp);
                                  }
                                  }





                                  share|improve this answer













                                  You can try removing the TabPage from the TabPageCollection :



                                  TabControl.TabPageCollection tabCol = tabControl1.TabPages;



                                          foreach (TabPage tp in tabCol)
                                  {
                                  if(condition)
                                  {
                                  tabCol.Remove(tp);
                                  }
                                  }






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Jan 20 '16 at 14:44









                                  marzmarz

                                  112




                                  112













                                  • The question is about removing the HEADER ROW (containing the names of the tabs) at the top of the visible tab contents. This is not an answer to that question.

                                    – ToolmakerSteve
                                    May 20 '17 at 9:28











                                  • tabControl.Appearance = TabAppearance.FlatButtons; tabControl.ItemSize = new Size(0, 1); tabControl.SizeMode = TabSizeMode.Fixed; foreach (TabPage tab in tabControl.TabPages) { tab.Text = ""; }

                                    – marz
                                    Dec 8 '17 at 8:45



















                                  • The question is about removing the HEADER ROW (containing the names of the tabs) at the top of the visible tab contents. This is not an answer to that question.

                                    – ToolmakerSteve
                                    May 20 '17 at 9:28











                                  • tabControl.Appearance = TabAppearance.FlatButtons; tabControl.ItemSize = new Size(0, 1); tabControl.SizeMode = TabSizeMode.Fixed; foreach (TabPage tab in tabControl.TabPages) { tab.Text = ""; }

                                    – marz
                                    Dec 8 '17 at 8:45

















                                  The question is about removing the HEADER ROW (containing the names of the tabs) at the top of the visible tab contents. This is not an answer to that question.

                                  – ToolmakerSteve
                                  May 20 '17 at 9:28





                                  The question is about removing the HEADER ROW (containing the names of the tabs) at the top of the visible tab contents. This is not an answer to that question.

                                  – ToolmakerSteve
                                  May 20 '17 at 9:28













                                  tabControl.Appearance = TabAppearance.FlatButtons; tabControl.ItemSize = new Size(0, 1); tabControl.SizeMode = TabSizeMode.Fixed; foreach (TabPage tab in tabControl.TabPages) { tab.Text = ""; }

                                  – marz
                                  Dec 8 '17 at 8:45





                                  tabControl.Appearance = TabAppearance.FlatButtons; tabControl.ItemSize = new Size(0, 1); tabControl.SizeMode = TabSizeMode.Fixed; foreach (TabPage tab in tabControl.TabPages) { tab.Text = ""; }

                                  – marz
                                  Dec 8 '17 at 8:45











                                  0














                                  This solution appears to work well -
                                  How to hide tabs in the tab control?




                                  1. Insert Tabcontrol into a form, the default name being tabcontrol1.



                                  2. Ensure that tabcontrol1 is selected in the Properties pane in visual studio and change the following properties:



                                    a. Set Appearance to Buttons



                                    b. Set ItemSize 0 for Width and 1 for Height



                                    c. Set Multiline to True



                                    d. Set SizeMode to Fixed




                                  This is best done after your have finished your design time tasks as it hides them in the designer as well - making it difficult to navigate!






                                  share|improve this answer






























                                    0














                                    This solution appears to work well -
                                    How to hide tabs in the tab control?




                                    1. Insert Tabcontrol into a form, the default name being tabcontrol1.



                                    2. Ensure that tabcontrol1 is selected in the Properties pane in visual studio and change the following properties:



                                      a. Set Appearance to Buttons



                                      b. Set ItemSize 0 for Width and 1 for Height



                                      c. Set Multiline to True



                                      d. Set SizeMode to Fixed




                                    This is best done after your have finished your design time tasks as it hides them in the designer as well - making it difficult to navigate!






                                    share|improve this answer




























                                      0












                                      0








                                      0







                                      This solution appears to work well -
                                      How to hide tabs in the tab control?




                                      1. Insert Tabcontrol into a form, the default name being tabcontrol1.



                                      2. Ensure that tabcontrol1 is selected in the Properties pane in visual studio and change the following properties:



                                        a. Set Appearance to Buttons



                                        b. Set ItemSize 0 for Width and 1 for Height



                                        c. Set Multiline to True



                                        d. Set SizeMode to Fixed




                                      This is best done after your have finished your design time tasks as it hides them in the designer as well - making it difficult to navigate!






                                      share|improve this answer















                                      This solution appears to work well -
                                      How to hide tabs in the tab control?




                                      1. Insert Tabcontrol into a form, the default name being tabcontrol1.



                                      2. Ensure that tabcontrol1 is selected in the Properties pane in visual studio and change the following properties:



                                        a. Set Appearance to Buttons



                                        b. Set ItemSize 0 for Width and 1 for Height



                                        c. Set Multiline to True



                                        d. Set SizeMode to Fixed




                                      This is best done after your have finished your design time tasks as it hides them in the designer as well - making it difficult to navigate!







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Nov 26 '18 at 3:29









                                      Stephen Rauch

                                      28.7k153557




                                      28.7k153557










                                      answered Nov 26 '18 at 3:05









                                      Adrian BrownAdrian Brown

                                      338




                                      338






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6953487%2fhide-tab-header-on-c-sharp-tabcontrol%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                                          Calculate evaluation metrics using cross_val_predict sklearn

                                          Insert data from modal to MySQL (multiple modal on website)