Autor Beitrag
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 09.09.04 15:13 
Hi,
In meinem Programm arbeite ich mit einer ListBox. Dabei lösche ich immer einträge aus. Am Ende will ich dann Aber alle Einträge wieder haben. Ich will aber nicht die ListBox extra in eine Datei hineinspeichern oder mit einer zweiten ListBox arbeiten. Kann ich die ListBox auch irgendwie in eine Variable oder so reintun?
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Do 09.09.04 15:19 
Ja, in eine andere Stringliste.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  x : TStringList;
  a : Integer;
begin
  x:=TStringList.Create;
  for a:=0 to ListBox.Items.Count-1 do x.Add(ListBox.Items[a]);
  ...

Am Ende x wieder freigeben.

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 09.09.04 15:50 
thx.
Aber wozu ist das -1 bei ...to ListBox.Items.Count-1 do.... ?
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Do 09.09.04 16:19 
Da die Indices bei 0 losgehen und nicht bei 1, muss man natürlich auch am Ende eins eher aufhören. Spaßenshalber kannst du die -1 ja mal weglassen.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Fr 15.10.04 18:15 
thx, hat funktioniert. :)