Autor Beitrag
mcbrunox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92



BeitragVerfasst: So 01.09.02 13:31 
wie kann ich eine Listbox mit Strings sortieren ?
O'rallY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: So 01.09.02 14:06 
Alphabetisch kannst du eine Listbox mit der Proberty ListBox1.sorted := true; sortieren.
mcbrunox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92



BeitragVerfasst: So 01.09.02 14:24 
ich erhalte diese Fehlermeldung:
Im Projekt ??? ist eine Exception der Klasse EStringListError aufgetreten. Meldung 'Listenindex überschreitet das Maximum(0)'.

Hier nun der Code:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
procedure TForm1.Button1Click(Sender: TObject);
var
  dir,list:string;
  Anzahl,i:integer;

begin
  i:=0;
  dir := BrowseForFolder('Verzeichnis öffnen');

  ListBox1.Items.Text := '';
  ListFiles(dir, edit1.text);
  LBHorizontalScroll(ListBox1);
  Anzahl := ListBox1.Items.Count;
repeat
  list:=listbox1.Items[i];
  repeat
    delete(list,1,pos('\',list));
  until pos('\',list)=0;
  label4.caption:= List;
  Listbox2.items[i]:=List;
  inc(i);
until i>=listbox1.Items.count;
       ListBox2.sorted := true;
end;

Kann mir da jemand helfen ?
XPert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129

Windows 98/00/Me/XP
D6 Pers
BeitragVerfasst: So 01.09.02 15:01 
wie viel soll denn in die listbox einsortiert werden?

_________________
MfG Fabian Schweers :lol:
mcbrunox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92



BeitragVerfasst: So 01.09.02 15:03 
Alphabetisch
XPert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129

Windows 98/00/Me/XP
D6 Pers
BeitragVerfasst: So 01.09.02 15:05 
wie viele einträge meinte ich :wink:

_________________
MfG Fabian Schweers :lol:
mcbrunox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92



BeitragVerfasst: So 01.09.02 15:20 
ein paar tausend
XPert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129

Windows 98/00/Me/XP
D6 Pers
BeitragVerfasst: So 01.09.02 15:34 
das ist net möglich! ganz klar! da klappt der pc ja zusammen :shock:
das musst du erstmal auf ein par boxes verteilen! ich glaube bei tausend würde der pc normal einen betriebssystemshock schon erleiden müssen *g*
weist du was? benutz ein memo (aber das kann auch keine paar tausend zeilen haben) du überlastest ja die möglichkeiten der komponenten! und wer will ein programm überhaupt haben, wo man erst ne halbe stunde warten muss und das programm VIELLEICHT läd...??? ich net
sorry :( da kann ich dir net helfen :!:
:? frag noch mal genauer nach dieser stringlist..... :wink:
viel glück....

_________________
MfG Fabian Schweers :lol:
aogwaba
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109



BeitragVerfasst: So 01.09.02 16:24 
Zitat:
Im Projekt ??? ist eine Exception der Klasse EStringListError aufgetreten. Meldung 'Listenindex überschreitet das Maximum(0)'.


Die Liste ist leer, und du versuchst auf das nullte Item zuzugreifen!
noch ein Tip:
Das erste Item hat den Index=0, der letzte 'ListBox.count-1' !

cu
waba
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: So 01.09.02 16:30 
Hi,
wie kommst du darauf, dass eine Listbox keine paar Tausend Einträge haben kann? Worauf basiert dein Wissen (Quelle...)?

Zu dem Absturzproblem:
Listbox1.Count fängt bei 1 an zu zählen, die Items aber bei 0.
Also musst du einfach statt
ausblenden Quelltext
1:
until i>=listbox1.Items.count;					

das so machen:
ausblenden Quelltext
1:
until i>=listbox1.Items.count - 1;					
mcbrunox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92



BeitragVerfasst: So 01.09.02 16:50 
also das mit until i>=listbox1.Items.count-1; hat gefunzt
jedoch ist die liste noch immer nicht sortiert.
muss ich das ListBox1.sorted := true; wo anderst einsetzen oder muss
ich die liste nur neu einladen ?
aogwaba
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109



BeitragVerfasst: So 01.09.02 17:12 
benutze zum anfügen doch ListBox1.Items.Add() , wenn's sowieso
sortiert wird.

cu
waba
XPert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129

Windows 98/00/Me/XP
D6 Pers
BeitragVerfasst: So 01.09.02 17:41 
@alibi:
jedenfalls net auf deiner qulle des wissens! :wink:

_________________
MfG Fabian Schweers :lol:
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: So 01.09.02 17:49 
Hallo,

Alibi hat folgendes geschrieben:
Zu dem Absturzproblem:
Listbox1.Count fängt bei 1 an zu zählen, die Items aber bei 0.
Also musst du einfach statt
until i>=listbox1.Items.count;
das so machen:
until i>=listbox1.Items.count - 1;


Nein die Zeile
ausblenden Quelltext
1:
until i>=listbox1.Items.count;					

war schon richtig, da i erst am Ende der Schleife erhöht wird und der letzte Eintrag der Listbox (count-1) muß auch noch bearbeitet werden.

Das Problem ist eher das die repeat Schleife immer mindestens einmal durchlaufen wird, auch wenn die Listbox leer ist. Und dies führt zu dem beschriebenen EStringListError.

@mcbrunox
Bist du sicher das die Listbox wirklich Einträge enthält? Du löscht die ListBox
ausblenden Quelltext
1:
 ListBox1.Items.Text := '';					

aber wird sie auch wieder gesetzt?
mcbrunox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92



BeitragVerfasst: So 01.09.02 18:04 
aber mit ListFiles(dir, edit1.text); wird die listbox wieder gefüllt.
aogwaba
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109



BeitragVerfasst: So 01.09.02 18:14 
Hoppla!
ausblenden Quelltext
1:
until i >= listbox1.Items.count;					

cu
waba
[/b]
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: So 01.09.02 18:30 
@mcbrunox

Tritt der Fehler bei ListBox1 oder bei ListBox2 auf ???

enthält die ListBox2 auch schon Einträge bevor du hier die Werte
speicherts?
ausblenden Quelltext
1:
 Listbox2.items[i]:=List;					


Ansonsten benutze hier
ausblenden Quelltext
1:
ListBox2.Items.Add(List);					

um auf der sicheren Seite zu sein.
mcbrunox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92



BeitragVerfasst: So 01.09.02 18:47 
den oben genannten Fehler habe ich nicht mehr,
es geht mir nur mehr um die Alphabetische sortierung.

Kann mir da jemand helfen ?
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: So 01.09.02 18:52 
@XPert
@alibi

Hallo,

zu der Frage viele Einträge eine ListBox verkraftet
XPert hat folgendes geschrieben:
das ist net möglich! ganz klar! da klappt der pc ja zusammen


Nee das Tut es nicht, ich habe gerade 32736 Strings innerhalb von 5 Sekunden in eine ListBox geschrieben. :lol:

Dies schein aber das Limit zu sein alles darüber gibt eine
EOutOfResources Exception.


Komisch ist nur das alle Funktionen der ListBox als Parameter Integer
verwenden und nicht Smallint (32736)
mcbrunox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92



BeitragVerfasst: So 01.09.02 19:35 
jetzt habe ich es mal so probiert...geht aber auch nicht...bekomme die gleicher fehlermeldung wie am anfang
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
begin
  listbox1.Items[0]:='hallo';
  listbox1.items[1]:='bello';
  ListBox1.sorted := true;
end;

end.