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.
SelectNexPage
如果GoForward参赛为true,则选择ActivePage属性指定的后一页,否则指定前一页