How to Hide the Tabs of the TPageControl Delphi Control

Create a wizard-like user interface

Hide TPageControl Tabs.

The TPageControl Delphi control displays a set of pages used to make a multiple-page dialog box. Each page — a tab sheet — hosts its own controls. The user selects a page (makes it visible) by clicking the page’s tab that appears at the top of the control.

Hiding PageControl Tabs

If you need to create a wizard-like user interface where you have Next and Previous buttons appearing to move a user forward and backward through a set of pages (dialogs), hide the tabs of the PageControl and thus disallow selecting a particular page by means of the user's mouse.

The trick is in setting the TabVisible property to false for each of the sheets (TTabSheet object) of the page control.

Activating the page by using either the ActivePage or the ActivePageIndex PageControl properties will not raise the OnChange and OnChanging events.

To programmatically set the active page, use the SelectNextPage method:

 //Hide PageControl Tabs
page : integer;
for page := 0 to PageControl1.PageCount - 1 do
PageControl1.Pages[page].TabVisible := false;
//select the first tab
PageControl1.ActivePageIndex := 0;
Or set Active Page directly
PageControl1.ActivePage := TabSheet1;
Note: the above two do NOT raise the
OnChanging and OnChange events
procedure TForm1.PageControl1Changing(
Sender: TObject;
var AllowChange: Boolean) ;
//no change if on the last page
AllowChange := PageControl1.ActivePageIndex < -1 + PageControl1.PageCount;
//Select "Previous" Tabprocedure TForm1.PreviousPageButtonClick(Sender: TObject) ;
PageControl1.SelectNextPage(false,false) ;
//Select "Next" Tabprocedure TForm1.NextPageButtonClick(Sender: TObject) ;
PageControl1.SelectNextPage(true,false) ;

Using this technique will de-clutter the form, leading to a more streamlined interface, but ensure that the arrangement of controls on each tab doesn't force the user to move frequently between tabs.

mla apa chicago
Your Citation
Gajic, Zarko. "How to Hide the Tabs of the TPageControl Delphi Control." ThoughtCo, Aug. 25, 2020, Gajic, Zarko. (2020, August 25). How to Hide the Tabs of the TPageControl Delphi Control. Retrieved from Gajic, Zarko. "How to Hide the Tabs of the TPageControl Delphi Control." ThoughtCo. (accessed June 3, 2023).