Autor Beitrag
covel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

Win XP PRo
Borland D7/C#
BeitragVerfasst: Do 02.06.05 07:50 
hallo


ich erstelle einige Buttons (Button[i]). nun will ich die buttons aber wieder löschen (button[i].destroy)

weiß aber nicht wie ich das realisieren soll, ich will die Anzahl der Button beim erstellen nicht mit zählen habe es mit findcomponent probiert.

Hoffe das mit jemand ne Anregung geben kann.
deccer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 57



BeitragVerfasst: Do 02.06.05 08:08 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
uses
  Classes, // für TList
  Contnrs; // für TObjectList

var
  xButtons: T(Object)List;
  xButton: TButton;

begin
  xButtons := T(Object)List.Create;
  xButton := TButton.Create(Self); // siehe parent
  with xButton do begin
    Parent := Self; // wenns grad das formular is auf dem die teile erstellt werden sollen, ansonsten das Panel oder die groupbox, oder was auch immer das parent is, angeben, sonst siehtma den button nich
    Caption := 'foo';
    Width := 108;
    Height := 25;
  end;
  xButton.Add(xButton);
end;


//wenn du lieber TList benützt solltest du dir ne function basteln die ungefähr das macht

procedure FinalizeButtonList(xList: TList);
var
  iIndex: integer;

begin
  for iIndex := xList.Count - 1 downto 0 do begin
    TButton(xList[iIndex]).Free;
    xList[iIndex] := nil;
    xList.Delete(iIndex);
  end;
  xList.Clear; // um nohcmal ganz sicher zu gehn, ob auch alles wech iss
end;


anzahl der erzugten buttons erhältst mit xButtons.Count ...

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
covel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

Win XP PRo
Borland D7/C#
BeitragVerfasst: Do 02.06.05 11:30 
besten dank genau das habe ich gesucht
deccer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 57



BeitragVerfasst: Do 02.06.05 11:51 
püddeschöin