方法有三:
第一种:(此方法比较笨)
在页面上隐藏几个需要改变页面上图片的picturebox,比如下面的picFrom
在需要改变图片的方法处先定义:
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
然后就可以改变了(比如picTo的图片要改变成picFrom的图片)
this.picTo.Image = ((System.Drawing.Image)(resources.GetObject("picFrom.Image")));
第二种:
使用 FileStream 对象,如下所示:
Dim fs As System.IO.FileStream
' Specify a valid picture file path on your computer.
    fs = New System.IO.FileStream("C:\WINNT\Web\Wallpaper\Fly Away.jpg",
IO.FileMode.Open, IO.FileAccess.Read)
PictureBox1.Image = System.Drawing.Image.FromStream(fs)
fs.Close()

第三种(我认为是比较好的)
使用 Image.FromFile 方法在 PictureBox 控件中加载图片,该图片文件将在您启动应用程序时锁定。 

在应用程序运行时,图片文件保持锁定。 即使在运行时将 Image 属性设置为 Nothing,图片文件仍将锁定。

PictureBox1.Image = Image.FromFile("C:\WINNT\Web\Wallpaper\Fly Away.jpg")


From:
http://www.cnblogs.com/black263/archive/2008/01/12/1036021.html

相关文章:

  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-07-22
  • 2021-11-17
  • 2021-11-08
猜你喜欢
  • 2021-05-26
  • 2022-12-23
  • 2021-11-30
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案