Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Files in a listbox
#2
Well, this doesn't work because your code is inside of the SelectedIndexChanged method. This means that you would have to essentially change what is selected in the listbox in order to get the files to appear. However, you cannot change your selection because there is nothing to select!

Try moving your code around like this:
Code:
Public Class Form3

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim directory = "C:\PIF"
Dim files() As System.IO.FileInfo
Dim dirinfo As New System.IO.DirectoryInfo(directory)
files = dirinfo.GetFiles("*", IO.SearchOption.AllDirectories)
For Each file In files
ListBox1.Items.Add(file)
Next
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
End Class
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
Files in a listbox - by Hurricane - 02-26-2012, 08:45 AM
Re: Files in a listbox - by brandonio21_phpbb3_import2 - 02-26-2012, 10:51 AM
Re: Files in a listbox - by Hurricane - 02-26-2012, 07:39 PM
Re: Files in a listbox - by Hurricane - 02-26-2012, 07:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Listbox items text and text boxes? Derek275 3 17,026 11-21-2012, 12:04 PM
Last Post: brandonio21
  How to search multiple files for one string ryan 1 9,346 06-18-2012, 06:04 PM
Last Post: brandonio21
  How to delete all files in a specific folder using VB ? Himansh 4 17,586 03-13-2012, 02:55 PM
Last Post: brandonio21
  Get Files from the C drive Protection4Real 3 15,486 02-10-2011, 07:59 AM
Last Post: Protection4Real

Forum Jump:


Users browsing this thread: 1 Guest(s)