Autor Beitrag
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Sa 28.05.05 16:28 
Hallo,

wie kann ich eine TabSheet zur Laufzeit erzeugen Das PageControl mit 1 TabSheet ist schon auf der Form. Ich habe versucht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
var
  Tabsheet: TTabSheet;
begin
  Tabsheet := Tabsheet.Create(nil); // <- auch nicht mit "Application"
  TabSheet.Parent := PageControl1;
  Tabsheet.Show;
end;


Sorecht gelingen will es aber nicht. Und wie geht es dann mit den Namen? Auf dem erzeugten TabSheet sollen nämlich dann noch 4 weite Edit's erstellt werden.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Sa 28.05.05 16:39 
Erzeugen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
Procedure TForm1.Button1Click(Sender: TObject);
var tabsheet: TTabSheet;
begin
tabsheet := TTabSheet.Create(Self); //Self = MainForm
tabsheet.PageControl := form1.PageControl1;//
inc(Counter, 1); //Counter ist eine Integer Variable
tabsheet.Name := 'Blablabla' + Counter; 
end;


Zugriff geht auch über
ausblenden Delphi-Quelltext
1:
form1.PageControl1.Pages[i];//i ist der Index des Tabsheets					

_________________
Programmers never die, they just GOSUB without RETURN
Harry M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Sa 28.05.05 16:43 
Cool thx geht nur 1 zeile musste ich leider ändern:

ausblenden Delphi-Quelltext
1:
2:
3:
{ von } tabsheet.Name := 'Blablabla' + Counter;  

{ in } tabsheet.Name := 'Blablabla' + IntToStr(Counter);

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Sa 28.05.05 16:54 
ja, sowas überseh ich ständig 8)
die sache mit dem Counter ist aber so eine Sache(wichtig, muss man dazu sagen), weil wenn du ein Tabsheet zerstörst, stimmts nicht mehr. Mache das lieber über PageControl1.Pages[i]. Über PageControl1.PageCount kriegst du die Seitenzahl und über PageControl1.ActivePage die aktuelle Seite. Nimm lieber das sonst kommen am ende noch ein haufen AVs raus (da kann ich ein Lied von singen... bei mir im Prog isses aber noch ein wenig komplexer...)
Gruß!

_________________
Programmers never die, they just GOSUB without RETURN
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 28.05.05 17:03 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var
ed:array[1..10of TEdit;
a : integer;
begin
a := 1;
ed[a]:=tEdit.Create(self);
ed[a].Parent:=form1;
end;

Die Edits. Bei Parent muss dann halt der TabSheet oder sost was rein.