newbie image question

  • Thread starter Thread starter Altman
  • Start date Start date
A

Altman

I added to gif images to my project and I want to programatically change my
picture box to those images but it is not working. This is what I am using.

picImage.Image.fromfile("myGif1.gif")
or
picImage.Image.fromfile("myGif2.gif")
 
Altman said:
I added to gif images to my project and I want to
programatically change my picture box to those images
but it is not working. This is what I am using.

picImage.Image.fromfile("myGif1.gif")
or
picImage.Image.fromfile("myGif2.gif")

\\\
picImage.Image = Image.FromFile("...")
///
 
Well ok I guess it kind of works. I am trying to make a library of controls
and I have one control that I want to change the picture based on what
property is chosen. I then have another project that will use these
controls. This project crashes with the code you gave me.
 
Altman said:
I then have another project that will use these controls. This project
crashes with the code you
gave me.

Are you sure the image is in the directory where the EXE and the DLL are
stored? What exception is thrown?
 
I was hoping that the image would be included in the dll. Is this possible?
Or do I have to have it outside the dll?
 
BTW the error I am getting is "NullReferenceException: Object reference not
set to an instance of an object." I don't get this error if I use the
control inside the same project though. If it is in a different project,
then I get the error.
 
Sorry wrong error, it is a filenotfoundexception




Altman said:
BTW the error I am getting is "NullReferenceException: Object reference
not set to an instance of an object." I don't get this error if I use the
control inside the same project though. If it is in a different project,
then I get the error.
 
Sorry wrong error, it is a filenotfoundexception




Altman said:
BTW the error I am getting is "NullReferenceException: Object reference
not set to an instance of an object." I don't get this error if I use the
control inside the same project though. If it is in a different project,
then I get the error.
 
Altman said:
I was hoping that the image would be included in the dll.
Is this possible?

Yes, that's possible. The code below shows how to do that for an icon, it
will work very similar for an 'Image'/'Bitmap':

Add the icon file to your project and set its 'Build Action' property to
'Embedded Resource'. You can use the code below to load the icon at
runtime:

\\\
foo.Icon = _
New Icon( _
[Assembly].GetExecutingAssembly().GetManifestResourceStream( _
"WindowsApplication1.Ball.ico" _
) _
)
///

'WindowsApplication1' is the root namespace of the application, "Ball.ico"
is the icon's filename.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top