locked
Selected some Pictures from showdialod and set the name in the listBox Control RRS feed

  • Question

  • I want to Browse The showdialog and selected some files and when press open he paste the name of Pictures get in the listbox
    Sunday, December 19, 2010 3:57 AM

Answers

  • you can use an OpenFileDialog to navigate to and select the folder

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ofd As New OpenFileDialog
        ofd.Multiselect = True
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
          For Each f As String In ofd.FileNames
            'full path
            ListBox1.Items.Add(f)
            'file name with extension
            ListBox1.Items.Add(Path.GetFileName(f))
            'file name without extension
            ListBox1.Items.Add(Path.GetFileNameWithoutExtension(f))
          Next
        End If
      End Sub
    
    • Marked as answer by KhaLeeL ZoURoB Wednesday, December 22, 2010 8:06 PM
    Wednesday, December 22, 2010 6:18 PM

All replies

  • what part are you having trouble with? showing the OpenFileDialog, selecting multiple files, displaying the name for each in the ListBox?

    it would also help if you can show the code you have so far

    Sunday, December 19, 2010 6:23 AM
  •  

    look at   me

     

    i write this code to get the all picture from pic folder in my application folder

     

    Dim files As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
        files = My.Computer.FileSystem.GetFiles(My.Application.Info.DirectoryPath & "\Pic", FileIO.SearchOption.SearchTopLevelOnly, "*.JPG")
        ' files = My.Computer.FileSystem.GetFiles(My.Application.Info.DirectoryPath & My.Computer.FileSystem.GetDirectories(My.Computer.FileSystem.), FileIO.SearchOption.SearchTopLevelOnly, "*.JPG")
        Dim i As Integer
        For i = 1 To files.Count - 1
          Me.ListBox1.Items.Add(IO.Path.GetFileName(files.Item(i)))
        Next
    

    i want to display in listbox the picture i want selected in any folder from harddisk

    that's at all

    Wednesday, December 22, 2010 5:13 PM
  • Are you using Windows Forms or WPF or?
    Mike McIntyre Senior Developer / Partner aZ Software Developers
    Wednesday, December 22, 2010 5:24 PM
  • you can use an OpenFileDialog to navigate to and select the folder

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ofd As New OpenFileDialog
        ofd.Multiselect = True
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
          For Each f As String In ofd.FileNames
            'full path
            ListBox1.Items.Add(f)
            'file name with extension
            ListBox1.Items.Add(Path.GetFileName(f))
            'file name without extension
            ListBox1.Items.Add(Path.GetFileNameWithoutExtension(f))
          Next
        End If
      End Sub
    
    • Marked as answer by KhaLeeL ZoURoB Wednesday, December 22, 2010 8:06 PM
    Wednesday, December 22, 2010 6:18 PM
  • Windows forms
    Wednesday, December 22, 2010 7:52 PM
  • Imports System.IO

     

    Thanks u

     

    Wednesday, December 22, 2010 8:05 PM