Results 1 to 7 of 7

Thread: [HELP CODE BEGINNER] RETRIEVE THE name picture FROM A PICTUREBOX ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2017
    Posts
    96

    Exclamation [HELP CODE BEGINNER] RETRIEVE THE name picture FROM A PICTUREBOX ?

    Hi everyone!

    i have some trouble to finish my program!

    my problem is how can i retrieve the name of a picture from a picturebox without extension on a label

    SOMETHING LIKE THIS: label1.text = picturebox1.image.text or picturebox1.image.name ( obviously these exemples are wrong i know!)

    thank you in advance for your answer!
    Last edited by kareninstructor; Dec 22nd, 2020 at 12:25 PM. Reason: formatting

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,630

    Re: [HELP CODE BEGINNER] RETRIEVE THE name picture FROM A PICTUREBOX ?

    Picturebox1.ImageLocation seems like what you are looking for.

    A list of all Picturebox properties is here:

    https://docs.microsoft.com/en-us/dot...5.0#properties

  3. #3
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,630

    Re: [HELP CODE BEGINNER] RETRIEVE THE name picture FROM A PICTUREBOX ?

    In the end, if all you want is the name of the file (no preceding path, and no extension), then you would get the ImageLocation value, and then pass that to Path.GetFileNameWithoutExtension

    https://docs.microsoft.com/en-us/dot...n?view=net-5.0

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [HELP CODE BEGINNER] RETRIEVE THE name picture FROM A PICTUREBOX ?

    Image objects don't have a name. If you expect to get the name of the file that the Image was loaded from then you could have got that when you opened the file. If you want to take OptionBase1's advice and use the ImageLocation property to get the path of the file from which the Image was loaded then you have to have used that property in the first place to load it, or else called the Load method. If you called Image.FromFile and assigned the result to the Image property then the PictureBox has no knowledge of the original file. I suggest that you always do use either ImageLocation or Load to populate a PictureBox from a file, unless you have a specific need for an Image object that you can use elsewhere as well.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: [HELP CODE BEGINNER] RETRIEVE THE name picture FROM A PICTUREBOX ?

    lol this is why questions should be explicit because I'm thinking he is trying to extract a name from an actual image.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [HELP CODE BEGINNER] RETRIEVE THE name picture FROM A PICTUREBOX ?

    Quote Originally Posted by Niya View Post
    lol this is why questions should be explicit because I'm thinking he is trying to extract a name from an actual image.
    I wasn't really sure myself but the fact that the OP says "without extension" makes me think that it's about the file name. It would be nice if people would actually say what they mean though. Every time we have to assume or guess, there's the chance we'll get it wrong and waste everyone's time.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: [HELP CODE BEGINNER] RETRIEVE THE name picture FROM A PICTUREBOX ?

    Quote Originally Posted by jmcilhinney View Post
    I wasn't really sure myself but the fact that the OP says "without extension" makes me think that it's about the file name. It would be nice if people would actually say what they mean though. Every time we have to assume or guess, there's the chance we'll get it wrong and waste everyone's time.
    It was phrased so awkwardly that it didn't even occur to me that he was talking about file extensions. In addition to being explicit, I feel people need to take the time to write their questions. Too many times, like OP in this case, the questions read like they were written and posted in a hurry. On occasions where I ask something I always take my time.

    For example, I recently asked this on SO. It took me about 30 minutes to write that because I was constantly re-reading and changing it to make sure I was as clear as possible about what I wanted. And even then I still had to go back and edit it after I posted because someone still misunderstood what I wanted. So yea, man you're right. We can save a lot of time if we are clear on what is being asked.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width