473,383 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
0 1343

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

Similar topics

0
by: kylin | last post by:
uses statement: System.Windows.Forms.PictureBox pictureBox1; System.Windows.Forms.Panel panel1; pictureBox1 = new System.Windows.Forms.PictureBox(); panel1 = new...
0
by: akh | last post by:
I want to use de Drag and Drop ´s event to move a picture box from a form and within a Picture Box. But I have behaviour if the MyPBox As PictureBox as the Globale varible or not Thanks for...
9
by: rut | last post by:
If I have a picturebox with a background image and I want to 1. Display text atop of the background and 2. Have transistions between text; ie, when the text changes, the screen can fade out/in...
3
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
38
by: johnb41 | last post by:
I have a Picturebox that has an image displayed inside. Through code, I was able to have the "whole image" display in it without distortion. (Like a "Fit All" in most any image viewer program) ...
10
by: wandii | last post by:
Hi, I have a table which contains a BLOB field for image. I would like to copy a picture from database directly to a picture box control and I have tried the following: Dim c as Integer c =...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
4
by: Jerry West | last post by:
I have a routine that updates a PictureBox image every x seconds. I do this by first loading an array with the path to all of the images. I then generate a random number to use as the index of the...
1
by: veer | last post by:
Hi i want to save image from picturebox into sql but i got the error 'ARTHEMATIC OPERATIONS RESULTED IN AN OVERFLOW' On line bytBLOBData = New Byte() {ms.Length} here is my code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.