I want Picture show (image viewer)and this code is not working Please Help

PictureBox[] arrpic = new PictureBox[5];
            arrpic[0] = pic1;
            arrpic[1] = pic2;
            arrpic[2] = pic3;
            foreach (PictureBox pb in arrpic)
            {
                picshow.Show(pb);
            }

Recommended Answers

All 3 Replies

A PictureBox is a control and thus needs to be added to a form. You'll need to set the positions and size of the PictureBox before you add it to the forms control collection.

Please send me complete code of image viewer in picture box

On line 1 of your code you created an array of 5 PictureBoxes.
You still have to create the PictureBoxes!
Line 2 will give a NullReferenceException!
You have to do something like this:

arrpic[0] = new PictureBox();
arrpic[0].Image = Properties.Resources.Pic1;
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.