网上文摘 小说 Flash游戏 最近更新 下载排行 资源分类 下载指南
经典编程资源 精彩不容错过
设为首页
加入收藏
联系我们
当前位置:Delphi园地技巧文章编程心得 → How to Hide the Tabs of the TPageControl Delphi control
How to Hide the Tabs of the TPageControl Delphi control
日期:2009年12月15日 作者: 人气: 查看:[大字体 中字体 小字体]

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, i.e. 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 "moving" a user forward and backward through a set of pages (dialogs), you might want to hide the tabs of the PageControl and thus disallow selecting a particular page by the mouse.

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

Note: 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
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" Tab
procedure TForm1.PreviousPageButtonClick(Sender: TObject) ;
begin
  PageControl1.SelectNextPage(false,false) ;
end;

//Select "Next" Tab
procedure TForm1.NextPageButtonClick(Sender: TObject) ;
begin
  PageControl1.SelectNextPage(true,false) ;
end;

(出处:http://delphi.about.com/od/delphitips2007/qt/hidepagectrltab.htm)

相关文章:
·在整个程序中,实现"Enter作为Tab"变换
·利用ADOTable存取Excel文件
·在 Delphi 6 中使用 Hashtable
 → 特别推荐
 → 热点TOP10
关于我们 | 广告服务 | 发布资源 | 联系站长 Copyright © 2001-2009 Delphi园地 All Rights Reserved
束 -->