Autor Beitrag
nas4killer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Fr 13.02.04 00:31 
hi,

kann ich die Items der Listbox Mischen lassen

wenn z.b. vorher
1
2
3
4
5
stand das nach dem mischen eine anderen rheienfoge drin steht
per Zufallsgenerator z.b.
5
4
2
3
1
oder ähnlich.

Danke
chefkoch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

WIN XP pro
D7
BeitragVerfasst: Fr 13.02.04 00:38 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
    randomize;
    listbox1.Items.Exchange(random(listbox1.items.Count),random(listbox1.items.Count));
end;


Alles reiner Zufall ;)

hf Chefkoch

Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt

_________________
Chaos, Panic, Disorder - My work here is done
nas4killer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Fr 13.02.04 00:44 
Danke das ist Perfekt. Noch eine kleinigkeit.
WEnn ich versuche mit
ausblenden Delphi-Quelltext
1:
Listbox1.Items.Delete(StrToInt(ListBox1.Items[0]));					

die erste zeile der listbox zu löschen, löscht er die zweite weist du was das sein kann ?

Moderiert von user profile iconPeter Lustig: Delphi-Tags gesetzt
chefkoch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

WIN XP pro
D7
BeitragVerfasst: Fr 13.02.04 00:47 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  listbox1.Items.Delete(0);
end;


Oder willst du was anderes ?

Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt

_________________
Chaos, Panic, Disorder - My work here is done
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 13.02.04 08:36 
Hallo, Chefkoch!

Bitte nutze demnächst die Delphi-Tags anstatt der Code-Tags. Das macht die Darstellung von Delphi-Source sehr viel übersichtlicher, da so das Systax-Highlighting aktiviert wird.

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Fr 13.02.04 10:07 
@Nas4killer:

Fast sämtliche Listenelemente in Delphi sind null-indiziert, daß heisst, das erste Element hat immer die Position 0.
Mit deinem Code interpretierst du den Text des ersten Elements (an Stelle 0) als Integer, was bei dir 1 ergibt ( der Text des ersten Elements ist bei dir ja '1'). Du löscht also das Element an Position 1, das zweite Element.

Cu,
Udontknow