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
  1. Home
  2. General Programming
  3. Visual Basic
  4. Picturebox Control Question

Picturebox Control Question

Scheduled Pinned Locked Moved Visual Basic
6 Posts 3 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
    JohanSturk
    wrote on last edited by
    #1

    Hi all, I started learning VB.NET a few months ago and I love it. What I'm having trouble with though is that I'm trying to assign a picturebox to a listbox so that the picture changes when selecting another item. But I can't figure out how. The pictures are in the project resource files, how do I assign them to the process? There's 78 pictures. :) The form with the picturebox and listbox.[^] Cheers!

    M J 2 Replies Last reply
    0
    • J JohanSturk

      Hi all, I started learning VB.NET a few months ago and I love it. What I'm having trouble with though is that I'm trying to assign a picturebox to a listbox so that the picture changes when selecting another item. But I can't figure out how. The pictures are in the project resource files, how do I assign them to the process? There's 78 pictures. :) The form with the picturebox and listbox.[^] Cheers!

      M Offline
      M Offline
      M Hall
      wrote on last edited by
      #2

      Is your question about extracting the resources or assigning them to the picturebox

      1 Reply Last reply
      0
      • J JohanSturk

        Hi all, I started learning VB.NET a few months ago and I love it. What I'm having trouble with though is that I'm trying to assign a picturebox to a listbox so that the picture changes when selecting another item. But I can't figure out how. The pictures are in the project resource files, how do I assign them to the process? There's 78 pictures. :) The form with the picturebox and listbox.[^] Cheers!

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

        First, it depens on how you want to use resources. Are these embeded pictures as resources in your project or you are going to load them from references or from a specific directory. :wtf:

        What a curious mind needs to discover knowledge is noting else than a pin-hole.

        J 1 Reply Last reply
        0
        • J JUNEYT

          First, it depens on how you want to use resources. Are these embeded pictures as resources in your project or you are going to load them from references or from a specific directory. :wtf:

          What a curious mind needs to discover knowledge is noting else than a pin-hole.

          J Offline
          J Offline
          JohanSturk
          wrote on last edited by
          #4

          Well what I want to do is; When the user selects an item in the ListBox, the PictureBox loads a file from the resources and displays it, and when the user selects another item, the PictureBox do the same procedure but gets another picture. Since I've never used code to grab something from the resources, I have no clue on where and how I'm gonna load them. A friend of mine gave me this[^] link where it was described how a PictureBox could be used. pictureBox1.Image = _ new Bitmap(Assembly.GetExecutingAssembly(). _ GetManifestResourceStream("PictureBoxControl.tinyemulator_res.jpg")) The issue with this is that first Assembly is undefined and second that, well I have no freakin' idea on where the UI input should be. Is that enough to help me? :) Cheers!

          M J 2 Replies Last reply
          0
          • J JohanSturk

            Well what I want to do is; When the user selects an item in the ListBox, the PictureBox loads a file from the resources and displays it, and when the user selects another item, the PictureBox do the same procedure but gets another picture. Since I've never used code to grab something from the resources, I have no clue on where and how I'm gonna load them. A friend of mine gave me this[^] link where it was described how a PictureBox could be used. pictureBox1.Image = _ new Bitmap(Assembly.GetExecutingAssembly(). _ GetManifestResourceStream("PictureBoxControl.tinyemulator_res.jpg")) The issue with this is that first Assembly is undefined and second that, well I have no freakin' idea on where the UI input should be. Is that enough to help me? :) Cheers!

            M Offline
            M Offline
            M Hall
            wrote on last edited by
            #5

            First do you have Imports System.Reflection at the beginning of your code, you need that to access the Assembly object. For the next part use the ListBox SelectedIndexChanged event, use the selecteditem value to index your resource file. Hope that helps:)

            1 Reply Last reply
            0
            • J JohanSturk

              Well what I want to do is; When the user selects an item in the ListBox, the PictureBox loads a file from the resources and displays it, and when the user selects another item, the PictureBox do the same procedure but gets another picture. Since I've never used code to grab something from the resources, I have no clue on where and how I'm gonna load them. A friend of mine gave me this[^] link where it was described how a PictureBox could be used. pictureBox1.Image = _ new Bitmap(Assembly.GetExecutingAssembly(). _ GetManifestResourceStream("PictureBoxControl.tinyemulator_res.jpg")) The issue with this is that first Assembly is undefined and second that, well I have no freakin' idea on where the UI input should be. Is that enough to help me? :) Cheers!

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

              Please check this link out http://msmvps.com/blogs/JayHarlow/default.aspx[^] It can give you an idea. If I were you, I would use embeded resources of course it is much easier to deal. Also here is another approach:

              The following example uses the ResourceManager.GetObject method to retrieve and display a binary resource (such as a graphic image).
              …
              Dim private rm As ResourceManager
              rm = New ResourceManager("MyImages", Me.GetType().Assembly)
              PictureBox.Image = Ctype(rm.GetObject("MyObject"), System.Drawing.Image)
              …
              

              :wtf: -- modified at 16:24 Monday 12th March, 2007

              What a curious mind needs to discover knowledge is noting else than a pin-hole.

              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