Friday, November 8, 2019
How to Hide the Tabs of the TPageControl Delphi Control
How to Hide the Tabs of the TPageControl Delphi Control 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 users 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 Tabsvarpage : integer;beginfor page : 0 to PageControl1.PageCount - 1 dobeginPageControl1.Pages[page].TabVisible : false;end;//select the first tabPageControl1.ActivePageIndex : 0;(*Or set Active Page directlyPageControl1.ActivePage : TabSheet1;Note: the above two do NOT raise theOnChanging and OnChange events*)end;procedure TForm1.PageControl1Changing(Sender: TObject;var AllowChange: Boolean) ;begin//no change if on the last pageAllowChange : PageControl1.ActivePageIndex -1 PageControl1.PageCount;end;//Select Previous Tabprocedure TForm1.PreviousPageButtonClick(Sender: TObject) ;beginPageControl1.SelectNextPage(false,false) ;end;//Select Next Tabprocedure TForm1.NextPageButtonClick(Sender: TObject) ;beginPageControl1.SelectNextPage(true,false) ;end; Using this technique will de-clutter the form, leading to a more streamlined interface, but ensure that the arrangement of controls on each tab doesnt force the user to move frequently between tabs.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.