Windows Phone Developers

Tuesday, August 3, 2010

How to Add Images to Project Resources in C#/.NET






How to add/deploy Images in C#/.NET (Visual Studio)

You can add images as resources to the project. The images will be stored as part of your solution and get deployed when you deploy your solution. To add an image to the project, select Resources Tab from Project Properties and click on Add Resources; Select an appropriate file

Resources Tab in Visual Studio


Once the image is added it will be displayed as shown below:



The resource file is part of your project as shown below:


To access the image from code use the following

public System.Drawing.Bitmap GetButtonImage(Office.IRibbonControl control)
        {
            switch(control.Id)
            {
                case "btnmoscow":
                    return Properties.Resources.moscow;
.
.
,
                default:
                    return null;

            }           

        }

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

No comments:

Post a Comment

kbAlertz.com :: Visual Studio 2005

kbAlertz.com :: Visual Studio 2008

kbAlertz.com :: Visual Basic 2005