Autor Beitrag
schitho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 288

XP Home SP2
D2005 Prof
BeitragVerfasst: Sa 26.02.05 03:50 
Hi,

wie kann ich die Items aus der ListView in eine neue Liste mit Items kopieren?

Ich hab es so probiert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  Liste : TListItems;
:
:
Liste.Assign(listview1.Items);


Doch da bekomm ich eine Exception. Was mach ich falsch?

Gruß
Thomas

_________________
(Sorry! Leider ewiger Delphi-Neuling)
opfer.der.genauigkeit
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754
Erhaltene Danke: 1



BeitragVerfasst: Sa 26.02.05 04:30 
Hi,

So dürft's gehen.

ausblenden Delphi-Quelltext
1:
  ListView2.Items := ListView1.Items;					


//Edit: Oder so.. :)
ausblenden Delphi-Quelltext
1:
  ListView2.Items.Assign(ListView1.Items);					

_________________
Stellen Sie sich bitte Zirkusmusik vor.
schitho Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 288

XP Home SP2
D2005 Prof
BeitragVerfasst: So 27.02.05 00:46 
Danke für die Antwort.

Aber ich hab nur ein ListView. :(

Wie kann ich nun alle Items auf einmal kopieren?

Gruß
Thomas

_________________
(Sorry! Leider ewiger Delphi-Neuling)
schitho Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 288

XP Home SP2
D2005 Prof
BeitragVerfasst: Mo 28.02.05 12:46 
Gibt es vielleicht jemanden, der mir sonst eine Möglichkeit aufzeigen könnte, wie ich die Werte in den Items speichern könnte? Array? Stringliste?

Hintergrund:
In meiner Listview verwende ich mehrere Spalten und eine Checkbox. Damit ich erkennen kann, ob jemand einen Eintrag geändert hat, wollte ich einfach die Items in eine neue Item-Liste kopieren. Dies funktioniert leider nicht (siehe weiter oben).

Nun suche ich nach einer anderen Möglichkeit, wie ich die Inhalte der Spalten pro Zeile, sowie den dazugehörigen Checkbox-Zustand (true oder false) speichern kann.

Was empfehlt ihr?

Vielen Dank

Gruß
Thomas

_________________
(Sorry! Leider ewiger Delphi-Neuling)
vsti
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 43

XP Home
D2005
BeitragVerfasst: Mo 28.02.05 13:36 
mit ner schleife sollte es doch gehen...

ausblenden Delphi-Quelltext
1:
2:
  for i := 0 to ListView1.Items.Count-1 do
    Liste.Add.Assign(ListView1.Items.Item[i]);


greez

_________________
[size=10:8b472be373]Wer anderen eine Grube gräbt hat Gold im Mund.[/size:8b472be373]
schitho Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 288

XP Home SP2
D2005 Prof
BeitragVerfasst: Mo 28.02.05 23:00 
Bei dem Code bekomm ich auch eine Exception :cry:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  Liste : TListItems;

procedure TFAutostart.ItemsCopy;
var
  i: Integer;
begin
  for i := 0 to ListView1.Items.Count - 1 do
    Liste.Add.Assign(ListView1.Items.Item[i]);
end;



Sobald ich die Procedure aufrufe erhalte ich die Exception.

Was mach ich blos falsch?

Gruß
Thomas

_________________
(Sorry! Leider ewiger Delphi-Neuling)