By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,719 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,719 IT Pros & Developers. It's quick & easy.

c# noob question. difficulty with picturebox.image and if statement

P: 1
Hi there, I'm pretty new to c# (started up a few days ago) and I'm making a simple program, so far everything is going good except I can't figure somethine out.. hence why I'm here.

Anyways, in my program I have a picture box that when the user clicks it I want it to change the picture, and when the user clicks it again I want it to change back to the first image. So I figured a simple if statement would work, well it doesn't. Again I'm a complete c# noob and I might be missing something, or going about it the wrong way. here is the code I have so far

if (pictureBox.Image == global::WindowsApplication.Properties.Resources.im age1)
{
pictureBox.Image = global::WindowsApplication.Properties.Resources.im age2;
}
else
{
pictureBox.Image = global::WindowsApplication.Properties.Resources.im age1;
}

I've googled this a lot and I can't seem to find an answer or an example of anyone doing something like this with a picturebox, so I figured I would ask here. Thanks in advance.
Oct 6 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.