Search code examples
c++c++buildervcltpagecontrol

How can I hide the header of the PageControl TabSheets in C++ Builder


I wonder how can I hide the headers of the TabSheets in PageControl component. I want make a creator e.g to build your champion where you can choose some stuff on the pages. TabSheets will be change every 10 s by Timer. In Google I can find only how hide TabSheet(with contents). I want hide only header of the TabSheets e.gTabSheet1 and so on. I'm working in C++ Builder. Greetings,


Solution

  • You can hide every page of the TPageControl (TabVisible property of the TabSheet) and you can still show the Tabsheet in code, by changing the ActivePage or ActivePageIndex properties of the page control.

    The Timer can call the SelectNextPage method to programmatically change the active page:

    PageControl1->SelectNextPage(true, false);
    

    EDIT

    A simple form (Form1) with a TPageControl (as appears in the designer):

    TPageControl in the designer

    The code to hide the header:

    void __fastcall TForm1::FormShow(TObject *Sender)
    {
      for (int i(0); i < PageControl1->PageCount; ++i)
        PageControl1->Pages[i]->TabVisible = false;
    
      // You can show the TabSheet programmatically changing the active page.
      PageControl1->ActivePage = TabSheet1;
    }
    

    The code to select the next page:

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
      PageControl1->SelectNextPage(true, false);
    }
    

    The wizard-like effect (at runtime):

    enter image description here


    Recent versions of C++Builder have the TCardPanel control. It's a set of pages, like the TPageControl, with no tabs. You display one page at a time (each hosting its own controls) and it has built in support for swiping pages using a gesture.