Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a window form with picture control ,

I want to set the image for this picture control dynamically in code

I have a dropdown with two value red and green ,if user click on green picture control will show green image and vice-versa

picGreen.ImageLocation = System.Drawing.Image.FromFile(Application.StartupPath("..\\Resources\\Red_button_small_16x16.png"))


also when i build the project i just want a exe ,i dont want any image folder .
Posted

1 solution

Add the file in your resources folder
then you use it like this

to add a resource file
1) open the project properties tab
2) select the resources tab
3) select the add resources
now add the file and then use it like this

XML
PictureBox1.Image = My.Resources.MyImg
 
Share this answer
 
Comments
aassaahh 11-Nov-13 23:59pm    
i can see all my images in form.resx ,
PictureBox1.Image = My.Resources.MyImg in above code

what is My.Resources.MyImg ?? what is MyImg ?
aassaahh 12-Nov-13 0:00am    
is MyImg the file name or image name ???
aassaahh 12-Nov-13 0:16am    
i got it thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900