Windows Phone Developers

Sunday, January 25, 2009

How to Add Resources to C# Windows Application

How to add images as resources to C# Windows Application

Resources can be added to the C# Project using Resource Page in the Project Designer (Project à Project Properties)

The Resources page of the Project Designer hosts an instance of the Resource Designer that stores and maintains resources in a single location (Resources.resx).

The Resource Designer is language-neutral and supports projects in all Visual Studio languages. Items that you add to the project by using the Resource Designer are placed in the Resources directory for your project. The designer information is stored in a file named Resources.resx, and code for the resource is stored in Resources.Designer.cs, Resources.Designer.vb, or Resources.Designer.jsl.

Right Click the Resources section in the solution explorer and Select Add à Existing Item and select the Image files that need to be added

The images will be added as shown below

Drag the images to the Resources page – Rename the resource names if needed

Now you can use the Resources in your Form. Select the BackGroundImage from the Form’s properties box – Click on the ellipsis next to the BackGroundImage property. This will open the Select Resource dialog Box

Select appropriate resource from the list

The same can be set through code using

this.BackgroundImage = Properties.Resources.User_Single

For linkedresources see - Create HTML Message with Embedded Images in VB.NET / Embed images in HTML mail message using VB.NET

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon


  1. Hey, this is kind of easy. But how can I, when I added a text file to the resources, write into this file. Read the file is kind of easy Properties.Resources.[nameOfResource]

    I hope you can help me

  2. hay i have a problem.
    i want to add a .wav file. as my project is distributed means i have to run it on different computers. then how to use relative paths??