如果我已经有很多充满控件的页面,那么在TPageControl中‘插入’页面的最好方法是什么?假设我想在TabSheet1之前插入一个新页面。
谢谢。
更新:在设计时。
发布于 2009-10-12 06:22:13
你可以试试这个
procedure TForm13.Button1Click(Sender: TObject);
Var
tabSheet: TTabSheet;
AComponent: TComponent;
aIndex: Integer;
begin
aIndex:=-1;
AComponent := FindComponent('TabSheet1');
if Assigned(AComponent) then
if AComponent is TTabSheet then
aIndex := TTabSheet(AComponent).PageIndex; //get the index of the 'TabSheet1'
tabSheet := TTabSheet.Create(PageControl1);
tabSheet.PageControl := PageControl1;
tabSheet.Caption := 'My TabSheet'+IntToStr(PageControl1.PageCount);
if aIndex>-1 then
tabSheet.PageIndex := aIndex; //Set the index of the new TabSheet
end;更新
在设计时,必须将PageIndex属性设置为TabSheet1的PageIndex。
再见。
https://stackoverflow.com/questions/1552957
复制相似问题