0

On the click event of the picturebox, I've tried the following:

picturebox1.image = imagelist1.index?????

I don't know the syntax, how do I choose a picture from an imagelist and place it into a picturebox. Thanks :)

3
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by LizR
1

Something like : picturebox1.image = imagelist1.Images[currentIndex]; might do the trick. imaglist must contain images of course.

Votes + Comments
Solved my problem.
0

Something like : picturebox1.image = imagelist1.Images[currentIndex]; might do the trick. imaglist must contain images of course.

Exactly what I was looking for. Thanks man. :D

0

Another problem arises!

Here's what I want to program to do:
1. When the game starts the picturebox loads an image from the imagelist.

2. When the player clicks an image I want to the "if" statement to ask if the image in the picturebox is the imageindex "x".

How could I do this?

I think I'm asking the wrong question because this doesn't work:

private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Image == imageList1.Images[0])
            {
                pictureBox1.Image = imageList1.Images[1];
            }
        }
0

You could always have a boolean flag which you use to show the different pictures ..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.