本文整理自网络,侵删。
TPageControl组件属性
ActivePage
用来显示当前页面。
示例:多页面显示
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范围之内,
示例:通过按钮实现多页面切换
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
示例:查找页面相关位置。
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.
相关阅读 >>
Delphi 拖动文件到exe 打开 获取getcommandline命令行
Delphi waitforsingleobject 响应窗体
更多相关阅读请进入《Delphi》频道 >>