# [thelist] question concerning c#dynamicallychangingwhatisinapicturebox

Robert Vreeland vreeland at studioframework.com
Thu Aug 17 09:04:11 CDT 2006

Not sure if this will help,
But looking through some SDK examples I noticed two potential differences.
1. Use the full path to the file, ex.
@"c:some\path\to\image\image.bmp"
2. Add boolean true after the image path, ex.
Bitmap bgImage = new Bitmap(@"c:\Images\ClosedDoor.bmp", true);

Hope it helps
Robert Vreeland
StudioFramework

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Lightning
Sent: Thursday, August 17, 2006 9:30 AM
To: thelist at lists.evolt.org
Subject: Re: [thelist] question concerning
c#dynamicallychangingwhatisinapicturebox

Thanks, Chris.

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.

Laura
\
----- Original Message -----
From: "Chris Marsh" <thelist at cjmarsh.com>
To: <thelist at lists.evolt.org>
Sent: Tuesday, August 15, 2006 9:05 PM
Subject: Re: [thelist] question concerning c#
dynamicallychangingwhatisinapicturebox

> Lasuras
>
>> This is a practice piece. I've got an eleven floor elevator (0-10),
>> and an image for each floor. This routine tests to see if the floor
>> has an elevator car on it. If it does, it inserts a picture of an
>> elevator.
>> If it doesn't,
>> it uses a picture of elevator cables. I am doing this as part of a
>> portfolio, so I want it to LOOK cute, too!
>
> Your method CloseDoor() in the file Form1.cs needs changing. One
> solution is as follows (see code). Caveat: the variable imagePath
> requires a valid path to a file, otherwise an exception will be thrown
> on the following line.
>
> private void CloseDoor()
> {
>    for (I = 0; i < 10; i++)
>    {
>      string imgPath = myElevator.CloseElevatorDoor(i).ToString();
>      Bitmap bgImage = new Bitmap(imgPath);
>      pbxFloor0.BackgroundImage = bgImage;
>    }
> }
>
> You could contract this to a single line as follows, but I've left it
> as three lines in the interests of clarity.
>
> pbxFloor0.BackgroundImage = new
> Bitmap(myElevator.CloseElevatorDoor(i).ToString());
>
> Let me know if this solves your problem!
>
> HTH
>
> --
> Regards
>
> Chris Marsh
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.10.10/419 - Release Date:
> 15/08/2006
>
>
>
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester and
> archives of thelist go to: http://lists.evolt.org Workers of the Web,
> evolt !

--

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester and archives
of thelist go to: http://lists.evolt.org Workers of the Web, evolt !