Autor Beitrag
cyberax
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 247

Win XP Pro
Delphi 5 Enterprise
BeitragVerfasst: Mo 26.02.07 18:04 
Hallo,

wie kann ich die Reihenfolge einer Stringlist drehen ?
Bsp.:

habe folgende Stringlist:
ausblenden Delphi-Quelltext
1:
2:
3:
 FieldList.add('Zeile 3');
 FieldList.add('Zeile 2');
 FieldList.add('Zeile 1');


und möchte diese liste drehen...
ausblenden Quelltext
1:
2:
3:
 Zeile 1
 Zeile 2
 Zeile 3


Ist das möglich ? Wenn ja - wie ?
Gruß cyberax


Moderiert von user profile iconChristian S.: Topic aus VCL (Visual Component Library) verschoben am Mo 26.02.2007 um 18:05
Bääääär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Mo 26.02.07 18:28 
guck doch mal in der onlinehilfe oder im I-Net. Soweit ich weiß, gibts da direkt 'ne funktion für.

ansonsten machst du eine temponäre stringlist und lädst alles da rein und dann schreibst du den letzten eintrag der tempönären in den 1. der wirklichen, dann den vorletzten in den 2. usw.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 26.02.07 18:33 
Moin!

Ist die physische Anordnung tatsächlich nötig? :gruebel: Sonst: von hinten nach vorne durch die Liste laufen. :idea: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: Mo 26.02.07 18:51 
Hallo,

das geht aber recht fix mit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
i:= 0;
j :=  FieldList.count-1;
while i<j do
  begin
  FieldList.Exchange(I,J);
  inc(i);
  dec(j)
  end;


Gruß Horst
Edit: das ist nur ein Zeigeraustauschen.
cyberax Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 247

Win XP Pro
Delphi 5 Enterprise
BeitragVerfasst: Mo 26.02.07 19:44 
@Horst:
Okay das funktioniert einwandfrei.

Vielen Dank auch an die anderen!!!