Reputation: 570
I'm unable to make my pictureboxes to be shown on form. Am i doing it wrong or? This is my code:
static Bitmap[] pictures = new Bitmap[9];
PictureBox[] picBox= new PictureBox[9];
on the constructor :
pictures[1] = new Bitmap(@"1.1Bright.jpg");
* picBox[1].Location = new System.Drawing.Point(25, 7);
picBox[1].SizeMode = PictureBoxSizeMode.StretchImage;
picBox[1].ClientSize = new Size(53, 40);
picBox[1].Image = pictures[1];
I keep getting nullreferenceexception error on *
Upvotes: 0
Views: 6820
Reputation: 570
got it:
picBox[0] = new PictureBox();
this.Controls.Add(this.picBox[0]);
Upvotes: 0
Reputation: 1500245
You haven't set picBox[1]
to reference anything. You need something like:
picBox[1] = new PictureBox();
Do you really want the pictures
variable to be static though? The array contents will be overwritten every time you create an instance of the form...
Upvotes: 3