[thelist] question concerning c#dynamicallychangingwhatisinapicturebox

Chris at globet.com Chris at globet.com
Thu Aug 17 09:00:10 CDT 2006


> I am still struggling over it. I will let you know how it comes out.
> To simplify things, I am trying to get THIS code to work:
> Bitmap bgImage = new Bitmap(@"\Images\ClosedDoor.gif");
> pbxFloor0.Image = bgImage;
> I got it off the msn pages, so it SHOULD work, but I get a
> message that it doesn't like the parameter.

This error message probably means that the path is not valid. As far as
my tests with your project went, I needed an absolute path as an
argument to the Bitmap constructor. If the path was not correct or
relative, then I received the same error mesdsage as you specify. I
haven't got your project installed on this computer, but try the
following. The path should be relative to your Windows Form, I think.

Bitmap bgImage = new Bitmap(Path.GetFullPath(@"Images/ClosedDoor.gif"));
pbxFloor0.Image = bgImage;

If you still have problems, assign
Path.GetFullPath(@"Images/ClosedDoor.gif") to the Text property of a
Label so that you can see it, and check in Windows Explorer that the
path points to the actual file.

Chris Marsh
Software Developer
t: +44 20 8246 4804 x828
f: +44 20 8246 4808
e: chris at globet.com
w: http://www.globet.com/

Any opinions expressed in this email are those of the individual and not
necessarily the Company. This message is intended for the use of the
individual or entity to which it is addressed and may contain
information that is confidential and privileged and exempt from
disclosure under applicable law. If the reader of this message is not
the intended recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly prohibited.
If you have received this communication in error, please contact the
sender immediately and delete it from your system. 

More information about the thelist mailing list