Results 1 to 3 of 3

Thread: Resources

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    19

    Question Resources

    I have been developing an application, and I have been trying to figure out how resources work. The online MSDN help does not work for what I am trying to do. My program will have a lot of images(about 8) on the main form, and I want the user to be able to customize them. The problem is if they are embedded you have to recompile for it to work.

    I want the form to simply look at the Application.Startpath + "\\layout\\" location for the image. I tried to do this manually in the constructor, form load, and even in the designer file for the form. The constructor(after initialize components) and form load caused the images to take 2 seconds to load after the form is displayed(not acceptable). And since the old images were added in the resource cache previously, it just keeps rewriting my code. I got it to work for one form, but not the other. Every time I change it, the IDE changes it back to embedded. All my resource files have been deleted, and the IDE keeps remaking the form.resx one itself. I hope this is enough of an explanation, can someone please help me understand how to fix this?

    Basically the old resource information is hosing up my form's images. If I manually change them, it doesn't show in the environment. If I add them back in, it makes them embedded automatically, even using "Local Linked" resources. I am confused.

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Resources

    I'm not sure exactly what you're asking. But I'm getting the most from the following sentence:

    . My program will have a lot of images(about 8) on the main form, and I want the user to be able to customize them.
    You can add recourses by going to the Resource tab of the application's properties.

    Then, assign each component's image like so:

    My.Resources.myImage

    If you want the User to be able to change the image, just make some sort of options, like a ContextmenuStrip. And in each item, set the appropriate image.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

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

    Re: Resources

    I think the reason that you're having trouble is the fact that resources won't do what you want them to do. Resources are compiled into your EXE and, as such, are read-only. Changing an image would require you to recompile and redeploy the app.

    If you want the user to be able to change the images then you can't use resources. You would simply create a folder specifically for those images and put them there, then read them at run time. The user can then replace those files with images of their own and your app will load those new images next time it runs.

    You might provide functionality in your app for the user to choose image files and then you can copy and rename them in code, ensuring that the names and locations are correct.
    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

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