如何在代码页的vb.net中使用img路径设置图像控件 [英] How to set image control with img path in vb.net in code page

查看:258
本文介绍了如何在代码页的vb.net中使用img路径设置图像控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个带图片控件的窗口表格,



我想动态设置这个图片控件的图像代码



如果用户点击绿色图片控件将显示绿色图像,反之亦然



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"))





当我构建项目时我只想要一个exe,我不想要任何图像文件夹。



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

推荐答案

在资源文件夹中添加文件

然后你就像这样使用



to添加资源文件

1)打开项目属性选项卡

2)选择资源选项卡

3)选择添加资源

现在添加文件然后像这样使用



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

PictureBox1.Image = My.Resources.MyImg


这篇关于如何在代码页的vb.net中使用img路径设置图像控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆