如何隐藏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控件显示一组用于创建多页对话框的页面。 每个页面(一个标签页)都拥有自己的控件。 用户通过单击显示在控件顶部的页面选项卡来选择页面(使其可见)。

隐藏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.

如果您需要创建一个类似向导的用户界面,其中出现“下一步”和“上一步”按钮以在一组页面(对话框)中前后移动用户,请隐藏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.

通过使用ActivePageActivePageIndex PageControl属性来激活页面不会引发OnChangeOnChanging事件。

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

要以编程方式设置活动页面,请使用SelectNextPage方法:


 //Hide PageControl Tabs
var
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值