Coding Help!

Started by Gold Man, June 01, 2014, 06:00:27 PM

Previous topic - Next topic
June 01, 2014, 06:00:27 PM Last Edit: June 01, 2014, 06:02:23 PM by Gold Man
Hey guys, I've got a problem, this time it's not computer-related, but programming-related.

Anyways, I have to have a project handed pretty soon (by soon I mean tomorrow), and I've run into a problem. I'm trying to use the following code:

Code (c#) Select

//capeBox1 is a drop-down selection box.
if (capeBox1.Text == "Bloody Demon Cape")
                accessoryBox1.Image = Properties.Resources.bdc;
//bdc is an image file I'm trying to have show up in accessoryBox1 (which is a PictureBox).


I know it should work, but it keeps popping up with the following error:

Quote
'System.Windows.Forms.PictureBox' does not contain a definition for 'image' and no extension method 'image' accepting a first argument of type 'System.Windows.Forms.PictureBox' could be found (are you missing a using directive or an assembly reference?)

Any idea what I'm doing wrong? I also need a response fast! :confused:

This is different from what I do... but in HTML, you can't do images if you don't have the file type after the image.

So... if the BDC is your image then you need to put bdc.jpg (or whatever kind of file type it is. Might not be .jpg)

I hope it works for you. Honestly I'd be astonished if it did because I'm no help at all! :shrug:

Formerly:
{Alpha}Gen.Ultimo
[212]Cpl.Ultimo
WUSi.Whisper

First thing I can tell you is that nine out of ten times when I write code that "should work" it's because I've written it wrong or made some small mistake somewhere. If I had a dime for each time a simple typo had screwed me over... I would have a few dollars.

Quote'System.Windows.Forms.PictureBox' does not contain a definition for 'image' and no extension method 'image' accepting a first argument of type 'System.Windows.Forms.PictureBox' could be found (are you missing a using directive or an assembly reference?)

I can't see System.Windows.Forms.PictureBox in your code snippet but "image" isn't meant to start with a capital by any chance? In the code you did post it had one.

PS. Welcome to the wonderful world of learning a new library. Enjoy your stay!

June 01, 2014, 06:31:21 PM #3 Last Edit: June 02, 2014, 04:20:16 PM by Gold Man
Quote from: SleepKiller on June 01, 2014, 06:23:45 PM
First thing I can tell you is that nine out of ten times when I write code that "should work" it's because I've written it wrong or made some small mistake somewhere. If I had a dime for each time a simple type had screwed me over... I would have a few dollars.

I can't see System.Windows.Forms.PictureBox in your code snippet but "image" isn't meant to start with a capital by any chance?

PS. Welcome to the wonderful world of learning a new library. Enjoy your stay!

Well, that's just it. I've tried without a capital, and it still gave me the same response. I have this code snippet within the capeBox1 private void, and trying it in the accessoryBox1 void doesn't work either. I'm using the same code as a friend of mine (were building two different designers for our own games), and they both are using the same code, more or less. The code he used for images is the same I'm using for mine, but for some reason it isn't working.

I assume it could be with how I have the directory path in the code, so I might try to toy with that.

EDIT: It doesn't work. I honestly don't know where I've gone wrong this time.

EDIT: Tried it again at school (through a Remote Desktop application that was on at home on my laptop), and the lowercase "i" was the bug! I have no idea why it wouldn't work last night though? :confused:

Anyways, it works now, thanks!