Hi!
Tried searching the forums but I came up short, sorry if I'm asking the same stupid question over and over.
I got a code snippet that looks like this

private void pictureBox1_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = Image.FromFile(@"IMAGEPATH\test1.jpg");
        }

Since I'm a real newbie at programming I want to know how to code to make the other picture clickable aswell and when you click it it returns to the first image in the picturebox. Any help or links are appreciated (everything 'cept for rtfm-comments ;) )

Recommended Answers

All 2 Replies

I guess I need to understand what you are looking for. Do you want multiple pictureboxes that are clickable? Or do you want to have multiple images cycle through a single picturebox when it's clicked?

Somethin like this?

private void pictureBox1_Click(object sender, EventArgs e)
        {
            if(pictureBox1.Image == Image.FromFile(@"IMAGEPATH\test1.jpg")){
                pictureBox1.Image = Image.FromFile(@"IMAGEPATH\test2.jpg");
            }else{
                pictureBox1.Image = Image.FromFile(@"IMAGEPATH\test1.jpg");
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.