add on click event to picturebox vb.net

Posted by Matt Facer on Stack Overflow See other posts from Stack Overflow or by Matt Facer
Published on 2010-05-03T20:11:59Z Indexed on 2010/05/03 20:18 UTC
Read the original article Hit count: 381

Filed under:
|
|

I have a flowLayoutPanel which I am programatically adding new panelLayouts to. Each panelLayout has a pictureBox within it. It's all working nicely, but I need to detect when that picture box is clicked on. How do I add an event to the picture? I seem to only be able to find c# examples....

my code to add the image is as follows...

        ' add pic to the little panel container
        Dim pic As New PictureBox()
        pic.Size = New Size(cover_width, cover_height)
        pic.Location = New Point(10, 0)
        pic.Image = Image.FromFile("c:/test.jpg")
        panel.Controls.Add(pic)

        'add pic and other labels (hidden in this example) to the big panel flow
        albumFlow.Controls.Add(panel)

So I assume somewhere when I'm creating the image I add an onclick event. I need to get the index for it also if that is possible! Thanks for any help!

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about picturebox