Autor Beitrag
SteheAufDerLeitung
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Do 12.07.07 08:10 
G'Morgen!!

Ich möchte die selektierten Nodes einer TreeView in eine TList speichern, damit ich sie beim erneuten Aufruf wieder selektieren lasse..

In einer TList werden ja pointer gespeichert, richtig?
Von daher dachte ich dies würde funzen:
ausblenden Delphi-Quelltext
1:
2:
3:
for i := 0 to TreeView.Items.Count-1 do 
if Treeview.Items[i].selected then
TList.add(pointer(TreeView.Items[i]));


Jedoch erscheint beim Ausführen:
Exception der Klasse EAccessViolation, Zugriffsverletzung bei Adresse... Lesen von Adresse xyz..

Was mach ich denn falsch?

Euch allen erstmal nen guten Start in den Tag! ;-) Lecker Kaffee!! :-D
wwwdirk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D6 Prof / D2005 Prof
BeitragVerfasst: Do 12.07.07 09:28 
Hast du ne TList-Instanz erstellt?
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Do 12.07.07 11:20 
Wie wwwdirk schon geschrieben hat: TList ist eine Klasse. Du benötigst aber eine Instanz einer Klasse. So in etwa:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var
  SelItems: TList;
begin
  SelItems := TList.Create;
  try
    for i := 0 to TreeView.Items.Count-1 do 
      if Treeview.Items[i].selected then
        SelItems.add(TreeView.Items[i]);

    { mach etwas mit SelItems ... }
  finally
    SelItems.Free;
  end;
end;



Lg, Martin

_________________
Ein Nutzer der Ecke ;-)
SteheAufDerLeitung Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Do 12.07.07 12:09 
Ahh!! daran hab ich noch nicht gedacht, werd es bei Gelegenheit mal ausprobieren.. Vielen Dank schon mal!
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Sa 14.07.07 12:21 
Das mit dem Pointer-Zeugs kannst du meines Wissens weglassen.
Ich füge immer so neue Einträge in eine TList hinzu:
ausblenden Delphi-Quelltext
1:
List.Add(Klasse);					

Beim Zugreifen musst du entweder TKlasse(List[Index]) davorhängen, oder mit Item := List[Index]; Item.Selected ... erst eine Variable setzen.