繁体   English   中英

如何使用C#将图像加载到Visual Studio中的PictureBox上

[英]How to Load an Image onto PictureBox in Visual Studio using C#

我一直在尝试使用以下代码使用C#将图像从“我的资源”加载到Visual Studio 2012上的图片框

pictureBox1.Load(Properties.Resources.Desert);

而且我得到了以下错误。

  1. System.Windows.Forms.PictureBox.Load(string)的最佳重载方法匹配具有一些无效的参数
  2. 参数1:无法从System.Drawing.Bitmap转换为string

Load方法采用一个string 您直接向它传递的资源是Bitmap ..这是行不通的。

尝试这个:

pictureBox1.Image = Properties.Resources.Desert;

这将直接将PictureBox的图像设置为您资源中的Bitmap

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM