Pointing to an image file -- "does not contain a definition for Properties"

I wish the background property of my form to point to an image file instead of importing one, but when I try to do so in the property window I get the compile error:

"does not contain a definition for Properties"

The following code had been generated:

this.BackgroundImage = MyApplication.Properties.Resources.myForm;

Am I missing a using statement
Instead, importing an image goes fine, but I want to allow the user to change the image.

Is there an easy way to locate where in System something is, so I can find the necessary using statements myself

Regards,

  Guido



Answer this question

Pointing to an image file -- "does not contain a definition for Properties"

  • 5thCav

    MyApplication.Properties.Resources is an auto-generated class that the IDE creates when you add resources through the Project Properties tab.  MyApplication is your namespace name you set up in the Project Properties tab.  You can find the class under the Properties folder in Solution Explorer.

    You can't use *.Properties.Resources if you want to allow the user to arbitrarily change the image because this class is dynamically generated from the resources embedded in the project.  Instead you should use *.Properties.Settings which contains any application/user-level settings you have specified.  This class doesn't actually exist until you add a setting through the Project Properties.  I would recommend that you add a user-level setting that is the path to an image file to load.  You can default it to an appropriate image.  You then simply use framework to open the image file and assign it to your BackgrounImage property.

    Michael Taylor - 10/1/05

  • IronMan

    Thanks, that's what I ended up doing.
    Still, it seems to be a bug in VS.

  • Pointing to an image file -- "does not contain a definition for Properties"