Hi! I make a textbox and a search button, when I click that button, it will find files in the directory that I locate named "something_I_type_in_textbox.gif"
and list it in the listbox
Now I put a picture box and when I select the item in listbox, that image will appears
Here is the code
Image not loaded, do you know why ?
Thanks !!!
and list it in the listbox
Now I put a picture box and when I select the item in listbox, that image will appears
Here is the code
VB.NET:
Imports System.IO
Imports System.Drawing
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FName As String
FName = TextBox1.Text
Me.FolderBrowserDialog1.Description = "Select source folder"
If Me.FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim di As New IO.DirectoryInfo(Me.FolderBrowserDialog1.SelectedPath)
ListBox1.DataSource = di.GetFiles(FName & ".gif", IO.SearchOption.AllDirectories)
ListBox1.DisplayMember = "Name"
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim Item As String
Item = ListBox1.SelectedItem.Text() ' it says error here
' Public member 'Text' on type 'FileInfo' not found.
Item = "E:\New Folder\Blue\blue\" & Item
PictureBox1.Image = Image.FromFile(Item)
End Sub
End Class
Thanks !!!