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 do i get an image to appear in a picture box using the open file dialog??

How do i get an image to appear in a picture box using the open file dialog??

Scheduled Pinned Locked Moved Visual Basic
questiondatabase
4 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.
  • C Offline
    C Offline
    China Gary
    wrote on last edited by
    #1

    I would like be able to open up a .jpg file from the open file dialog and then have the selected picture appear in a picture box, for submitting to a database at a later stage. Is this easily done? This is what i have so far, and am a small bit confused as to where to go! Dim OpenFileDialog As New OpenFileDialog OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments OpenFileDialog.Filter = "Image files (*.jpg)|*.jpg|" If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then 'what do i need to do from here??? End If Thanks

    C 1 Reply Last reply
    0
    • C China Gary

      I would like be able to open up a .jpg file from the open file dialog and then have the selected picture appear in a picture box, for submitting to a database at a later stage. Is this easily done? This is what i have so far, and am a small bit confused as to where to go! Dim OpenFileDialog As New OpenFileDialog OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments OpenFileDialog.Filter = "Image files (*.jpg)|*.jpg|" If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then 'what do i need to do from here??? End If Thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      pictureBox.Image = Image.FromFile(OpenFileDialog.FilePath) Something like that

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      C I 2 Replies Last reply
      0
      • C Christian Graus

        pictureBox.Image = Image.FromFile(OpenFileDialog.FilePath) Something like that

        Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

        C Offline
        C Offline
        China Gary
        wrote on last edited by
        #3

        Thanks!

        1 Reply Last reply
        0
        • C Christian Graus

          pictureBox.Image = Image.FromFile(OpenFileDialog.FilePath) Something like that

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          I Offline
          I Offline
          IqbalVB
          wrote on last edited by
          #4

          Don't forget to clear previous image, and there's no filepath property in the openfiledialog, remember that. So use filename instead. pictbox.Image = Nothing pictbox.Image = image.fromfile(openfiledialog.filename)

          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