1.绝对路径:
this.pictureBox2.Image=Image.FromFile("D:\\001.jpg");
2.相对路径:
Application.StartupPath;
可以得到程序根目录
this.pictureBox2.Image=Image.FromFile(Application.StartupPath "\\1.gif");
3.获得网络图片的路径
this.pictureBox2.Image= Image.FromStream(System.Net.WebRequest.Create(http://www.pxkt.com/logo.gif).GetResponse().GetResponseStream());
自适应大小属性:BackGroundImageLayout=Stretch,SizeMode=StretchImage
本文详细介绍了在编程中如何使用不同路径加载图片,包括绝对路径、相对路径和网络路径的使用方法。同时,还讲解了如何设置自适应大小属性,使图片能够更好地适应界面。
2114

被折叠的 条评论
为什么被折叠?



