Hallo, ich habe folgendes Problem:
In meinem Prog befinden sich 2 Listboxes. In der einen werden Dateien mit ihrem Dateipfad aufgelistet (die ListBox ist invisible), in der anderen die selben Dateien nur ohne Pfad.
Nun würde ich gern die sichtbare ListBox sortiet dargestellt haben un muss ja dann auch die unsichtbare genauso sortieren.
Habe dass nun mal mit folgendem Code versucht:
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: 36: 37: 38: 39: 40: 41:
| procedure TForm1.Sort; var i,j,temp : Integer; positionen : Array of Integer; tempList1, tempList2 : TStringList; begin SetLength(positionen, ListBox2.Items.Count); for i:=0 TO ListBox2.Items.Count-1 do positionen[i] := i;
For i := 1 to High(positionen) do For j := High(positionen) downto i do If ListBox2.Items[positionen[j]] < ListBox2.Items[positionen[j-1]] then Begin temp := positionen[j]; positionen[j] := positionen[j-1]; positionen[j-1] := Temp; end;
tempList1 := TStringList.Create; tempList1.AddStrings(ListBox2.Items);
tempList2 := TStringList.Create; tempList2.AddStrings(ListBox1.Items);
ListBox2.Clear; ListBox1.Clear;
for i:=0 to High(positionen) do begin ListBox2.Items.Add(tempList1[positionen[i]]); ListBox1.Items.Add(tempList2[positionen[i]]); end;
tempList1.Free; tempList2.Free; end; |
Das funktioniert eigentlich auch genauso wie ich das wollte, ist nur sehr langsam.
da in meiner Liste teilweise über 5000 Dateien vorhanden sind, dauert diese Methode mehrere Minuten.
Hat da jemand eine schnellere Lösung?
Schon mal THX für eure Antworten Flo