pictureBox控件获得图片路径的三种方法及自适应大小属性

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

posted @ 2016-08-10 16:09  DBing  阅读(8885)  评论(0)    收藏  举报