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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It says System.Drawing.Image does not contain a definition for FromFile.
What's up with this?
What's up with this?
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
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.
ASKER