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.
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. –
J'aurais dû dire l'insertion au moment du design. (Peut-être que je devrais éditer ma question?) – volvox
C'est ce que je pensais. OK - merci pour le code de toute façon ce sera utile. – volvox