Results 1 to 4 of 4

Thread: [RESOLVED] how to access files added to the project?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Location
    Australia
    Posts
    130

    Resolved [RESOLVED] how to access files added to the project?

    Hi folks.

    In the solution explorer I have created a pics folder, then added files to the folder. I could use "Me.PictureBox1.ImageLocation = path" for pic files that have not been added to the project. But now that the files are added to the project, is there a way of accessing them directly? For example "Picturebox.Load(1.jpg)". Is there any difference in how files are accessed whether they are part of the project or not?

    Thanks in advance.
    Attached Images Attached Images  

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,380

    Re: how to access files added to the project?

    Add them to your resources. To do so:
    1) Double-Click 'My Project' in the Solution Explorer
    2) Click on the resources tab in the left hand column
    3) Change the 'Strings' drop-down box to 'Images'
    4) Click on the arrow for the 'Add Resources'
    5) Click on add existing files

    To access the images you'd set the picturebox like this:
    Code:
    PictureBox1.Image = My.Resources.1
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Location
    Australia
    Posts
    130

    Re: how to access files added to the project?

    Thanks dday9.

    I followed all the steps, and the image file is added as _1.jpg in the resources window(even though in solution explorer it shows as 1.jpg). Then intellisense completes the statement as "PictureBox1.Image = My.Resources._1", and the picture does not load in the picturebox.

    I can use the properties window to choose the image as a project resource and the image loads fine. "PictureBox1.Image = My.Resources.1" results in an error message, "PictureBox1.Image = My.Resources._1" does not, but the image doesn't load.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Location
    Australia
    Posts
    130

    Re: [RESOLVED] how to access files added to the project?

    Ok, works now. I had accidentally put the statement in the picturebox's click event handler, so no image is displayed until I click on it.

    Thanks for your help dday9!

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