Autor Beitrag
csigg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Do 07.07.05 14:25 
Kann ich Listviews denn zur Laufzeit erzeugen?? Und welche Namen haben die dann, bzw. wie kann ich denen dann Namen geben??
freedy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Do 07.07.05 14:31 
Klar geht das. Wie jede andere Klasse auch. Wenn du nur eine genau definierte Anzahl erstellen willst, pack Variablen in den Private-Teil deines Forms (z.B. ListView1, ListView2...ListViewN). Die werden dann einfach mit

ausblenden Delphi-Quelltext
1:
ListView1 := TListView.Create(Form1 bzw.Name deines Forms);					


erzeugt.

Dann musst du nur doch den ganzen Rest an Properties zuweisen.
Ein Blick in die Delphi-Hilfe hätte aber auch genügt.

freedy
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Do 07.07.05 14:46 
Ich weiss davor noch nicht wieviel ich erzeugen will, das wird erst aus der DB ausgelesen, drum weiss ich ja nicht wie ich dem ganzen versch. Namen gebe
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Do 07.07.05 15:45 
habs soweit jetzt alles so gemacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
  for i := 0 to anzahl do
      begin
           lvCube := TListView.Create(self);
           lvCube.Parent := frm_Main;
           links := links + 100;
           lvCube.Left := lvCube.Left + 100;
           lvCube.Name := 'lvCube'+inttostr(i);
           ShowMessage('1 Durchgang');
      end;

Wie kann ich jetzt in einer Schleife auf die LV´s zugreifen??
Die Namen sind hinterher ja lvCube0, lvCube1, lvCube2,.....
Wie kann ich in einer Schleife drauf zugreifen und dabei immer den Namen um eins
erhöhen??

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Dolphi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Do 07.07.05 16:10 
Das ist nicht ganz richtig. Statt der einfachen Variable lvCube solltest du vielleicht ein dynamisches Array verwenden.
Schau mal in der Delphi-Hilfe nach "Dynamische Arrays"

Als globale Variable:
ausblenden Delphi-Quelltext
1:
  lvCube: array of TListView;					


Irgendwo anders:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
  SetLength(lvCube, anzahl);
  for i := 0 to anzahl - 1 do begin   
    lvCube[i] := TListView.Create(self);   
    lvCube[i].Parent := frm_Main;   
    links := links + 100;   
    lvCube[i].Left := lvCube[i].Left + 100;   
    lvCube[i].Name := 'lvCube'+inttostr(i);   
    ShowMessage('1 Durchgang');   
  end;


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Do 07.07.05 16:14 
Hallo,

so in etwa:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 0 to anzahl do  
  begin  
  frm_Main.FindComponent('lvCube'+inttostr(i)) as TListView).Tag := 0;
  end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
freedy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Do 07.07.05 16:15 
Dynamisch geht es auf jeden Fall. Ansonsten könntest du Zugriff bekommen, indem du die Komponenten suchst mit FindComponent. Einfach mal in der Delphi-Hilfe schauen. Da gibt es, wenn ich mich richtig erinnere, ein Beispiel zu.

Ich möchte dich nur auf eines hinweisen. Das Listview ist irre langsam und ich frage mich, ob es bei dir wirklich effektiv ist, mehr als ein Listview anzulegen. Überleg doch noch mal, ob es nicht noch eine andere Möglichkeit gäbe. :?

Gruß
freedy
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Fr 08.07.05 08:32 
Ich wüsste nicht welche anderen Möglichkeiten, aber ich hatte mit meinen 6 ListViews eiegentlich noch nie Performance Probleme.
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Fr 08.07.05 13:30 
Ich hab in der Delphi Hilfe nix passendes gefunden.
Ich muss jetzt halt wissen wie ich dieser Komponente z.b. zu späterem zeitpunkt was zuweise. Wie kann ich auf die Komponente zugreifen, wenn ich deren Namen nicht weiss.