Creating a Image Gallery

Hi. I'm creating an image gallery in VB.NET 2005. I've got my basic interface nearly complete and need some help. So my first question is how I can create a list of image I've imported. I'd like to do some sort of gallery where there is all the images loaded into the program as a list. Then you click on the thumbnail/file and it opens in the gallery. I think that the best way would be to use a ListView but I can't figure out how to put images in it. To start, I've put a few images into the resources if that helps. I'm just not sure where to go from here.

If you're confused, just say so and I'll try and clairfy it.



Answer this question

Creating a Image Gallery

  • VincentShi

    DMan1 wrote:

    I don't know how you imported your files...but when you import the files you should be able to add the string to the a listbox:

    For Each foundFile As String In TheFiles

    ListBox1.Items.Add(foundFile)

    Next

    and when the user selects a file in the listbox....

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

    Me.PictureBox1.Image = Image.FromFile(CStr(Me.ListBox1.SelectedItem))

    End Sub

    That last part's really helpful; I was thinking something along those lines in getting the image viewer to actually work. That just makes it a bit clearer. As for how I imported the files, right now I just put them in as resources. I can leave them in there if it works better, or I may be better off putting them in a text file as kidwidahair mentioned. That's how they are imported, but how do I get them into the ListBox I guess probably another good option might be to use an XML file I'm a big newbie to Visual Basic so any and all help is appreciated.


  • srini_m_s

    Why dont you create a text file and add all of the paths of your images. Then use LineInput to read each path and open the picture.

    Hope this helps

    Steve



  • Nicw

    I don't know how you imported your files...but when you import the files you should be able to add the string to the a listbox:

    For Each foundFile As String In TheFiles

    ListBox1.Items.Add(foundFile)

    Next

    and when the user selects a file in the listbox....

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

    Me.PictureBox1.Image = Image.FromFile(CStr(Me.ListBox1.SelectedItem))

    End Sub



  • Creating a Image Gallery