Link to home
Start Free TrialLog in
Avatar of tr309
tr309

asked on

Setting PictureBox.Image property

Hi,

I have a PictureBox control on my form and I'm having difficulty setting its Image property at run-time. I was trying this:

imgDisplay.Image = System.Drawing.Image ...

expecting Intellisense to give me the FromFile() method, but I can't seem to access any of the Image methods.

I was hoping to supply a string containing the filename to this method.

Can anyone help?

Thanks,

Rich
Avatar of tr309
tr309

ASKER

I forgot to mention that this is in .Net Compact Framework as I'm developing for PocketPC2003.
ASKER CERTIFIED SOLUTION
Avatar of zupi5
zupi5

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tr309

ASKER

It says System.Drawing.Image does not contain a definition for FromFile.

What's up with this?
Avatar of tr309

ASKER

Oh well. I think I've found the solution. Contrary to descriptions provided by numerous online sources (including MSDN) - the way to set the Image property of a PictureBox at run-time is by using the System.Drawing.Bitmap class:

Bitmap test = new Bitmap(@"\Temp\test.jpg");
pictureBox1.Image = test;

At least, this worked for me.

Never mind.

Thanks anyway,

Rich
oh you are using compact framework, did not see that post while writing my response. :NET compact framework Image object does not support FromFile function, you'll have to doit with the bitmap.