Newhack - Mi 15.12.04 18:48
Titel: listbox files kopieren
So hab mal einen neuen Thread gemacht.
Hier ich habe mal das Versucht:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
| procedure TForm1.Button1Click(Sender: TObject); var a,c:integer; b,d:string;
begin for a:=0 to FileListBox1.Items.Count-1 do if FileListBox1.Selected[a] then b :=FileListBox1.Items[a]; for c:=0 to FileListBox2.Items.Count-1 do if FileListBox2.Selected[c] then d := FileListBox2.Items[c];
Memo1.Lines.Add('copy '+b+' '+d);
end; |
Wenn ich z.b. in der listbox1 2 files auswähle und in der listbox2 1 file auswähle kopiert er nur ein file nicht 2.
Also Listbox1: file1 / file2 / file3
ich habe file 1 und 2 markiert
in der listbox2: file5
da hab ich das eine file kopiert
nun möchte ich das es in der memo so aussieht:
copy file1 file5
copy file2 file5
hoffe ihr habt es verstanden
LCS - Mi 15.12.04 19:37
Titel: Re: listbox files kopieren
Hi
dann solltest du das mal so probieren
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
| procedure TForm1.Button1Click(Sender: TObject); var a,c:integer; b,d:string;
begin for a:=0 to FileListBox1.Items.Count-1 do begin if FileListBox1.Selected[a] then begin b :=FileListBox1.Items[a]; for c:=0 to FileListBox2.Items.Count-1 do if FileListBox2.Selected[c] then begin d := FileListBox2.Items[c]; Memo1.Lines.Add('copy '+b+' '+d); end; end; end;
end; |
Ein bisschen rumexperimentieren mit dem Debugger hätte dich sicher auch drauf gebracht. :mrgreen: In dieser Form hast du allerdings noch ein problem wenn in der ersten Liste 1 Eintrag und in der zweiten Liste mehrere Einträge markiert sind. Das kannst du aber selber austüfteln. :wink:
Gruss Lothar