Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi opendialog, allowmultiselect, filename (https://www.delphipraxis.net/20478-opendialog-allowmultiselect-filename.html)

dde 18. Apr 2004 18:23


opendialog, allowmultiselect, filename
 
hey guys,

wie schaff ichs mit opendialog, die ausgewählten DATEIEN in eine Liste zu integrieren. Mir reicht nur der Code um die ausgewählten Dateien irgendwie anzusprechen. Opendialog1.Filename liefert nur das letzte ausgewählte. ich will aber alle ausgewählten...

thx i a

Ratte 18. Apr 2004 18:29

Re: opendialog, allowmultiselect, filename
 
HI,

die Lösung lautet:
Delphi-Quellcode:
Opendialog1.files
Darin sind alle Dateien enthalten (TStrings).

Ratte

toms 18. Apr 2004 18:31

Re: opendialog, allowmultiselect, filename
 
Hi,

So:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
 i: Word;
begin
 if OpenDialog1.Execute then
 begin
   for i := 0 to OpenDialog1.Files.Count -1 do
    ListBox1.Items.Add(OpenDialog1.Files[i])
   end;
end;

oder so (verstreamte Version):

Delphi-Quellcode:
var
 s: TStream;
begin
 if OpenDialog1.Execute then
 begin
   s := TMemoryStream.Create;
   try
     OpenDialog1.Files.SaveToStream(s);
     s.Position := 0;
     ListBox1.Items.LoadFromStream(s);
   finally
     s.Free;
   end;
 end;

Chris1986 18. Apr 2004 18:38

Re: opendialog, allowmultiselect, filename
 
Hi,
geht nicht auch

Delphi-Quellcode:
Listbox1.Items := Opendialog1.files
?

MfG
Christian

EDIT:\\ Ja, geht :lol:

toms 18. Apr 2004 18:39

Re: opendialog, allowmultiselect, filename
 
@Chris1986: Klar, geht auch!

Robert_G 18. Apr 2004 19:18

Re: opendialog, allowmultiselect, filename
 
TOpenDialog.Files ist doch TStrings ,oder?
Irgendwie gefällt mir diese Zuweisung einer Instanz an eine andere nicht. :gruebel:
Es sollte zwar funktionieren, aber auf die Art sieht es irgendwie "hübscher" aus.
Delphi-Quellcode:
with OpenDialog do
begin
  if Execute then
    ListBox.Items.Assign(Files);
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:26 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz