PDA

View Full Version : how to add multiple selected files to a listbox ?


cgirolet
04-21-2007, 10:49 AM
hello

i managed to add a single file to a listbox using the following code, but even if i set "multiple selection" to true, when i select multiples files only the last one is added


01 MesDoc = Shell.GetFolder(SHF_MYDOCUMENTS);
02 ajout_fichier = Dialog.FileBrowse(true, "Ajouter 1 Fichier ...", MesDoc, "Images (*.jpg,*.png,*.gif,*.png,*.tif)|*.jpg;*.png;*.gif; *.png;*.tif|", "", "", true, true);
03 if (ajout_fichier[1] ~= "CANCEL") then
04 -- enlever le chemin
05 fichier = String.SplitPath(ajout_fichier[1]);
06 -- Ajouter à la liste
07 ListBox.AddItem( "ListBox1", fichier.Filename..fichier.Extension, ajout_fichier[1]);
08 end

output enhanced with AMS Code Pretty (http://www.indigorose.com/forums/showthread.php?t=19409)


can you help me ?

claude

RizlaUK
04-21-2007, 11:32 AM
you need to loop through the files and add them to the listbox

try this


MesDoc = Shell.GetFolder(SHF_MYDOCUMENTS);
ajout_fichier = Dialog.FileBrowse(true, "Ajouter 1 Fichier ...", MesDoc, "Images (*.jpg,*.png,*.gif,*.png,*.tif)|*.jpg;*.png;*.gif; *.png;*.tif|", "", "", true, true);
if (ajout_fichier[1] ~= "CANCEL") then
for i,v in ajout_fichier do
-- enlever le chemin
fichier = String.SplitPath(ajout_fichier[i]);
-- Ajouter à la liste
ListBox.AddItem( "ListBox1", fichier.Filename..fichier.Extension, ajout_fichier[i]);
end
end

output enhanced with AMS Code Pretty (http://www.indigorose.com/forums/showthread.php?t=19409)