Avatar of Fero45
Fero45 asked on

Collection of picture boxes; how to store image information?

Hi experts

I have a collection of picture boxes and to catch MouseHover event, I use this:

 Private Sub Generic_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles pic1.MouseHover, pic2.MouseHover, pic3.MouseHover, .....etc ...  pic120.MouseHover

        Dim control As PictureBox
        control = CType(sender, PictureBox)

        x = control.Location.X
        y = control.Location.Y

End Sub

I use ListBox to select a collection of dresses, so a particular PictureBox holds a different image every time. I store x and y as shown above, but how do I store the image information, namely its file name (xxxx.jpg) or the whole path?


Visual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon
Mike Tomlinson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

to Idle_Mind

if I use pic1.Tag = 'xxx"

this would mean I have to attach a tag to every picture before it is loaded. However when I move new images to the folder and them show them in PictureBoxes, it would be too much time. We have more than  a 1000 images.

I thought there could be something like, e.g.
??? string = control.image(ImageLocation(Path) ???


I'm not sure you question, but it sounds like you may not know that you can store anything in the Listbox items. They are objects.

That being said, create a class
class MyListBoxItem
    'put any member variables here

    'property accessors here

    'constructor here

    override function Tostring as string
         return 'whatever string you want to return from here, will be displayed in the list box
                    'but you can get the selected items in the listbox use
                    'use the above ctype and then access any of your objects properties to get access to the  filename which you would have stored when you popuplated it

    end function

end Class

IS this what you were looking to do?

Well, there is no way that anyone can view the 1000 images at a time.
Perhaps if you are determined to do it in pictureboxes  you need to set up a limited number of them and a vertical scrollbar and based on positioning, display the correct 50 at a time or whatever...you'd still need tags.

what I suggested above would work for a listbox.

However you might want to use a ListView control.  You can show the pictures, or choose to use Ownerdrawn to draw them however you want to in the ListView.  It was built to show things--like Explorer does on the right side.

In that case, create your own ListViewItemClass

class MyListViewItem
       inherits ListViewItem 'I'm not sure the entire path... system.forms.ListViewItem perhaps
end class

The above gives you default listview item stuff.
then you add a constructor
sub New(filepath as string)
      'this sub can the store the filepath in the object,
      'open it and do whatever you want to with it
      'it could even store the image inside of itself--however memory may or may not permit that
      'if it doesn't i.e. too many images... then your drawing method might need to see which ones are  
      'visible and load those..and then next N items pictures into memory and free ones from the others or  
      'something of this effect
end sub
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck

to SStory

List Box  contains collections of Flower Girl, Prom, Bridal gowns, Mothers, etc. List Box Selection populates PictureBoxes; every time a different image. Mouse Hover should store the image file name (usually a four digit number, eg. 2378.jpg) , go to the database and show a complete info about the dress (colors available, fabric, price, season)

images of a certain collection are shown as thumbnails for people in customer service area. Mouse Hover should give them quick info when they are on the phone.

Probably the idea of attaching a TAG to every image when the collection is populated is the best solution


Yes, TAG is is best way. Thanks for a good solution
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

Well... a listbox for category and a listview for displaying the images would probably work well too...with your own listviewitem...

since the question is closed... I will say no more.