Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Browse dialog and select multiple files

Hello EE,

I need a browser dialog and the user would be able to select multiples images then on OK press it returns all path of all images selected in a ListBox..

not sure how to create the Dialog with multiple selection

any idea of code?
0
PhilippeRenaud
Asked:
PhilippeRenaud
  • 4
  • 4
  • 2
2 Solutions
 
x77Commented:

    Dim fdlg As New OpenFileDialog
    fdlg.Filter = "(*.dat)|*.dat"
    fdlg.Multiselect = True
    fdlg.CheckFileExists = True
    fdlg.InitialDirectory = Ruta
    If fdlg.ShowDialog(Me) <> Windows.Forms.DialogResult.OK Then Return
    LoadAnalisis(fdlg.FileNames)
    Ruta = Path.GetDirectoryName(fdlg.FileNames(0))

-  Use  Multiselect  propeerty to allow multiple selection.
-  Use FileNames to get an array of strings containing selected files.

- I Also preserve the Path to use it when user uses OpenFileDialog next time.
0
 
PhilippeRenaudAuthor Commented:
Ruta ?..

so instead of that I would write like "My documents" ?

and LoadAnalisis would be where I load my listbox?

and fdlg.FileNames is a List(Of String) ??
0
 
x77Commented:

You can also allow Drop Files fron any File Explorer (Windows Explorer by sample).

Private Sub AnalisisDlg_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
   LoadAnalisis(TryCast(e.Data.GetData(DataFormats.FileDrop), String()))
End Sub

You need set AllowDrop = true on Form or any Control where you want user Drop Files.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
x77Commented:
LoadAnalisis is my method to process selected files.

Ruta = Path : I use Spanish name on my private Var I use to Remember last used Path.

fdlg.FileNames - Is array of strings.

0
 
PhilippeRenaudAuthor Commented:
very nice..
0
 
PhilippeRenaudAuthor Commented:
When i try to drag an item in my documents into my ListView  (allowDrop = true)  I still see the  mouse icon as a "you cant drop"  

I guess im missing something?
0
 
CodeCruiserCommented:
You need to catch the dragenter event and allow the drop based on its type
0
 
CodeCruiserCommented:
In the drag drop, add this


        If e.Data.GetDataPresent(DataFormats.FileDrop, False) Then
            e.Effect = DragDropEffects.Copy
        End If

0
 
x77Commented:
Sorry, I miss aditional event:

    Private Sub AnalisisDlg_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
      e.Effect = If(e.Data.GetDataPresent(DataFormats.FileDrop), DragDropEffects.Copy, DragDropEffects.None)
    End Sub
0
 
PhilippeRenaudAuthor Commented:
thanks both
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now