---
title: "Accessing image files from project resources"  
description: "Step 1:- Open Visual Studio  Step 2:- Create New Project, Rename Project if required (I have renamed it  as SinglePictureBox)      Step 3:- Add 1 No P"  
author: "Vilas Shende"  
published: 2013-10-06  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/605/accessing-image-files-from-project-resources  
category: "c#"  
tags: ["c#"]  
reading_time: 3 minutes  

---

# Accessing image files from project resources

Step 1:- Open [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available)\
Step 2:- Create New Project, Rename Project if required (I have renamed it\
as SinglePictureBox)\
![Accessing image files from project resources](http://4.bp.blogspot.com/-g-ubgkgxpB0/UlEDyITf2xI/AAAAAAAAAHA/TQ9PZXp1n7A/s400/1.png)\
\
Step 3:- Add 1 No PictureBox control from Toolbox on your blank form![Accessing image files from project resources](http://4.bp.blogspot.com/-h7e1GghMdyM/UlEEFNld8qI/AAAAAAAAAHI/DAI5UBQDSKo/s400/2.png)\
\
Step 4:- Add 3 Nos [Button Control](https://www.mindstick.com/articles/290/button-control-in-vb-dot-net) from toolbox on your form. (you can add \
less or more buttons as you desired)\
![Accessing image files from project resources](http://4.bp.blogspot.com/-jFv3E_n827g/UlEEQw4hhwI/AAAAAAAAAHQ/Y94lX2jrXFk/s400/3.png)\
\
\

Our GUI is ready now, before adding any images please rename their file

\

names like Img1, Img2 & Img3, so that it will easy to add & pick names in

\

[your code](https://www.mindstick.com/forum/157976/how-can-you-use-jquery-s-testing-framework-such-as-qunit-to-write-unit-tests-for-your-code) window, I have renamed 3 images [as mentioned](https://answers.mindstick.com/qa/38307/bring-out-the-significance-of-the-terms-sovereign-democratic-republic-as-mentioned-in-the-preamble) above.

\
\
Step 5:- Right click on [picture box](https://www.mindstick.com/forum/714/change-two-images-in-one-picture-box-using-a-button-vb-dot-net), go to property,\
![Accessing image files from project resources](http://1.bp.blogspot.com/-z6SKU34FwYg/UlEEdSqVNfI/AAAAAAAAAHY/nb6Fdp0IFu8/s400/4.png)\
\
Select ‘Image’ property, select ‘Import’ option, you will get brows for \
adding image files, now select any 3 Nos pictures (In this project I have \
added 3 Nos Button Controls so we need only 3 Nos images also, you can \
add less or more as you desired)\
![Accessing image files from project resources](http://4.bp.blogspot.com/-DkoIqZ8El4o/UlEEuqv79jI/AAAAAAAAAHg/kpwHHnyfSUI/s400/5.png)\
\
Step 6:- After addition of image, [select option](https://www.mindstick.com/forum/12881/select-option-generate-value-from-ajax-on-change) as ‘none’ & press Ok, so that \
when you run [your project](https://www.mindstick.com/forum/156583/best-way-to-link-bootstrap-file-in-your-project) then by default Picture box will show as blank.\
![Accessing image files from project resources](http://2.bp.blogspot.com/-mwWTF8zyNLo/UlEE65Vr4jI/AAAAAAAAAHo/e17Mhz4a2LM/s400/6.png)\
\
\
Now time to code our app\
Right click on your form & select view code,\
![Accessing image files from project resources](http://4.bp.blogspot.com/-gnLWLfd0pHo/UlEFFOzB18I/AAAAAAAAAHw/mjmGFcCZ3MU/s400/7.png)\
\
Your code window will open![Accessing image files from project resources](http://1.bp.blogspot.com/-VIgl4iizEEU/UlEFQ94wrkI/AAAAAAAAAH4/N67B4w6TJ4c/s400/8.png)\
Step 7: Add namespace in your code for pick image resources in each \
button, your name space will look like this\

```
using SinglePictureBox.Properties;
```

\
![Accessing image files from project resources](http://1.bp.blogspot.com/-hBClNHEtRS4/UlEFb_UVnzI/AAAAAAAAAIA/KDuTZ3_-JQM/s400/9.png)\
In above code, SinglePictureBox is project name as I renamed it while \
creating new project, if you have given any different name to you project \
then you have to use that name only instead on SinglePictureBox\
Now come back on your GUL (form Design)\
Step 8:- [Double click](https://www.mindstick.com/forum/155692/what-is-dfp-double-click-for-publisher) on Button1 & code this in [click event](https://www.mindstick.com/forum/424/how-to-call-form_paint-event-on-button-click-event)\

```
private void button1_Click(object sender, EventArgs e)        {            pictureBox1.Image = Resources.Img1;        }
```

In above code, Img1 will display after [button click](https://www.mindstick.com/forum/790/form-gets-submiited-twice-on-button-click).\
Again double click on Button2 & code this in click event\
\
{ pictureBox1.Image = Resources.Img2; }\
\
In above code, Img2 will display after button click.\
\
\
Once again double click on Button3 & code this in click event.\
\
{ pictureBox1.Image = Resources.Img3; }\
\
In above code, Img3 will display after button click.\
Your coding is done & your final code will look like this.

```
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using SinglePictureBox.Properties;namespace SinglePictureBox{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)        {            pictureBox1.Image = Resources.Img1;        }        private void button2_Click(object sender, EventArgs e)        {            pictureBox1.Image = Resources.Img2;        }        private void button3_Click(object sender, EventArgs e)        {            pictureBox1.Image = Resources.Img3;        }    }}
```

\
![Accessing image files from project resources](http://1.bp.blogspot.com/-685XtwyLzaU/UlEFons5jrI/AAAAAAAAAII/D9VyhvcKtZw/s400/10.png)\
\
\
Now run you code & check it works? Press all (3 Nos) buttons one by one \
you will get all image one by one in single picture box.\
\
![Accessing image files from project resources](http://3.bp.blogspot.com/-OH6_b4RJL5A/UlEF0rnB2kI/AAAAAAAAAIQ/mfSKMWrn_I4/s400/11.png)\
\
Thanks,

---

Original Source: https://www.mindstick.com/blog/605/accessing-image-files-from-project-resources

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
