Best way to 'insert' a page in a TPageControl if i already have many pages full of controls? Let's say i want to insert a new page before TabSheet1.
Thanks.
UPDATE : At design time.
Best way to 'insert' a page in a TPageControl if i already have many pages full of controls? Let's say i want to insert a new page before TabSheet1.
Thanks.
UPDATE : At design time.
Rightclick on the pagecontrol, and click New Page
After that, set the PageIndex
property to place the new page where you want to have it.
You can try this
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;
Update
In Designtime you must set the PageIndex Property to the PageIndex of the TabSheet1.
Bye.