图像未显示在Winforms中

时间:2012-07-03 15:57:11

标签: winforms image resources

我正在使用Winforms(C#.NET)。当我向资源查看器添加资源(图像)时,我可以看到它们。

enter image description here

但是当我将它们添加到表单时,只能看到灰色背景 - 图像不是。

enter image description here

但是当从本地资源加载图像时,它显示正常。我认为问题在于项目资源文件。我有什么不对吗?


编辑:这是设计师代码......

 <data name="addemployee" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\addemployee1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>


</data>
  <data name="addmovie" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\addmovie1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="buytickets" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\buytickets1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="changepassword" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\changepassword1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="customerregistration" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\customerregistration1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="deleteemployee" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\deleteemployee1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="movietheater" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\movietheater1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="welcomeadmin" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\welcomeadmin1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="welcomeform3" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\welcomeform31.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>
  <data name="welcomeform4" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Resources\welcomeform41.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  </data>

2 个答案:

答案 0 :(得分:1)

问题是Visual Studio的一个错误。尝试重新启动将有助于此..

答案 1 :(得分:0)

尝试将图片的属性更改为资源而不是内容,然后尝试一下