2009-10-12 9 views

Répondre

9

Vous pouvez essayer cette

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; 

Mise à jour

En DesignTime vous devez définir la propriété PageIndex au PageIndex du TabSheet1.

Salut.

+1

Il y a beaucoup de code dans cet exemple. La partie qui répond * à la question * est la dernière ligne, où 'PageIndex' reçoit une nouvelle valeur. –

+0

J'aurais dû dire l'insertion au moment du design. (Peut-être que je devrais éditer ma question?) – volvox

+0

C'est ce que je pensais. OK - merci pour le code de toute façon ce sera utile. – volvox

13

Rightclick sur le PageControl, puis cliquez sur Nouvelle page

Après cela, définissez la propriété PageIndex pour placer la nouvelle page où vous voulez avoir.

Questions connexes