Autor Beitrag
3rdnuss
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 139



BeitragVerfasst: Mo 16.05.05 12:39 
Ich habe bisher immer Listboxeinträge mit:

ausblenden Delphi-Quelltext
1:
2:
if opendialog1.Execute = true then begin
listbox1.Items := opendialog1.Files;


Ok, das ist ja auch kein Problem.
Aber wenn ich jetzt wieder neue Einträge in die Listbox hinzufügen möchte, dann werden die vorhandenen Einträge wieder gelöscht..

Kennt da Jemand eine bessere Lösung?


Gruß Felix :P


Moderiert von user profile iconChristian S.: Topic aus Dateizugriff verschoben am Mo 16.05.2005 um 13:59
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 16.05.05 13:00 
Hallo!

Deine Lösung funktioniert deshalb nicht, weil Du nur Referenzen kopierst und ListBox1.Items hinterher auf dasselbe Objekt zeigt wie OpenDialog1.Files. Daher mache es so:
ausblenden Delphi-Quelltext
1:
2:
  if OpenDialog1.Execute then
    ListBox1.Items.AddStrings(OpenDialog1.Files);


Wie Du siehst, kannst Du Dir auch das = true in der if-Anweisung sparen.

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
3rdnuss Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 139



BeitragVerfasst: Mo 16.05.05 13:43 
Ok, danke. Hätt ich auch selbst drauf kommen können :wink:^^