Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to set/change teh background image of a form at runtime. I found this code, but I always get the error: "Invalid parameter used".

 

dlgStartUp.BackgroundImage = new Bitmap("dictionary.jpg");

 

Can someone tell me how to get a jpg on the form please?

  • Leaders
Posted
Does it work if you use a bmp instead? It could be a problem with the JPG. Have you tried other JPGs?

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

  • *Experts*
Posted

Maybe you could try this:

Put the .jpg bitmap file in the Bin directory of your project then call the bitmap with:

dlgStartUp.BackgroundImage = Image.FromFile(Application.StartupPath & "\dictionary.jpg")

 

or if dlgStartUp is a form then

Me.BackgroundImage = Image.FromFile(Application.StartupPath & "\dictionary.jpg")

 

Then remember to include the .jpg file in the project's distributation package.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted

This is what I tried:

this.BackgroundImage = new Bitmap(GetType().Assembly.GetManifestResourceStream("Thai_Dictionary.dictionary.jpg"));

 

Where "Thai_Dictionary" = the name of the namespace/project/solution

And "dictionary.jpg" = the name of the image

 

I alsways get the following:

'null' is not a valid value for 'stream'.

Posted (edited)

I tried your C# example and that works. When I try my project it does NOT work. I tried it with space, underscore, .... nothing works.

 

My image is just under the namespace.

 

I included the project, so if you like you can have a look. I must warn you the thing is full of test and most of them don't work.

ThaiDictionary.zip

Edited by PlausiblyDamp
  • Administrators
Posted

Couldn't build the app as it's missing a few references, however make sure that the build action for the jpeg is set to 'Embedded Resource' in the property window.

Also it may be worth mentioning that you are using a beta version of vs.net and as such things may differ from the current release.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

I tried it in a test program and it worked.

 

Today I put it in my library. This is a different namespace and a different solution. As you can guess this does not work anymore.

 

Any idea's on how to solve this?

 

The thing is that I have a property on soSytem with the name of the image. When I create the StartUp form, I want to load the image and then display it.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...