图片显示在表单加载中 [英] Image show on form load

查看:75
本文介绍了图片显示在表单加载中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在项目文件夹的Picturebox上的窗体上显示图像.
没有人有代码请转发它.
在此先感谢.

how to show image on form load on picturebox from project folder.
did anyone have code pls forward it.
thanks in advance.

推荐答案

您的朋友这样使用

在项目.exe文件位置中创建一个文件夹,例如(驱动器名:\\ projectname \ bin \ Debug \ img),然后在其中创建映像.
然后执行这段代码

hi friend use like this

create a folder in your project .exe file location like (drivename:\\projectname\bin\Debug\img) and your image there.
then execute this code

private void Form1_Load(object sender, EventArgs e)
       {
           pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\img\\1.jpg");
       }



问候
sarva



regards
sarva


您的工作目录应该是项目文件夹,因此Image.FromFile("filename.bmp")应该可以正常工作.
Your working directory should be the project folder, so Image.FromFile("filename.bmp") should actually work fine.
Path.GetDirectoryName(Application.ExecutablePath);

会为您提供运行代码的文件夹.

will give you the folder the code is running from, though.


这篇关于图片显示在表单加载中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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