TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jerry Fike
NA
107
0
Another Newbie Queastion
Nov 5 2010 10:31 PM
I've been trying to figure this out for a while. I have some code that looks like this:
PictureBox p = null;
PictureBox pb_dice = null;
for(int i = 1l I < 7; i++)
{
p = this.Controls["p" + i.ToString()] as PictureBox;
pb_dice = this.Controls["p_dice" + i.ToString()] as PictureBox;
p.Image = WindowsFormsApplication1.Properties.Resources.diceBlank;
pb_dice.Image = WindowsFormsApplication1.Properties.Resources.diceBlank;
}
When I run it, I get an error "Object reference not set to an instance of an object." for the pb_dice.Image, but the p.Image works fine. The resource diceBlank.png is valid and I double-
checked that both Pictureboxes are indeed pictureboxes. Both pictureboxes properties are identical and neither are part of a group or panel.
I'm using Visual Studio C# 2010 Express.
Any suggestions?
Reply
Answers (
7
)
Issue Closing (X-ing out) a Windows Form
Downloading an application from the web?