Results 1 to 5 of 5

Thread: Can i get Image path from PictureBox?

  1. #1
    albertkhor is offline VB.NET Forum Genius
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jan 2006
    Posts
    150
    Reputation
    113

    Can i get Image path from PictureBox?

    i have a database which is use to store a photo and i use PictureBox to show the photo. Can i get Image path from PictureBox?

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,611
    Reputation
    2738
    In .Net 2.0 the PictureBox got an ImageLocation property you can get/set, also when using Load method, but not when just assigning an image/bitmap to the Image property.

    For .Net 1.1 you have to manage this yourself, one tip is to also put the path in the Tag property of the control.

    Please update your Primary Platform in User CP, albertkhor.

  3. #3
    TwoWing is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Jan 2006
    Location
    Near Portsmouth, England
    Posts
    71
    Reputation
    111

    Can I get image path from picture box?

    Hi albertkhor. I am not sure if this is exactly what you want, but at least it will give you something to work on that I know works because I have just built it for you and am copying and pasting the code.
    Start a new project. On the Form put a PictureBox and two buttons. Also from the Toolbox you will need to double-click on an OpenFileDialog. I changed the Name of mine to ofdLookalike.
    To the first button click event, put this code:-
    Code:
     
    'Show the open file dialog box.
    If ofdLookalike.ShowDialog = DialogResult.OK Then
    'Load picture into picture box.
    picPictureShow.Image = Image.FromFile(ofdLookalike.FileName)
    'Show the name of the file in the Form's caption.
    Me.Text = "Picture Show (" & ofdLookalike.FileName & ")"
    End If
    Now, put this code in to the second button's click event:-
    Code:
     
    MsgBox("Picture Show (" & ofdLookalike.FileName & ")")
    If I can help you further I shall do my utmost to do so.
    Code:
     
    Sometimes, just having the tools is not enough - a good guide will show how to use them.

  4. #4
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,611
    Reputation
    2738
    TwoWing, you could very well be right that albertkhor didn't mean what he was asking: if it is possible to read the file path of the image the picturebox is currently displaying..

  5. #5
    TwoWing is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Jan 2006
    Location
    Near Portsmouth, England
    Posts
    71
    Reputation
    111
    I have just tested my proj again. With the first button click the OFD gets the user to locate a picture in its 'file' and put it in the PictureBox. The second click the OFD tells the user how it found it.(To put it simply!)
    Build it and see for yourself.
    In any case, albertkhor will have something he can exercise with. I learned a lot from having a simple thing like that.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking