Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. How can I read a picture from a resource file?

How can I read a picture from a resource file?

Scheduled Pinned Locked Moved Visual Basic
questiontutoriallearning
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JUNEYT
    wrote on last edited by
    #1

    Hello! I created a resource file and then added all the pictures in it. However, I do not know how to retrieve a picture from resource file and assign it to a picturebox? Picturebox1.image = ? (How can assign a value here from resorce file?) Thanks!

    P D 2 Replies Last reply
    0
    • J JUNEYT

      Hello! I created a resource file and then added all the pictures in it. However, I do not know how to retrieve a picture from resource file and assign it to a picturebox? Picturebox1.image = ? (How can assign a value here from resorce file?) Thanks!

      P Offline
      P Offline
      progload
      wrote on last edited by
      #2

      Give this a try: http://www.codeproject.com/dotnet/embeddedresources.asp#xx319276xx[^] progload

      J 1 Reply Last reply
      0
      • P progload

        Give this a try: http://www.codeproject.com/dotnet/embeddedresources.asp#xx319276xx[^] progload

        J Offline
        J Offline
        JUNEYT
        wrote on last edited by
        #3

        Hi Progload! I was not able to open th eproject with vs 2005. Here is my method but I am started getting an eror message which I haven't solved it... Do you have any idea what is causing that? Thanks!:doh: ERROR MESSAGE IS :: MissingManifestResource Exception Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: Resources1.resx locationInfo: fileName: Resources1.resx.resources My Code is:: Dim rm as ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("Resources1.resx", ".", Nothing) PB_Mic.Image = rm.GetObject("epa_mic_in.gif")

        P 1 Reply Last reply
        0
        • J JUNEYT

          Hi Progload! I was not able to open th eproject with vs 2005. Here is my method but I am started getting an eror message which I haven't solved it... Do you have any idea what is causing that? Thanks!:doh: ERROR MESSAGE IS :: MissingManifestResource Exception Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: Resources1.resx locationInfo: fileName: Resources1.resx.resources My Code is:: Dim rm as ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("Resources1.resx", ".", Nothing) PB_Mic.Image = rm.GetObject("epa_mic_in.gif")

          P Offline
          P Offline
          progload
          wrote on last edited by
          #4

          Sorry, I don't have VS2005 yet, I believe that code was for VS2003. Maybe someone with VS2005 can help you. Sorry, progload

          T 1 Reply Last reply
          0
          • P progload

            Sorry, I don't have VS2005 yet, I believe that code was for VS2003. Maybe someone with VS2005 can help you. Sorry, progload

            T Offline
            T Offline
            TDSp
            wrote on last edited by
            #5

            Dragging the resource from the pane into your code inserts the location (it does on my VS05) -- modified at 18:19 Sunday 19th March, 2006

            1 Reply Last reply
            0
            • J JUNEYT

              Hello! I created a resource file and then added all the pictures in it. However, I do not know how to retrieve a picture from resource file and assign it to a picturebox? Picturebox1.image = ? (How can assign a value here from resorce file?) Thanks!

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              I'm assuming you're using VB.NET 2005. If you have the Application Framework turned on in your project (double-click My Project, Application tab), then it's pretty easy. Click on the Resrouces tab in My Project. Acrossed the top of the Resources window, the far left icon picks what type of resources are going to be listed in the window. The second one is, of course, Add Resource. Click on the drop-down arrow next to it, then pick Add Existing File. Pick the file has the image you want to add. Done! The image will be added to the window with the resource name under the image. You can rename it if you want to, you'll be using this name to refer to the image in your code. Close the My Project window and save changes. For an example, say I've added a .JPG with the resource name Sample. Now, in your code, all you have to do to, say, assign this image to a picturebox is:

              PictureBox1.Image = My.Resources.Sample
              

              It's that simple! RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups