We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,627 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Picture slide show

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);
            }
3
Contributors
3
Replies
3 Hours
Discussion Span
1 Year Ago
Last Updated
4
Views
yousafc#
Junior Poster in Training
98 posts since Feb 2011
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

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.

Momerath
Senior Poster
3,726 posts since Aug 2010
Reputation Points: 1,322
Solved Threads: 624
Skill Endorsements: 12

Please send me complete code of image viewer in picture box

yousafc#
Junior Poster in Training
98 posts since Feb 2011
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

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;
ddanbe
Industrious Poster
4,277 posts since Oct 2008
Reputation Points: 2,121
Solved Threads: 720
Skill Endorsements: 26

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0589 seconds using 2.69MB