图片来源winform

发布于 2024-07-29 02:33:52 字数 204 浏览 6 评论 0原文

您好,如何将图像源设置为 winforms 中的图像?

我的图像位于应用程序的资源文件夹中,只是

我尝试过这样的

PictureBox pb = new PictureBox(); pb.Image = Image.FromFile("资源/a.gif");

但它显示文件未找到异常。

提前致谢

Hi how can i set image source to an image in winforms?

my images are in Resources folder in the application only

I tried like this

PictureBox pb = new PictureBox();
pb.Image = Image.FromFile("Resources/a.gif");

But it is showing file not found exception.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

删除→记忆 2024-08-05 02:33:52

如果图像位于应用程序的资源中,您可以这样做:

pb.Image = Properties.Resources.a

If the image is in your application's resources, you can do that :

pb.Image = Properties.Resources.a
失退 2024-08-05 02:33:52
pictureBox1.Image = Properties.Resources.[image name];
pictureBox1.Image = Properties.Resources.[image name];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文