如何隐藏TPageControl Delphi控件的选项卡
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.
TPageControl Delphi控件顯示一組用于創(chuàng)建多頁對話框的頁面。 每個頁面(一個標簽頁)都擁有自己的控件。 用戶通過單擊顯示在控件頂部的頁面選項卡來選擇頁面(使其可見)。
隱藏PageControl選項卡 ( 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.
如果您需要創(chuàng)建一個類似向導的用戶界面,其中出現(xiàn)“下一步”和“上一步”按鈕以在一組頁面(對話框)中前后移動用戶,請隱藏PageControl的選項卡,從而禁止通過以下方式選擇特定頁面用戶鼠標的位置。
The trick is in setting the TabVisible property to false for each of the sheets (TTabSheet object) of the page control.
技巧是將頁面控件的每個工作表(TTabSheet對象)的TabVisible屬性設置為false。
Activating the page by using either the ActivePage or the ActivePageIndex PageControl properties will not raise the OnChange and OnChanging events.
通過使用ActivePage或ActivePageIndex PageControl屬性來激活頁面不會引發(fā)OnChange和OnChanging事件。
To programmatically set the active page, use the SelectNextPage method:
要以編程方式設置活動頁面,請使用SelectNextPage方法:
//Hide PageControl Tabsvar
page : integer;
begin
for page := 0 to PageControl1.PageCount - 1 do
begin
PageControl1.Pages[page].TabVisible := false;
end;
//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
*)
end;
procedure TForm1.PageControl1Changing(
Sender: TObject;
var AllowChange: Boolean) ;
begin
//no change if on the last page
AllowChange := PageControl1.ActivePageIndex < -1 + PageControl1.PageCount;
end;
//Select "Previous" Tabprocedure TForm1.PreviousPageButtonClick(Sender: TObject) ;
begin
PageControl1.SelectNextPage(false,false) ;
end;
//Select "Next" Tabprocedure TForm1.NextPageButtonClick(Sender: TObject) ;
begin
PageControl1.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 doesn't force the user to move frequently between tabs.
使用此技術將使表單雜亂無章,從而使界面更加簡化,但要確保每個選項卡上控件的布置都不會迫使用戶在選項卡之間頻繁移動。
翻譯自: https://www.thoughtco.com/hide-the-tabs-of-the-tpagecontrol-1057851
總結
以上是生活随笔為你收集整理的如何隐藏TPageControl Delphi控件的选项卡的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用打码平台登录B站
- 下一篇: VS 2019中使用qt