delphi TPageControl组件用法  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi TPageControl组件用法


TPageControl组件属性


ActivePage


用来显示当前页面。


示例:多页面显示

1.jpg



procedure TForm1.FormCreate(Sender: TObject);

var

  i:Integer;

begin

  for i:= 0 to PageControl1.PageCount-1 do

  begin

    ComboBox1.Items.Add(PageControl1.Pages[i].Caption);

  end;

  ComboBox1.ItemIndex:=0;


end;


procedure TForm1.ComboBox1Change(Sender: TObject);

begin

  PageControl1.ActivePage:=PageControl1.Pages[comboBox1.itemindex];

end;

ActivePageIndex


  获取当前页面的索引,从0到PageCount-1范围之内,


示例:通过按钮实现多页面切换

2.jpg



procedure TForm1.Button2Click(Sender: TObject);

begin

  if PageControl1.ActivePageIndex<PageControl1.PageCount-1 then

    PageControl1.ActivePageIndex:= PageControl1.ActivePageIndex+1;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

  if PageControl1.ActivePageIndex>0 then

    PageControl1.ActivePageIndex:= PageControl1.ActivePageIndex-1;

end;

  pageCount


  确定page的页数


TpageCountrol组件的方法


  FindNextPage


示例:查找页面相关位置。


3.jpg


procedure TForm1.PageControl1Change(Sender: TObject);

var

  prevCaption,NextCaption:ShortString;

begin

  with(Sender as TPageControl)do

  begin

    prevCaption:= FindNextPage(ActivePage,True,False).Caption;

    NextCaption:=findnextpage(ActivePage,False,False).Caption;

  end;

  ShowMessage('下一页是:'+prevcaption+' 前一页是:'+nextcaption+'');


end;


end.

 


  SelectNexPage


  如果GoForward参赛为true,则选择ActivePage属性指定的后一页,否则指定前一页



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.036368846893311 seconds